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

Wait for APIServer 'ok' forever during CSINode initialization during Kubelet init #89589

Merged
merged 2 commits into from Mar 30, 2020

Conversation

jsafrane
Copy link
Member

@jsafrane jsafrane commented Mar 27, 2020

This is fixed version of #88000 when @davidz627 is out.

  • fixed unit test speed
  • added logs
  • probe API server by getting a dummy CSINode object. Kubelet may have limited permission during TLS bootstrap and we need kubelet with real permission to publish CSINode.

I kept David's commit there, so he gets credit for the fix.


If APIServer takes a long time to initialize (faster than the timeout for CSI Node intialization) the Kubelet may kill itself before the APIServer has time to come up. This PR makes it so that the goroutine that initializes CSINode will poll and wait for APIServer initialization before starting the exponential backoff to create CSINode objects.

Fixes: #87964

/cc @misterikkit @msau42 @rphillips @marun @tedyu
/kind bug

CSINode initialization does not crash kubelet on startup when APIServer is not reachable or kubelet has not the right credentials yet.

davidz627 and others added 2 commits March 27, 2020 18:27
To speed up unit tests and add more observability when things go wrong.
@k8s-ci-robot k8s-ci-robot added kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Mar 27, 2020
@k8s-ci-robot k8s-ci-robot added sig/storage Categorizes an issue or PR as relevant to SIG Storage. and removed needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Mar 27, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jsafrane

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 Mar 27, 2020
@jsafrane
Copy link
Member Author

/priority important-soon

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Mar 27, 2020
@jsafrane jsafrane force-pushed the fix-node-startup branch 2 times, most recently from 224dd86 to 60e901a Compare March 27, 2020 18:15
@jsafrane
Copy link
Member Author

cc @liggitt to check CSINode probe. Is here a better way how to check TLS bootstrap is finished and kubelet is ready to start for real?

@@ -914,3 +919,30 @@ func highestSupportedVersion(versions []string) (*utilversion.Version, error) {
}
return highestSupportedVersion, nil
}

// waitForAPIServerForever waits forever to get the APIServer Version as a proxy
Copy link
Contributor

Choose a reason for hiding this comment

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

Please modify this comment to be consistent with the node retrieval on line 934

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

// https://kubernetes.io/docs/reference/command-line-tools-reference/kubelet-tls-bootstrapping/
// Using a dummy node name, IsNotFound error is expected. IsForbidden or timeout are bad.
_, lastErr = client.StorageV1().CSINodes().Get(context.TODO(), nonExistingNodeName, meta.GetOptions{})
if lastErr == nil || apierrors.IsNotFound(lastErr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

lastErr shouldn't be nil if the node is non-existent :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

you never know :-)

Copy link
Member Author

@jsafrane jsafrane Mar 27, 2020

Choose a reason for hiding this comment

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

One could crash break whole cluster by creating a node with nonExistingNodeName.

Copy link
Contributor

Choose a reason for hiding this comment

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

Since the node may exist, we can give it name such as possiblyExistingNodeName

@jsafrane
Copy link
Member Author

Trick with getting CSINode does not work:

Failed to contact API server when waiting for CSINode publishing: csinodes.storage.k8s.io "nonExistingNodeName" is forbidden: User "system:node:e2e-29112e7941-674b9-minion-group-1djj" cannot get resource "csinodes" in API group "storage.k8s.io" at the cluster scope: can only access CSINode with the same name as the requesting node

@tedyu
Copy link
Contributor

tedyu commented Mar 28, 2020

With the following change to csi_plugin (nonExistingNodeName is no longer used), test suites pass:

		err := waitForAPIServerForever(kubeClient, host.GetHostName())
...
func waitForAPIServerForever(client clientset.Interface, host string) error {
...
		_, lastErr = client.StorageV1().CSINodes().Get(context.TODO(), host, meta.GetOptions{})

@jsafrane
Copy link
Member Author

Updated to get CSINode of the current node.

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Mar 30, 2020

@jsafrane: The following test failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
pull-kubernetes-e2e-kind-ipv6 8bdbd4d link /test pull-kubernetes-e2e-kind-ipv6

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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. I understand the commands that are listed here.

@tedyu
Copy link
Contributor

tedyu commented Mar 30, 2020

/lgtm

@jsafrane
Copy link
Member Author

jsafrane commented Apr 3, 2020

Edited the release note a bit to emphasize kubelet panic.

k8s-ci-robot added a commit that referenced this pull request Apr 17, 2020
…89-upstream-release-1.17

Automated cherry pick of #89589: Wait for APIServer 'ok' forever during CSINode
k8s-ci-robot added a commit that referenced this pull request Apr 17, 2020
…89-upstream-release-1.18

Automated cherry pick of #89589: Wait for APIServer 'ok' forever during CSINode
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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSINodeInfo registration timeout can kill kubelet before API server is available
4 participants