-
Notifications
You must be signed in to change notification settings - Fork 39k
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
Fix race condition when joining nodes #72030
Fix race condition when joining nodes #72030
Conversation
Hi @ereslibre. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
Despite we were checking for the kubelet kubeconfig file to be present, the kubelet first writes this file and then the certificates the kubeconfig file refers to. This represents a race condition in kubeadm in which when we confirm that the kubelet's kubeconfig file is present we continue creating a clientset out of it. However, the clientset creation will ensure that the certificates the kubeconfig file refers to exist on the filesystem. To fix this problem, not only wait for the kubelet's kubeconfig file to be present, but also ensure that we can create a clientset ouf of it on our polling process, while we wait for the kubelet to have performed the TLS bootstrap.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ereslibre Thanks! For this PR
I'm ok with improving this wait cycle in order to make it more robust.
However, I kindly ask opinion from @luxas / @timothysc as well, because I think that if there is a flake in the kubelet TLS bootstrap might be better to get it fixed in kubelet as well.
I did a little bit of research in kubelet code base, and if I got it right the kubelet.conf file is written here, but if I got this right this happen after all the certificates are written to disk...
@fabriziopandini As far as I could see from the kubelet bootstrap logic:
Between This is what I understood from a first inspection of the source code, if I'm wrong please correct me. I don't think the way the kubelet bootstraps is flake itself per-se, but how kubeadm is solely waiting for the kubelets final kubeconfig to be present, and assuming that at that very moment it exists we can continue creating a clientset out of it (when the kubelet might not yet have written the certificates to disk and created the symlink for the current). The kubelet always bootstraps just fine, but is kubeadm the one that aborts the execution when trying to create the clientset; causing the cri annotation to not be created on the new node (and potentially further operations that could be added in the future to not happen after that failure). Let's wait for @luxas and/or @timothysc to confirm, thanks for your time @fabriziopandini! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the proposed solution @ereslibre !
I kind of share the opinion of @fabriziopandini, that this is probably a kubelet problem, that needs to be fixed on their side. We may ping some SIG-Node folks for this.
However, if we need to fix it on our side, then I am OK with the proposed solution.
/ok-to-test
For the sake of completion, apart from the error itself, here's more evidence about the times these files have been created:
As you can see |
@ereslibre thanks for the super detailed analysis! I let the final lgtm to @luxas / @timothysc |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ereslibre, fabriziopandini 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 |
Since we are getting near to v1.13.2 I make this merge on master in order to start working in the cherry pick. I defer @timothysc / @luxas opinion to the cherry pick PR |
@ereslibre can you add a release note to this PR as it's needed for the cherry-pick PR too? |
…030-upstream-release-1.13 Automated cherry pick of #72030: Fix race condition when joining nodes
What type of PR is this?
/kind bug
What this PR does / why we need it:
Despite we were checking for the kubelet kubeconfig file to be present, the
kubelet first writes this file and then the certificates the kubeconfig file
refers to. This represents a race condition in kubeadm in which when we confirm
that the kubelet's kubeconfig file is present we continue creating a clientset
out of it. However, the clientset creation will ensure that the certificates the
kubeconfig file refers to exist on the filesystem.
To fix this problem, not only wait for the kubelet's kubeconfig file to be
present, but also ensure that we can create a clientset ouf of it on our polling
process, while we wait for the kubelet to have performed the TLS bootstrap.
Which issue(s) this PR fixes:
Fixes kubernetes/kubeadm#1319
Does this PR introduce a user-facing change?: