🐛 Ensure move uses mutated metadata when updating a target object #24
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.
What this PR does / why we need it:
The
createTargetObject
function is called as part of the move operation. It creates the target object, i.e. the object on the target cluster. If the target object already exists, the function updates the object.Previously, the function fixed the name and namespace of the target object before it applied the experimental mutators. If some mutator modified the namespace of the target object, the function would continue to use the namespace established before the mutators were applied.
This adds a new (failing) unit test, and ensures that the target object namespace reflects the changes made by the experimental mutators.
--
We discovered this issue in a more complex scenario than the one in the new unit test.
In our scenario, we started the move operation, passing a mutator that changes the target namespace. The
createTargetObject
function try to create a ClusterClass in the target namespace. However, CAREN would copy the same ClusterClass to the namespace, and so the function would try to update it.Because of the bug fixed here, the function read the ClusterClass in the default namespace on the target cluster, and then tried to update the ClusterClass in the target namespace, all the while using the UID and resource version of the ClusterClass in the default namespace:
https://github.com/mesosphere/cluster-api//blob/d6afeb8e33d9565680345b84e900c1d78a8ab76f/cmd/clusterctl/client/cluster/mover.go#L1005-L1019
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Fixes #