-
Notifications
You must be signed in to change notification settings - Fork 159
Allow users to specify "storage-locations" for snapshots. #793
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
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: TeweiLuo 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 |
Hi @TeweiLuo. 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 Once the patch is verified, the new status will be reflected by the 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. |
2e8bfee
to
2447112
Compare
2447112
to
8740db7
Compare
@@ -73,7 +73,7 @@ type GCECompute interface { | |||
ListZones(ctx context.Context, region string) ([]string, error) | |||
ListSnapshots(ctx context.Context, filter string, maxEntries int64, pageToken string) ([]*computev1.Snapshot, string, error) | |||
GetSnapshot(ctx context.Context, project, snapshotName string) (*computev1.Snapshot, error) | |||
CreateSnapshot(ctx context.Context, project string, volKey *meta.Key, snapshotName string) (*computev1.Snapshot, error) | |||
CreateSnapshot(ctx context.Context, project string, volKey *meta.Key, snapshotName string, storageLocations string) (*computev1.Snapshot, error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had a question about using an array but I checked that parameters
is a map[string]string
https://github.com/kubernetes-csi/external-snapshotter/blob/f255fe7b46bd5410370537319879d06f2bf1a156/client/apis/volumesnapshot/v1/types.go#L215, I don't know if users would do this though (NOTE the space between the comma and the other region):
parameters:
storage-locations: us-central1, us-central2
Probably need to add an e2e test too |
I'm not sure if this should be a k/k e2e test because this param is pd specific. Maybe a GKE internal test is better? |
got it, I saw a few tests in |
/okay-to-test |
/ok-to-test |
pkg/gce-pd-csi-driver/controller.go
Outdated
if req.GetParameters() != nil { | ||
parameters = req.GetParameters() | ||
} | ||
snapshot, err = gceCS.CloudProvider.CreateSnapshot(ctx, project, volKey, req.Name, parameters[common.ParameterStorageLocations]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should split, trim and validate the storage locations here (via a helper ftn of course). See for example common.ExtractAndDefaultParameters and its usages as a model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking about the same thing initially but
- It's debatable whether we should validate the regions themselves - the PD backend may change.
- If (1) is true, then there is no other validation, because every string can be treated as a comma-separated string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
discussed offline. The API takes a list of strings, so we definitely need to split on commas, so we should do that early. If we're splitting on commas, we need to trim whitespace, which means we should do a regexp validation of the location to make sure it's plausible. Things like validating the regions will be done over in the PD service anyway and not in the driver, even in the cloud provider.
8740db7
to
efae0fc
Compare
Refactored to use a generalized |
lgtm :) |
Update: while the
from this page. I'll amend the PR accordingly. |
efae0fc
to
da03764
Compare
Doc updated. |
da03764
to
60f462f
Compare
60f462f
to
31a8f87
Compare
thanks! /lgtm |
@TeweiLuo: The following test failed, say
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. |
Use a comma separated string, for example "us-central1,us-west1"
as the "snapshot-locations" field of snapshot class parameters.
See the PR for detailed examples.
What type of PR is this?
/kind feature
What this PR does / why we need it:
Allow users to set storage locations[1] for their PD snapshots by specifying them in the snapshot class. For example:
Current the default location[2] will be used for all snapshots. GKE customers may have organization policies restricting the placement of snapshots that conflicts with the default location. This features will help customers to consistently apply their policies.
This parameter is described in the API document[3] for snapshots.
Which issue(s) this PR fixes:
Fixes #791
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
[1] https://cloud.google.com/compute/docs/disks/snapshots#custom_location
[2] https://cloud.google.com/compute/docs/disks/snapshots#default_location
[3] https://cloud.google.com/compute/docs/reference/rest/v1/snapshots