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

Add node check to vSphere cloud provider #117243

Merged
merged 1 commit into from May 4, 2023

Conversation

jsafrane
Copy link
Member

What type of PR is this?

/kind bug

What this PR does / why we need it:

At KCM startup, vSphere cloud provider builds a cache from NodeAdded() events from an informer. But these events are asynchronous, the cloud provider may need information from the cache earlier, for example when detaching a volume from a node at KCM startup. If a node is missing in the cache, the cloud provider treats such a detach as successful, which is wrong. Such a volume will be attached to the node forever.

To prevent this issue:

  1. Try nodeLister from the informer before declaring a node as not found. A/D controller starts after its node informer has been synced.

  2. Read API server before declaring a node as not found. To be 100% sure a node has been really deleted and the informer does not have stale data.

Which issue(s) this PR fixes:

Fixes #117091

Special notes for your reviewer:

Since vSphere CSI migration is GA, the vSphere cloud provider is used only to detach volumes from 1.25 and older nodes (unless the migration is disabled).

I've tested this with hacked errors in the cloud provider to fail Detach requests + restarted KCM - with this PR, I can see in logs:

Node jsafrane-8pmvh-worker-xlb2s found in vSphere cloud provider node informer

Which means the node is not in NodeManager's cache and the old cloud provider would treat all volumes used by this node as detached. With this PR, the cloud provider actually detaches volumes from the node.

Does this PR introduce a user-facing change?

Fixed vSphere cloud provider not to skip detach volumes from nodes at kube-controller-startup.

Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. labels Apr 12, 2023
@k8s-ci-robot
Copy link
Contributor

This issue is currently awaiting triage.

If a SIG or subproject determines this is a relevant issue, they will accept it by applying the triage/accepted label and provide further guidance.

The triage/accepted label can be added by org members by writing /triage accepted in a comment.

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-priority Indicates a PR lacks a `priority/foo` label and requires one. label Apr 12, 2023
@jsafrane
Copy link
Member Author

/assign @gnufied @divyenpatel

@k8s-ci-robot k8s-ci-robot added area/cloudprovider sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. and removed do-not-merge/needs-sig Indicates an issue or PR lacks a `sig/foo` label and requires one. labels Apr 12, 2023
@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 Apr 12, 2023
@divyenpatel
Copy link
Member

@lubronzhan Can you help review this PR?

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 13, 2023
At KCM startup, vSphere cloud provider builds a cache from NodeAdded events
from an informer. But these events are asynchronous, the cloud provider may
need information from the cache earlier, for example when detaching a
volume from a node at KCM startup. If a node is missing in the cache,
the cloud provider treats such a detach as successful, which is wrong.
Such a volume will be attached to the node forever.

To prevent this issue:

1. Try nodeLister before declaring a node as not found.
A/D controller starts after its node informer has been synced.

2. Read API server before declaring a node as not found.
Just in case the informer has stale data.
@gnufied
Copy link
Member

gnufied commented Apr 14, 2023

/lgtm

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

LGTM label has been added.

Git tree hash: f44ce987190d7c201b6638febfac85e189f8a8fa

@jsafrane
Copy link
Member Author

/assign @cheftako @andrewsykim
For approval. This is a bug in the in-tree vSphere provider that can get upgrade to out-of-tree CSI driver stuck when KCM is restarted at a wrong time. I plan to backport it to older releases too.

@jsafrane
Copy link
Member Author

jsafrane commented May 3, 2023

/assign @nckturner
for approval

@nckturner
Copy link
Contributor

/approve bug fix

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jsafrane, nckturner

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 May 4, 2023
@k8s-ci-robot k8s-ci-robot merged commit 8aa49a7 into kubernetes:master May 4, 2023
11 of 12 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.28 milestone May 4, 2023
k8s-ci-robot added a commit that referenced this pull request Jul 6, 2023
…7243-upstream-release-1.27

Automated cherry pick of #117243: Add node check to vSphere cloud provider
k8s-ci-robot added a commit that referenced this pull request Jul 6, 2023
…7243-upstream-release-1.26

Automated cherry pick of #117243: Add node check to vSphere cloud provider
k8s-ci-robot added a commit that referenced this pull request Jul 6, 2023
…7243-upstream-release-1.25

Automated cherry pick of #117243: Add node check to vSphere cloud provider
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/cloudprovider 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. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. 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/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In-tree vSphere volumes are not detached after KCM restart
7 participants