Skip to content

✨clusterctl: create the object graph for move #2060

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

@fabriziopandini fabriziopandini commented Jan 14, 2020

What this PR does / why we need it:
This PR implements the creation of a graph of Kubernetes objects to be moved.

The graph is built by reading from the cluster:

  • All the Kuberentes objects of types created by the CRDs installed by clusterctl
  • Secrets, Config Map

The graph is built by navigating object references.

While creating the graph, the ower references are "reversed" so each object has its own set of descendants.

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

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 14, 2020
@k8s-ci-robot k8s-ci-robot requested review from ncdc and vincepri January 14, 2020 13:58
@fabriziopandini
Copy link
Member Author

/assing @vincepri
/assing @ncdc

fields: fields{
proxy: test.NewFakeProxy().
WithObjs(
test.FakeCustomResourceDefinition("foo", "Bar", "v1", "v2"),
Copy link
Contributor

Choose a reason for hiding this comment

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

Missing this function definition

Copy link
Member Author

Choose a reason for hiding this comment

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

[1] waiting for #2059 to merge (I broke up in two PRs to keep this one as focused as possible)

@fabriziopandini
Copy link
Member Author

@ncdc thanks for the feedback!
I addressed everything that can be addressed before #2059 merges with the exception of #2060 (comment) because the resulting code will be much more verbose. Let me know if I have to fix it despite that.

@ncdc ncdc added this to the v0.3.0 milestone Jan 16, 2020
@ncdc
Copy link
Contributor

ncdc commented Jan 17, 2020

Is this ready for rebasing?

@fabriziopandini fabriziopandini force-pushed the clusterctl-move-object-graph branch from af7da0a to 7df5f03 Compare January 17, 2020 16:02
@fabriziopandini
Copy link
Member Author

fabriziopandini commented Jan 17, 2020

@ndcd rebased
the only change required was for adapting the test framework to the fact that Discovery picks up the storage version only for each API resource

@ncdc ncdc added the area/clusterctl Issues or PRs related to clusterctl label Jan 17, 2020
@ncdc
Copy link
Contributor

ncdc commented Jan 17, 2020

Thanks, will review shortly.

"bootstrap.cluster.x-k8s.io/v1alpha3, Kind=DummyBootstrapConfig, ns1/m1": {
dependents: []string{
"/, Kind=Secret, ns1/m1",
//"/, Kind=Secret, ns1/cluster1-sa",
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Member Author

Choose a reason for hiding this comment

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

leftover of some tests. removed.

@ncdc
Copy link
Contributor

ncdc commented Jan 17, 2020

Really close! Just a few questions.


// dependents contains the list of nodes that are owned by the current node.
// Nb. This is the reverse of metadata.OwnerRef.
dependents map[*node]struct{}
Copy link
Member

Choose a reason for hiding this comment

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

You can use Empty instead of struct{} here if you want https://godoc.org/k8s.io/apimachinery/pkg/util/sets#Empty

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 found using sets.Empty a little bit confusing, so I have redefined empty locally and now it reads
map[*node]empty

@fabriziopandini fabriziopandini force-pushed the clusterctl-move-object-graph branch from 7df5f03 to 24f9aef Compare January 18, 2020 09:49
@fabriziopandini
Copy link
Member Author

fabriziopandini commented Jan 18, 2020

@vincepri @ncdc
I have answered your questions! (and squashed latest nit into a single commit)

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 18, 2020
@fabriziopandini fabriziopandini force-pushed the clusterctl-move-object-graph branch from 24f9aef to abbd257 Compare January 21, 2020 15:53
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 21, 2020
@fabriziopandini
Copy link
Member Author

@ncdc fixed #2060 (comment) comment

@ncdc
Copy link
Contributor

ncdc commented Jan 21, 2020

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 21, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini, ncdc

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 21, 2020
@k8s-ci-robot k8s-ci-robot merged commit 1183a15 into kubernetes-sigs:master Jan 21, 2020
@fabriziopandini fabriziopandini deleted the clusterctl-move-object-graph branch January 22, 2020 08:46
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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Define clusterctl move process
4 participants