Skip to content

✨clusterctl: move shared objects #2161

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

Conversation

fabriziopandini
Copy link
Member

What this PR does / why we need it:
This PR refactors clusterctl in order to support move when two or move clusters are sharing some objects (like e.g. Templates or LoadBalancers).

The PR takes a generic approach to solve this problem and the move sequence is defined by processing the ownerReference chain, so we ensure that a node is moved only after its owners.

Additionally, nodes are grouped, so each group of nodes can be moved in parallel. e.g.

  • All the Clusters should be moved first because they have no OwenerReferences
  • All the MachineDeployments should be moved second because they have OwenerReferences to clusters, which are moved as part of the first group
  • then all the MachineSets should be moved second because they have OwenerReferences to MachineDeployments, which are moved as part of the second group
  • etc.

Which issue(s) this PR fixes:
rif: #1729

/area clusterctl
/assign @ncdc
/assign @vincepri

@k8s-ci-robot k8s-ci-robot added area/clusterctl Issues or PRs related to clusterctl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 27, 2020
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.

First pass, thanks for working on this!

}

// Define the move sequence by processing the ownerReference chain, so we ensure that a node is moved only after its owners.
// Additionally nodes are grouped, so bulk of nodes can be moved in parallel. e.g.
Copy link
Member

Choose a reason for hiding this comment

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

Should we s/node/resource/ here? I can extrapolate that it's meant to mean a node in the graph, but it could likely cause someone not familiar with cluster api to think it means a k8s Node resource here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I will make a pass to make it clear in the comment where we are talking about nodes in the graphs, but I would like to keep the names as it is.

@fabriziopandini
Copy link
Member Author

@ncdc @vincepri @detiber comments addressed, ready for another pass.

@fabriziopandini
Copy link
Member Author

/retest

@fabriziopandini
Copy link
Member Author

@ncdc @vincepri it seems that tests are flaking, probably due to parallel move. it will be ok for you removing the parallelism now? without "WaitForMachines", there is no real need for this additional level of complexity now...

@vincepri
Copy link
Member

vincepri commented Jan 28, 2020

@fabriziopandini Go for it, we don't need it to be parallel now

@fabriziopandini
Copy link
Member Author

@vincepri done

@vincepri
Copy link
Member

@fabriziopandini

Seems linter is unhappy

cmd/clusterctl/pkg/client/cluster/mover.go:244:32: Using the variable on range scope `nodeToCreate` in function literal (scopelint)
			return o.createTargetObject(nodeToCreate, toProxy)
			                            ^
cmd/clusterctl/pkg/client/cluster/mover.go:361:32: Using the variable on range scope `nodeToDelete` in function literal (scopelint)
			return o.deleteSourceObject(nodeToDelete)

@fabriziopandini fabriziopandini force-pushed the clusterctl-move-shared-objects branch from c2d2ff1 to 22be9f9 Compare January 28, 2020 17:13
@fabriziopandini
Copy link
Member Author

@vincepri CI is happy again 😉

@ncdc ncdc added this to the v0.3.0 milestone Jan 28, 2020
@fabriziopandini
Copy link
Member Author

/test pull-cluster-api-e2e

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
/assign @ncdc

for final lgtm

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini, 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 Jan 29, 2020
},
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
graph, err := getDetachedObjectGraphWihObjs(tt.fields.objs)
gb, err := getDetachedObjectGraphWihObjs(tt.fields.objs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm getting a little bit obsessed by code readability 🤣
If you prefer I can rollback

@fabriziopandini
Copy link
Member Author

@ncdc comment addressed

@ncdc
Copy link
Contributor

ncdc commented Jan 30, 2020

LGTM. @fabriziopandini please squash!

@fabriziopandini fabriziopandini force-pushed the clusterctl-move-shared-objects branch from 3be299c to ca66c55 Compare January 31, 2020 06:59
@fabriziopandini
Copy link
Member Author

@ncdc done!
@vincepri for the final lgtm

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.

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 31, 2020
@k8s-ci-robot k8s-ci-robot merged commit f068437 into kubernetes-sigs:master Jan 31, 2020
@fabriziopandini fabriziopandini deleted the clusterctl-move-shared-objects branch January 31, 2020 16:30
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. area/clusterctl Issues or PRs related to clusterctl 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants