Skip to content

Add --poll-snapshot-period for periodic readiness requeue check when creating a VolumeSnapshotContent #1284

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

pwschuurman
Copy link
Contributor

What type of PR is this?
/kind feature

What this PR does / why we need it:
Today, the csi-snapshotter runs with a reconciler pattern when processing VolumeSnapshotContent resources. This follows the familiar requeue, err pattern that is followed by other controller frameworks, like controller-runtime.

  • Error Handling: When an error is encountered, VolumeSnapshotContent resources will be requeued with exponential decay. This behavior is desired, as presumably RPC calls to a CSI driver are due to congestion, and the request rate should be reduced.
  • Requeue Processing: In the case of dynamic provisioning, the creation of a VolumeSnapshotContent may require some time until a snapshot is ready in the underlying storage system. This is where the requeue field is useful, as the reconciler can periodically attempt to check the status of a snapshot.

The problem with the current requeue implementation is that it relies on the same exponential backoff rate limiter queue as the error handling scenario. This is a problem, as it can lead to non-deterministic ready times, and can lead to significantly higher effective snapshot ready latencies for snapshots that take longer to process (eg: larger snapshots).

To fix this, the requeue logic should use a constant retry period, to allow for more reliable snapshot reconciliation. This PR adds a new command line argument --poll-snapshot-period to the csi-snapshotter, with a default of 10 seconds.

Which issue(s) this PR fixes:

Fixes #1282

Special notes for your reviewer:

Does this PR introduce a user-facing change?:

Requeue VolumeSnapshotContent resources based on --poll-snapshot-period in csi-snapshotter

@k8s-ci-robot k8s-ci-robot added kind/feature Categorizes issue or PR as related to a new feature. release-note Denotes a PR that will be considered when it comes time to generate release notes. labels Mar 22, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: pwschuurman
Once this PR has been reviewed and has the lgtm label, please assign jsafrane for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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 cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Mar 22, 2025
@pwschuurman
Copy link
Contributor Author

/assign @sunnylovestiramisu

@sunnylovestiramisu
Copy link
Contributor

Question:

  1. Why is the default 10 seconds? Is any data we looked at that is supporting this value?
  2. Do you think it makes sense to separate two queues for this case? One for deterministic ready times and the other for non-deterministic ready times.

@@ -93,6 +93,7 @@ var (
metricsAddress = flag.String("metrics-address", "", "(deprecated) The TCP network address where the prometheus metrics endpoint will listen (example: `:8080`). The default is empty string, which means metrics endpoint is disabled. Only one of `--metrics-address` and `--http-endpoint` can be set.")
httpEndpoint = flag.String("http-endpoint", "", "The TCP network address where the HTTP server for diagnostics, including metrics and leader election health check, will listen (example: `:8080`). The default is empty string, which means the server is disabled. Only one of `--metrics-address` and `--http-endpoint` can be set.")
metricsPath = flag.String("metrics-path", "/metrics", "The HTTP path where prometheus metrics will be exposed. Default is `/metrics`.")
pollSnapshotPeriod = flag.Duration("poll-snapshot-period", 10*time.Second, "Poll interval to check if a snapshot is ready. Default is 10 seconds.")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you set the default to 0 so that drivers can opt-in to this new behavior?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can you set the default to 0 so that drivers can opt-in to this new behavior?

I think changing the default is a benefit for end users here, so I would prefer to set it to a reasonable poll interval. We could increase the poll interval higher, if scalability is a concern. However if we do get a 429 from the APIServer, we'll encounter an error and then leverage exponential backoff.

I can make the default 0, and then refactor the logic to fallback on the exponential backoff when pollSnapshotPeriod is not set (eg: we need to adjust when Forget() is called if we do this).

@xing-yang What would you prefer (either keeping the logic as is but modifying the pollSnapshotPeriod, or refactoring to use the exponential rate limiting poll interval as a fallback).

@pwschuurman
Copy link
Contributor Author

@sunnylovestiramisu

Why is the default 10 seconds? Is any data we looked at that is supporting this value?

Good call out. I don't have any data for setting a default. A default of a minute is may be more reasonable. This is the CSI connection timeout:

defaultCSITimeout = time.Minute

I think the CreateSnapshot RPC is unique in that it is one of the RPCs that can return OK, but may require a retry. Other RPCs (eg: CreateVolume) are pass/fail. For CSI Provisioner, it seems that we used to have the default poll interval set at 10 seconds (eg: some reference here kubernetes-csi/external-provisioner#131).

Do you think it makes sense to separate two queues for this case? One for deterministic ready times and the other for non-deterministic ready times.

So you're thinking in the event of an error, we add a PVC to an "error" processing queue (that has a ExponentialRateLimiter), and we have a "retry" processing queue? I think that is more to manage, and there is greater risk of concurrency related issues. We'd need to track resource keys across two queues, and we need to listen to resources available on both queues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

Improve csi-snapshotter VolumeSnapshotContent requeue fairness
4 participants