-
Notifications
You must be signed in to change notification settings - Fork 829
Adding Proper Handling of VAC and Controller Tags On Volume Creation #2470
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
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 @mdzraf. 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-sigs/prow repository. |
/ok-to-test |
rawTagsToAdd := []string{} | ||
for key, value := range params { | ||
switch key { | ||
case ModificationKeyIOPS: |
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'm a bit worried at the amount code duplication we have for validating parameters that can be specified in either the SC versus mutable_parameters from VAC. Can we consolidate the logic?
Before this PR there are 2 separate functions that validate parameters shared between SC and VAC like IOPS:
- controller.go:
aws-ebs-csi-driver/pkg/driver/controller.go
Lines 147 to 152 in 6c1235d
case IopsKey: parseIopsKey, parseIopsKeyErr := strconv.ParseInt(value, 10, 32) if parseIopsKeyErr != nil { return nil, status.Errorf(codes.InvalidArgument, "Could not parse invalid iops: %v", err) } iops = int32(parseIopsKey) - controller_modify_volume.go:
aws-ebs-csi-driver/pkg/driver/controller_modify_volume.go
Lines 178 to 183 in 8814261
case ModificationKeyIOPS: iops, err := strconv.ParseInt(value, 10, 32) if err != nil { return nil, status.Errorf(codes.InvalidArgument, "Could not parse IOPS: %q", value) } options.modifyDiskOptions.IOPS = int32(iops)
This PR adds a third place we copy paste same exact code. (Which means there are three separate places to forget about when dealing with new parameters)
One possible solution for the create path would be to overwrite SC parameters with values from VAC mutable_parameters BEFORE validating them. They share the same parameter key anyway, and can be validated within the existing loop + switch statement.
This is in line with CSI Spec:
Values specified in mutable_parameters MUST take precedence over the values from parameters.
Alternatively we can refactor the switch statement + for loop into a shared validate function used in Create and Modify paths.
@@ -318,6 +315,10 @@ func (d *ControllerService) CreateVolume(ctx context.Context, req *csi.CreateVol | |||
volumeTags[k] = v | |||
} | |||
|
|||
for k, v := range modifyOptions.modifyTagsOptions.TagsToAdd { |
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 there a reason why VAC and 'extra' tags being evaluated and validated separately from SCTags? (But lines 402-409 are duplicate of 308-315?)
A smell here is that tags specified via extra-tags option would wind up in the unrelated struct modifyOptions.modifyTagOptions.TagsToAdd
.
Have you considered instead:
- Collating all validated scTags, extraTags, and vacTags into an array called
tagsToEvaluate
- Put them through
template.Evaluate
andvalidateExtraTags
- Append them to list of volumeTags that get passed in to cloud.DiskOptions
That way all tags, no matter their source, go through a clear set of steps? Bonus points if these steps are located near each other so it's easy to see how all tags are processed.
options.modifyTagsOptions.TagsToAdd = addTags | ||
return &options, 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.
General comment: Should we add a unit test that ensures all tags get evaluated for string interpolation to prevent regressions? (SCTags, VACTags, and Extra tags can be tested in the same unit test)
What type of PR is this?
kind feature
What is this PR about? / Why do we need it?
This PR adds proper handling of volumeAttributesClass tags so that the tags specified in the VAC are templated, validated, and added to the volume on volume creation. It also handles the templating and validation of any
--extra-tags
on the controller on volume creation.Resolves #2442
Resolves #2439
How was this change tested?
aws ec2 describe-volumes --volume-ids vol-<ID fo provisioned volume>
to make sure that the tags specified in the VAC were added and properly interpolated.Result of describe call
Does this PR introduce a user-facing change?