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 explicit AttachVolume call in WaitForAttachmentState #2005

Merged
merged 1 commit into from
Apr 11, 2024

Conversation

torredil
Copy link
Member

Is this a bug fix or adding new feature?

Bug Fix

What is this PR about? / Why do we need it?

Today, the driver relies on the DescribeInstances API to determine the attachment state of a volume to an EC2 instance. The API may incorrectly report the volume as attached due to EC2's eventual consistency model, as a result the driver will skip making an expected AttachVolume API call and proceed to directly poll the attachment state of the volume.

This PR adds an explicit AttachVolume API call in the WaitForAttachmentState function when there is a mismatch between the expected attachment state and the actual attachment state reported for a volume. If the AttachVolume call fails, it is logged for debugging purposes but the overall behavior of returning an error and triggering a retry of the AttachDisk operation remains unchanged.

What testing is done?

  • make test && make verify
  • CI

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Apr 11, 2024
Copy link

Code Coverage Diff

This PR does not change the code coverage

pkg/cloud/cloud_test.go Outdated Show resolved Hide resolved
pkg/cloud/cloud.go Outdated Show resolved Hide resolved
Signed-off-by: torredil <torredil@amazon.com>
Copy link
Contributor

@ConnorJC3 ConnorJC3 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 Apr 11, 2024
@ConnorJC3
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ConnorJC3

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 Apr 11, 2024
@k8s-ci-robot k8s-ci-robot merged commit 85563fb into kubernetes-sigs:master Apr 11, 2024
19 checks passed
@stefanc18
Copy link

Hi @torredil. We're experiencing frequent attachment failures with the log "expected device to be attached but was detached". By looking on EC2, it looks like the volume is bound to the node, but the volume's state is still "Available", and the attachment status doesn't say "Attached". It looks like your change here would fix this as you're triggering a new AttachVolume API call if it gets into this mismatched state, but why still return the error, even if the API call returns no error? Maybe I'm misunderstanding the code, but it doesn't look like it will retry in this case

@torredil
Copy link
Member Author

Hey @stefanc18

An error is intentionally returned here to short-circuit the WaitForAttachmentState polling.

but it doesn't look like it will retry in this case

Once WaitForAttachmentState returns an error, it will get bubbled up the call stack and returned by ControllerPublishVolume which will cause the external attacher sidecar to redrive a request. On the next call, the polling process will proceed as expected since the attach call has already been made.

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. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants