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

disk: wait to serialize attach & detach #930

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

huww98
Copy link
Contributor

@huww98 huww98 commented Dec 19, 2023

What type of PR is this?

/kind feature

What this PR does / why we need it:

Avoid backoff caused by InvalidOperation.Conflict thus speed up attaching.
Prioritize detach over attach to avoid InstanceDiskLimitExceeded error with best effort
set DISK_SERIAL_ATTACH env to opt-in this behaviour in controller

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

This is necessary to pass the external-storage test in k/k repository. Or we will almost certainly get timeout for volume not attached in 5 minutes.

Does this PR introduce a user-facing change?

Attach/detach multiple volumes to one node at the same time is optimized to have higher throughput, and less conflict error.

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


@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 19, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @huww98. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 19, 2023
select {
case s.detachSlot <- struct{}{}:
return nil
case s.normalSlot <- struct{}{}:
Copy link
Contributor

Choose a reason for hiding this comment

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

The test cases should meet the following scenarios on the same node

  1. Delete the application pod after restarting the controller pod, triggering an uninstallation.
  2. After restarting controller pod, delete/create different pods at the same time, trigger mounting/unmounting at the same time.
  3. after restarting the controller pod, create three pods at the same time, two mount and one unmount, and the unmounting is completed first.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

About "restarting the controller". The invariant here is the slot buffer is filled if and only if an attach or detach is in progress. This holds naturally when the process restarted.

I've run this through the official k/k external storage e2e test, with 25 cases in parallel. It works smoothly.

}

type serialSlot struct {
detachSlot chan struct{}
Copy link
Contributor

Choose a reason for hiding this comment

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

slot & priority slot would be better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, I've updated the naming, and added some comments.

Avoid backoff caused by InvalidOperation.Conflict thus speed up attaching.
Prioritize detach over attach to avoid InstanceDiskLimitExceeded error with best effort
set DISK_SERIAL_ATTACH env to opt-in this behaviour in controller
@huww98
Copy link
Contributor Author

huww98 commented Feb 1, 2024

I replaced sync.Map with map + sync.RWMutex, which is faster and avoids unnecessary allocations.

@mowangdk
Copy link
Contributor

mowangdk commented Feb 6, 2024

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: huww98, mowangdk

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 Feb 6, 2024
@k8s-ci-robot k8s-ci-robot merged commit 4db70c2 into kubernetes-sigs:master Feb 6, 2024
7 checks passed
@huww98 huww98 deleted the serial-ad branch March 8, 2024 03:06
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/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. 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.

None yet

3 participants