Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Ensure move uses mutated metadata when updating a target object #24

Conversation

dlipovetsky
Copy link
Collaborator

@dlipovetsky dlipovetsky commented Jul 29, 2024

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 #

Previously, createTargetObject updated an object using the metadata
(including namespace) of the unmutated object, even when the object
was mutated.
Copy link

@takirala takirala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @dlipovetsky !

@cwyl02 we need to backport this to 1.6.x release cuz we cant consume 1.7.x in kommander due to controller runtime.

@dlipovetsky dlipovetsky merged commit 05da24c into mesosphere:d2iq/release-1.7.4 Jul 29, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants