Skip to content

Support to add ResoureManagerTags to GCP Compute Disk, Image, Snapshot#1377

Merged
k8s-ci-robot merged 1 commit into
kubernetes-sigs:masterfrom
arkadeepsen:resource-manager-tags
Apr 25, 2024
Merged

Support to add ResoureManagerTags to GCP Compute Disk, Image, Snapshot#1377
k8s-ci-robot merged 1 commit into
kubernetes-sigs:masterfrom
arkadeepsen:resource-manager-tags

Conversation

@arkadeepsen
Copy link
Copy Markdown
Contributor

What type of PR is this?

Uncomment only one /kind <> line, hit enter to put that in a new line, and remove leading whitespaces from that line:

/kind api-change
/kind bug
/kind cleanup
/kind design
/kind documentation
/kind failing-test

/kind feature

/kind flake

What this PR does / why we need it:

This PR allows users to bind a list of tags to resources created by the driver, namely GCP Compute Disk, Image, Snapshot. The original issue #1319 provides more details on the usefulness of GCP tags.

Which issue(s) this PR fixes:

Fixes #1319

Special notes for your reviewer:

This PR adds the functionality to bind GCP resource manager tags to compute pd resources created by the driver. The tag keys and values will be created by the user and only the tag bindings to the pd resources will be created by the driver. The driver now accepts a new argument, --extra-tags, and a list of tags can be provided to the driver using this argument. The tag list is then validated to check if they are in the expected format or not. The list is also validated to check that a tag parent_id and key combination is not used more that once. The tags are attached to the Compute Disk, Image, Snapshot when the corresponding resources are created.

Does this PR introduce a user-facing change?:
Yes

Users can now attach existing tags to GCP Compute Disk, Image, Snapshot resources created by the driver. The driver now accepts a new argument, `--extra-tags`, and a list of tags can be provided to the driver using this argument. The argument is optional, and if the tags are not provided, then there is no change in the existing behavior.

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

linux-foundation-easycla Bot commented Sep 22, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: arkadeepsen / name: Arkadeep Sen (e703794)

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Welcome @arkadeepsen!

It looks like this is your first PR to kubernetes-sigs/gcp-compute-persistent-disk-csi-driver 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/gcp-compute-persistent-disk-csi-driver has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 22, 2023
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @arkadeepsen. 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.

Details

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 size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Sep 22, 2023
@arkadeepsen arkadeepsen changed the title Support to add ResoureManagerTags to GCP Compute Disk, Image, Snapsho… Support to add ResoureManagerTags to GCP Compute Disk, Image, Snapshot Oct 4, 2023
@arkadeepsen arkadeepsen force-pushed the resource-manager-tags branch from c272900 to 5fe0523 Compare October 4, 2023 13:03
@arkadeepsen arkadeepsen force-pushed the resource-manager-tags branch 2 times, most recently from 1f7ccfb to 6400a6d Compare October 19, 2023 16:39
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 20, 2023
@arkadeepsen arkadeepsen force-pushed the resource-manager-tags branch 3 times, most recently from 4726b09 to 3b7aeaf Compare October 24, 2023 04:32
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Oct 28, 2023
@arkadeepsen arkadeepsen force-pushed the resource-manager-tags branch from 3b7aeaf to d4a2788 Compare November 15, 2023 13:49
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 15, 2023
@arkadeepsen arkadeepsen force-pushed the resource-manager-tags branch from d4a2788 to 7847650 Compare November 15, 2023 15:00
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 22, 2023
@arkadeepsen arkadeepsen force-pushed the resource-manager-tags branch from 7847650 to 9a385e4 Compare November 22, 2023 17:52
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 22, 2023
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 6, 2023
@arkadeepsen arkadeepsen force-pushed the resource-manager-tags branch from 9a385e4 to e93b90c Compare December 7, 2023 06:39
@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 8, 2024
@bharath-b-rh
Copy link
Copy Markdown

/test pull-gcp-compute-persistent-disk-csi-driver-kubernetes-integration

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 17, 2024
@arkadeepsen arkadeepsen force-pushed the resource-manager-tags branch from 3106059 to 3d7bd8f Compare February 20, 2024 07:14
@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Feb 20, 2024
@arkadeepsen arkadeepsen force-pushed the resource-manager-tags branch from 3d7bd8f to 78ccaa8 Compare February 21, 2024 07:28
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 21, 2024
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 5, 2024
Comment thread cmd/gce-pd-csi-driver/main.go Outdated
computeEndpoint *url.URL
allowedComputeEnvironment = []gce.Environment{gce.EnvironmentStaging, gce.EnvironmentProduction}

extraTagsStr = flag.String("extra-tags", "", "Extra tags to attach to each Compute Disk, Image, Snapshot created. It is a comma separated list of parent id, key and value like '<parent_id1>/<tag_key1>/<tag_value1>,...,<parent_idN>/<tag_keyN>/<tag_valueN>'. parent_id is the Organization or the Project ID where the tag key and the tag value resources exist. A maximum of 50 tags bindings is allowed for a resource. See https://cloud.google.com/resource-manager/docs/tags/tags-overview, https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing for details")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

From the documentation, it seems like <parent_id> can also support project number (alongisde organization and project ID). Are these tags in namespacedName format?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Right, tags are expected to be in NamespacedName format.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have added project name as well in the description.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great, thanks.

Comment thread pkg/common/utils.go Outdated
Comment thread pkg/common/utils.go
Comment on lines +334 to +342
const maxNumberOfTags = 50
if len(tagsMap) > maxNumberOfTags {
return nil, fmt.Errorf("more than %d tags is not allowed, given: %d", maxNumberOfTags, len(tagsMap))
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please add a comment linking to the documentation about the limit of 50

@arkadeepsen
Copy link
Copy Markdown
Contributor Author

/retest-required

Comment thread pkg/common/parameters.go
Comment thread pkg/common/parameters.go Outdated
case ParameterKeyResourceTags:
paramResourceTags, err := ConvertTagsStringToMap(v)
if err != nil {
return p, fmt.Errorf("parameters contain invalid tags parameter: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you specify the exact name of the parameter key in this error? This will make it easier for the user to address the error (by knowing exactly which parameter key to modify).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pwschuurman I have added the full string containing the parent ID, tag key and value in the error message returned by ConvertTagsStringToMap().

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm looking for the actual key that the user would be familiar with (eg: ParameterKeyResourceTags) to be present in the output error message. This will allow the user to know what parameter to correct in their gRPC call. The end user will likely be a Kubernetes user, and this parameter should map to a parameter key they are familiar with, so they can update the corresponding parameter on their StorageClass. Without that context, they'll just be left with the value, and it won't be as clear about what parameter to change to fix the error they're seeing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Got it. Added the name of the parameter key in the error message.

Comment thread pkg/common/utils.go
Comment on lines +334 to +342
const maxNumberOfTags = 50
if len(tagsMap) > maxNumberOfTags {
return nil, fmt.Errorf("more than %d tags is not allowed, given: %d", maxNumberOfTags, len(tagsMap))
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks

Comment thread pkg/common/utils_test.go Outdated
Comment thread pkg/gce-cloud-provider/compute/gce-compute.go
Comment thread cmd/gce-pd-csi-driver/main.go Outdated
computeEndpoint *url.URL
allowedComputeEnvironment = []gce.Environment{gce.EnvironmentStaging, gce.EnvironmentProduction}

extraTagsStr = flag.String("extra-tags", "", "Extra tags to attach to each Compute Disk, Image, Snapshot created. It is a comma separated list of parent id, key and value like '<parent_id1>/<tag_key1>/<tag_value1>,...,<parent_idN>/<tag_keyN>/<tag_valueN>'. parent_id is the Organization or the Project ID where the tag key and the tag value resources exist. A maximum of 50 tags bindings is allowed for a resource. See https://cloud.google.com/resource-manager/docs/tags/tags-overview, https://cloud.google.com/resource-manager/docs/tags/tags-creating-and-managing for details")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Great, thanks.

Comment thread README.md Outdated
Comment thread pkg/common/utils.go Outdated
Comment on lines +1483 to +1522
// GCP has a rate limit of 600 requests per minute, restricting
// here to 8 requests per second.
limiter := common.NewLimiter(gcpTagsRequestRateLimit, gcpTagsRequestTokenBucketSize, true)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think one optimization would be to use a shared rate limiter, scoped to a CloudProvider client. This would allow each PDCSI controller instance to rate limit calls across CreateSnapshot/CreateVolume.

The 90 second initial delay seems a bit long. I think in the worst case you'd only need to wait for a maximum of 60 seconds until the per-minute quota is refilled (per the documentation: https://cloud.google.com/compute/api-quota#api-rate-limits).

Also, I don't think having an exponential backoff is that useful here (especially at a rate of 2.0), since the per-minute quota is a fixed window rate limit. You'll either be competing with another client, and exhaust quota before the next minute, or quota will refill and the bucket will be replenished. The only thing you may want to adjust is a negotiation scheme for the per-second bucket rate, but without direct knowledge of the request rate of any other client, this seems complicated to determine.

@arkadeepsen
Copy link
Copy Markdown
Contributor Author

/retest-required

1 similar comment
@arkadeepsen
Copy link
Copy Markdown
Contributor Author

/retest-required

Comment thread pkg/common/parameters.go Outdated
Comment thread pkg/common/parameters.go Outdated
case ParameterKeyResourceTags:
paramResourceTags, err := ConvertTagsStringToMap(v)
if err != nil {
return p, fmt.Errorf("parameters contain invalid tags parameter: %w", err)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm looking for the actual key that the user would be familiar with (eg: ParameterKeyResourceTags) to be present in the output error message. This will allow the user to know what parameter to correct in their gRPC call. The end user will likely be a Kubernetes user, and this parameter should map to a parameter key they are familiar with, so they can update the corresponding parameter on their StorageClass. Without that context, they'll just be left with the value, and it won't be as clear about what parameter to change to fix the error they're seeing.

@arkadeepsen
Copy link
Copy Markdown
Contributor Author

/retest-required

1 similar comment
@arkadeepsen
Copy link
Copy Markdown
Contributor Author

/retest-required

Comment thread pkg/common/utils_test.go Outdated
Comment thread pkg/gce-cloud-provider/compute/gce-compute.go Outdated
@arkadeepsen
Copy link
Copy Markdown
Contributor Author

/retest-required

1 similar comment
@arkadeepsen
Copy link
Copy Markdown
Contributor Author

/retest-required

@pwschuurman
Copy link
Copy Markdown
Contributor

/lgtm
/approve

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: arkadeepsen, pwschuurman

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details 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

@bharath-b-rh
Copy link
Copy Markdown

/cherry-pick release-1.6

@k8s-infra-cherrypick-robot
Copy link
Copy Markdown

@bharath-b-rh: only kubernetes-sigs org members may request cherry picks. If you are already part of the org, make sure to change your membership to public. Otherwise you can still do the cherry-pick manually.

Details

In response to this:

/cherry-pick release-1.6

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.

@bharath-b-rh
Copy link
Copy Markdown

@pwschuurman Could you please help me with cherry picking this change to release-1.6. Thank you!

@mattcary
Copy link
Copy Markdown
Contributor

/cherry-pick release-1.14

@k8s-infra-cherrypick-robot
Copy link
Copy Markdown

@mattcary: Failed to get PR patch from GitHub. This PR will need to be manually cherrypicked.

Error messagestatus code 406 not one of [200], body: {"message":"Sorry, the diff exceeded the maximum number of lines (20000)","errors":[{"resource":"PullRequest","field":"diff","code":"too_large"}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#get-a-pull-request","status":"406"}
Details

In response to this:

/cherry-pick release-1.14

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.

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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support to add ResoureManagerTags to GCP Compute Disk, Image, Snapshot resources

7 participants