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

🐛 clusterctl: update move to support new cluster validations #5625

Merged
merged 1 commit into from
Nov 11, 2021

Conversation

ykakarap
Copy link
Contributor

@ykakarap ykakarap commented Nov 9, 2021

What this PR does / why we need it:

This PR fixes the clusterctl move order so that any ClusterClass that are in use are moved to the target cluster before the Clusters that used them are moved.

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 #5620

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 9, 2021
@ykakarap
Copy link
Contributor Author

ykakarap commented Nov 9, 2021

/test pull-cluster-api-e2e-full-main

@ykakarap
Copy link
Contributor Author

/retest

Copy link
Member

@sbueringer sbueringer left a comment

Choose a reason for hiding this comment

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

Only did a high-level review for now.

Q: Did I understood the clusterctl move logic correctly:

  • target cluster: create one group after another
  • source cluster: delete one group after another in reverse order

That would mean:

  • target cluster: ClusterClasses are created before Clusters
  • source cluster: Clusters are deleted before ClusterClasses

(of course only if they actually depend on each other)

If I got it right, the move will still work when we introduce a webhook on the ClusterClass, which makes sure that a ClusterClass is only deleted after it's not used anymore in any Clusters.

cmd/clusterctl/client/cluster/objectgraph.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/cluster/objectgraph.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/cluster/objectgraph.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/cluster/objectgraph.go Outdated Show resolved Hide resolved
cmd/clusterctl/client/cluster/objectgraph.go Outdated Show resolved Hide resolved
// if the cluster uses a managed topoloy and uses the clusterclass
// set the cluster as a soft owner of the clusterclass.
if className, ok := cluster.additionalInfo[clusterTopologyNameKey]; ok {
if className == clusterClass.identity.Name && clusterClass.identity.Namespace == cluster.identity.Namespace {
Copy link
Member

Choose a reason for hiding this comment

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

Let's check also group

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just for my understanding: why would we want to check the group?

Here we are making sure that the clusterclass used in the cluster spec (cluster.spec.topology.class) matches the clusterclass we are checking against and we are making sure that the cluster and the clusterclass belong to the same namespace because we know that this is a requirement.
By checking groups we are saying that clusters and clusterclasses should belong to the same k8s group cluster.x-k8s.io. I dont see how this is a requirement to establish a soft ownership.

Am I missing something?

Copy link
Member

Choose a reason for hiding this comment

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

No you are right.
I did not look at the code above and I did assume we were looping through all the objects, not only clusters

@ykakarap
Copy link
Contributor Author

/test pull-cluster-api-e2e-full-main

@ykakarap
Copy link
Contributor Author

/test pull-cluster-api-e2e-full-main

@ykakarap
Copy link
Contributor Author

ykakarap commented Nov 11, 2021

@sbueringer That is correct. Because of the new soft ownership between the clusters and the cluster classes that are in use we can guarantee that any ClusterClass that is in use will be moved to the target cluster before the cluster object is moved.

@fabriziopandini
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 11, 2021
Copy link
Member

@vincepri vincepri left a comment

Choose a reason for hiding this comment

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

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: vincepri

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 11, 2021
@k8s-ci-robot k8s-ci-robot merged commit a5505de into kubernetes-sigs:main Nov 11, 2021
@k8s-ci-robot k8s-ci-robot added this to the v1.1 milestone Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clusterctl move should move ClusterClass before Clusters
5 participants