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

🌱 Refactor KubeadmConfig object update during cluster upgrades #4049

Closed

Conversation

srm09
Copy link
Contributor

@srm09 srm09 commented Jan 5, 2021

What this PR does / why we need it:
This patch removes the multiple update calls made to ETCD while updating the kubeadmConfig spec during upgrades. Instead, all the updates are batched into a single patch call made at the end of the reconcile loop.

Which issue(s) this PR fixes:
Fixes #4007

@k8s-ci-robot k8s-ci-robot added 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 5, 2021
@srm09
Copy link
Contributor Author

srm09 commented Jan 5, 2021

/hold
Waiting for #3994 to get merged.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 5, 2021
@srm09
Copy link
Contributor Author

srm09 commented Jan 5, 2021

/cc @shysank @fabriziopandini

@k8s-ci-robot
Copy link
Contributor

@srm09: GitHub didn't allow me to request PR reviews from the following users: shysank.

Note that only kubernetes-sigs members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @shysank @fabriziopandini

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@srm09 srm09 force-pushed the refactor/kubeadm_config_map branch 2 times, most recently from 4ad6f75 to c229ddd Compare January 5, 2021 21:47
@srm09
Copy link
Contributor Author

srm09 commented Jan 5, 2021

/retitle 🌱 Refactor KubeadmConfig object update during cluster upgrades

@k8s-ci-robot k8s-ci-robot changed the title 🌱 Refactor KubeadmConfig object 🌱 Refactor KubeadmConfig object update during cluster upgrades Jan 5, 2021
@srm09 srm09 force-pushed the refactor/kubeadm_config_map branch from c229ddd to a395518 Compare January 6, 2021 18:41
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jan 6, 2021
Comment on lines 77 to 80
patchHelper, err := patch.NewHelper(kubeadmConfig.GetConfigMap(), r.Client)
if err != nil {
return ctrl.Result{}, err
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fabriziopandini @vincepri I was having a conversation with @shysank around this, and he mentioned that workload clusters might be managing their own config maps (and these config maps do not get stored in the management cluster). Is that actually the case, in which case, the client used to initialize the patchHelper above would not do the right thing.

Copy link
Member

Choose a reason for hiding this comment

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

The kubeadm configmap should be technically only managed through a Cluster API deployment (KCP in this case),

With the changes above, it doesn't seem to me that we'd overwrite other data, apart from the one that we're managing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the patchHelper initialized with the managementCluster.Client would correctly persist the changes to the kubeadmConfig. Thanks for clearing it up.

Copy link
Contributor

Choose a reason for hiding this comment

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

Just want to confirm on the patch helper client. The code above gets the config map from the workload cluster, but the patch helper updates the config map in the management cluster. Shouldn't the patch helper also use the workload cluster's client? I'm not entirely sure if we should be updating the management cluster's kubeadm config map.

Copy link
Member

Choose a reason for hiding this comment

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

yes ^

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

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

In general, I really like the fact that we are cleaning up the Workload Cluster interface.
I still have to complete the review, but I will start with few initial comments on the new KubeamConfig interface

controlplane/kubeadm/controllers/upgrade.go Outdated Show resolved Hide resolved
controlplane/kubeadm/internal/kubeadm_config_map.go Outdated Show resolved Hide resolved
controlplane/kubeadm/controllers/upgrade.go Outdated Show resolved Hide resolved
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign justinsb after the PR has been reviewed.
You can assign the PR to them by writing /assign @justinsb in a comment when ready.

The full list of commands accepted by this bot can be found 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 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 11, 2021
@srm09
Copy link
Contributor Author

srm09 commented Jan 12, 2021

@fabriziopandini I refactored the methods according to the pointers you had provided. I have a doubt that I need to clear and then I will finalize the changes in the PR

@srm09
Copy link
Contributor Author

srm09 commented Jan 13, 2021

@vincepri Added the change to update the patchHelper with the workload cluster's client. PTAL.

@srm09
Copy link
Contributor Author

srm09 commented Jan 13, 2021

/test pull-cluster-api-test-main

@srm09
Copy link
Contributor Author

srm09 commented Jan 14, 2021

/retest

@fabriziopandini
Copy link
Member

/milestone v0.4.0
Changes lgtm to me and as I said before I like the fact that we are cleaning up the Workload Cluster interface.
Hopefully, we can get some more opinions about this PR...

@k8s-ci-robot k8s-ci-robot added this to the v0.4.0 milestone Jan 19, 2021
@srm09 srm09 force-pushed the refactor/kubeadm_config_map branch from dc1c5f0 to 7d29954 Compare January 19, 2021 17:07
@srm09
Copy link
Contributor Author

srm09 commented Jan 19, 2021

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 19, 2021
@vincepri
Copy link
Member

@srm09 Please squash :)

Instead of issuing multiple update calls during the KCP upgrade, the
reconciler makes the changes to the same kubeadmConfig object and the
changes to the object are persisted using a patch() call.
This also removes the intermediate methods on the WorkloadCluster
interface and the reconciler calls these methods directly on the
kubeadmConfig object.
This also exposes a getter for workload cluster's client

Signed-off-by: Sagar Muchhal <[email protected]>
@srm09 srm09 force-pushed the refactor/kubeadm_config_map branch from 7d29954 to 1e171e5 Compare January 19, 2021 17:12
@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 Jan 19, 2021
@srm09
Copy link
Contributor Author

srm09 commented Jan 27, 2021

@justinsb @vincepri Do the changes look fine? Any suggestions around improvements or feedback?

@srm09
Copy link
Contributor Author

srm09 commented Mar 19, 2021

Might need to rework this, this PR stopped working. If I could get some feedback around the approach, I can open another PR for this one.

@k8s-ci-robot
Copy link
Contributor

@srm09: PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 19, 2021
@vincepri
Copy link
Member

@srm09 I can chat more tomorrow sync if that helps, although I'd suggest to add more description about the solution chosen and the problem we're trying to solve

@srm09
Copy link
Contributor Author

srm09 commented Mar 24, 2021

@vincepri I tried revising this PR off the latest main branch, but it is broken. Maybe, I need to rethink this change a bit since there is a lotta mocking that needs to be done for the unit tests to be run.

@CecileRobertMichon
Copy link
Contributor

/lgtm cancel

PR needs rebase

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 13, 2021
@fabriziopandini
Copy link
Member

The goal of this PR still is valid but I'm wondering we we should freeze this effort and reconsider at later stage because a lot is changing in this part of the codebase as a consequence of the the introduction of embedded kubeadm types & the introduction of the support for multiple kubeadm API versions.
e.g #4443 is going to refactor quite a bit how the kubeadm config map is managed...

@srm09
Copy link
Contributor Author

srm09 commented Jul 23, 2021

/close

@k8s-ci-robot
Copy link
Contributor

@srm09: Closed this PR.

In response to this:

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

Refactor kubeadm ConfigMap update during cluster upgrade
6 participants