Fill known hosts when parsing cluster from API #4738
+49
−5
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cluster.KnownHosts are not part of REST API definitions, so we don't set them when running parseCluster.
It resulted in passing cluster with uninitialized
known hosts to ClusterService.PutCluster and in some cases to overwriting previously correctly discovered known hosts. This in turn could lead to connectivity issues as described in #4733.
To fix that, this commit fills known hosts of the cluster parsed from REST API before passing it to ClusterService.PutCluster. The only other place where parseCluster is used is on cluster creation, but we don't have any discovered known hosts at this point, so there is no need to fill them.
In terms of testing, this commit extended test checking connectivity check on cluster update. The problem is that since the fix targeted just the API handler, it's difficult to test it reliably without mocks. In order to bypass, additional safety net which fills missing known hosts in ClusterService.PutCluster was added. With that, we can validate that passing nil Cluster.KnowHosts to
ClusterService.PutCluster results in not losing the already discovered known hosts. So even if the initial API handler fix does not work, this safety net should correct it.
Fixes #4733