-
Notifications
You must be signed in to change notification settings - Fork 808
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
Apply extra volume tags to EBS snapshots #568
Conversation
Welcome @chrishenzie! |
Hi @chrishenzie. 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. |
Pull Request Test Coverage Report for Build 1261
💛 - Coveralls |
/ok-to-test |
e8374c1
to
e6ad3b1
Compare
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.
generally lgtm
/assign @bertinatto @wongma7
especially regarding reusing the "extra-volume-tags" arg.
pkg/driver/controller.go
Outdated
@@ -440,6 +440,9 @@ func (d *controllerService) CreateSnapshot(ctx context.Context, req *csi.CreateS | |||
opts := &cloud.SnapshotOptions{ | |||
Tags: map[string]string{cloud.SnapshotNameTagKey: snapshotName}, | |||
} | |||
for k, v := range d.driverOptions.extraVolumeTags { |
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.
Do you also want to add cluster id tag, similar to how it's done for CreateVolume?
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.
Added this and an additional unit test to cover this case.
e6ad3b1
to
57b6725
Compare
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.
Overal LGTM, just 2 nits.
I'd like to propose we mark the extra-volume-tags
option as Deprecated
and make it an alias to a new option with a more representative name. Later on we can remove extra-volume-tags
and keep only the new one.
pkg/cloud/cloud.go
Outdated
// Enforce ordering for unit tests. | ||
sort.SliceStable(tags, func(i, j int) bool { | ||
return *tags[i].Key < *tags[j].Key | ||
}) |
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.
Is this sorting really necessary? If so, can we potentially move it to the test function?
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.
Removed in favor of a custom matcher for this AWS input type. Let me know if this is what you were thinking.
@bertinatto One concern I have with this general Suppose customers want different tags for snapshots than they do volumes. With this solution, they will need to combine their tags for snapshots and volumes into one string, which could potentially exceed the limit of the max # of tags. Since this driver only provisions either EBS volumes or snapshots, it seems like another alternative would be to introduce |
cmd/options/controller_options.go
Outdated
// ID of the kubernetes cluster. This is used only to create the same tags on volumes that | ||
// in-tree volume volume plugin does. | ||
KubernetesClusterID string | ||
} | ||
|
||
func (s *ControllerOptions) AddFlags(fs *flag.FlagSet) { | ||
fs.Var(cliflag.NewMapStringString(&s.ExtraVolumeTags), "extra-volume-tags", "Extra volume tags to attach to each dynamically provisioned volume. It is a comma separated list of key value pairs like '<key1>=<value1>,<key2>=<value2>'") | ||
fs.Var(cliflag.NewMapStringString(&s.ExtraTags), "extra-tags", "Extra tags to attach to each dynamically provisioned resource. It is a comma separated list of key value pairs like '<key1>=<value1>,<key2>=<value2>'") | ||
fs.Var(cliflag.NewMapStringString(&s.ExtraTags), "extra-volume-tags", "DEPRECATED: Please use --extra-tags instead. Extra volume tags to attach to each dynamically provisioned volume. It is a comma separated list of key value pairs like '<key1>=<value1>,<key2>=<value2>'") |
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.
If both flags are set, is it possible that the deprecated one will overwrite the other? Is there a way we can give extra-tags
priority?
Perhaps we can:
- Keep
ExtraVolumeTags
above - Keep the
driver.WithExtraVolumeTags
line incmd/main.go
- Keep the
WithExtraVolumeTags
indriver.go
and change it to only seto.extraTags
if it hasn't been set yet.
Does that makes sense?
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.
The other changes LGTM.
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.
Yeah that makes sense. Let me know if this captures it.
Sorry, I missed this comment. That's a valid point, but I'm not sure if we need this flexibility at the moment (I don't have any use cases in mind). To me it feels like using a single flag is OK at this point, but we can always split it if we come across a strong use case. |
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.
Just 2 nits regarding the deprecated flag. Other than that, I think we can merge this!
I'm not sure how many people out there is using this flag, so IMO it's worth to be very "loud" about it 👍
7a33d85
to
cfda969
Compare
@bertinatto I've squashed these into one commit. See here for the deprecation comment:
And here for the warning: aws-ebs-csi-driver/pkg/driver/driver.go Lines 161 to 164 in cfda969
I added an extra check for |
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.
Thank you for working on this @chrishenzie!
/lgtm
func WithExtraVolumeTags(extraVolumeTags map[string]string) func(*DriverOptions) { | ||
return func(o *DriverOptions) { | ||
o.extraVolumeTags = extraVolumeTags | ||
if o.extraTags == nil && extraVolumeTags != nil { |
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.
Ideally we'd have 2 checks: 1 for printing the warning if extraVolumeTags != nil
and the other to overwrite o.extraTags
. But I think this is fine for now.
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bertinatto, chrishenzie 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 |
/retest |
1 similar comment
/retest |
/test pull-aws-ebs-csi-driver-e2e-single-az |
/test pull-aws-ebs-csi-driver-e2e-single-az Failures seem unrelated to this change. |
/test pull-aws-ebs-csi-driver-e2e-single-az |
5 similar comments
/test pull-aws-ebs-csi-driver-e2e-single-az |
/test pull-aws-ebs-csi-driver-e2e-single-az |
/test pull-aws-ebs-csi-driver-e2e-single-az |
/test pull-aws-ebs-csi-driver-e2e-single-az |
/test pull-aws-ebs-csi-driver-e2e-single-az |
/retest [1] https://testgrid.k8s.io/sig-aws-ebs-csi-driver#e2e-test-single-az |
/retest |
cfda969
to
7c17cb5
Compare
Ran |
/retest |
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.
/lgtm
Is this a bug fix or adding new feature?
Adding a new feature, see #566
What is this PR about? / Why do we need it?
This PR takes the
--extra-volume-tags
that are applied to provisioned EBS volumes inCreateVolume()
, and also adds them provisioned snapshots viaCreateSnapshot()
.What testing is done?
snapshotOptions
received bycloud.CreateSnapshot()
includes the suppliedextraVolumeTags
snapshotOptions
received bycloud.CreateSnapshot()
includes the cluster ID if that driver option is enabled (See PR feedback)