Skip to content

Conversation

@bfournie
Copy link
Contributor

What type of PR is this?
/kind bug

What this PR does / why we need it:

The ForwardingRules resource requires that the SetLabels() method be used to add the labels after the resource has been created. This resource is different than, for example, Instances or Disks. See Issue #1276 for more information.

Which issue(s) this PR fixes
Fixes #1276

Special notes for your reviewer:

This is the comment for ForwardingRules in https://github.com/googleapis/google-api-go-client/blame/main/compute/v1/compute-gen.go

       // Labels: Labels for this resource. These can only be added or modified
       // by the setLabels method. 
        Labels map[string]string `json:"labels,omitempty"

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

"NONE"

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. kind/bug Categorizes issue or PR as related to a bug. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 28, 2024
@k8s-ci-robot
Copy link
Contributor

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

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.

@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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jun 28, 2024
@netlify
Copy link

netlify bot commented Jun 28, 2024

Deploy Preview for kubernetes-sigs-cluster-api-gcp ready!

Name Link
🔨 Latest commit e9eda6e
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-gcp/deploys/6696dec96d45d2000883b03e
😎 Deploy Preview https://deploy-preview-1277--kubernetes-sigs-cluster-api-gcp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@k8s-ci-robot k8s-ci-robot requested review from dims and richardcase June 28, 2024 19:52
Copy link
Member

@cpanato cpanato left a comment

Choose a reason for hiding this comment

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

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jun 29, 2024
@bfournie bfournie force-pushed the fwdrule-setlabels branch from ea8befc to 31b640b Compare June 29, 2024 14:19
Comment on lines 590 to 591
err = s.forwardingrules.SetLabels(ctx, key, setLabelsRequest)
if err != nil {
return nil, err
}
Copy link
Member

Choose a reason for hiding this comment

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

How about

Suggested change
err = s.forwardingrules.SetLabels(ctx, key, setLabelsRequest)
if err != nil {
return nil, err
}
if err := s.forwardingrules.SetLabels(ctx, key, setLabelsRequest); err != nil {
return nil, err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed.


// Labels on ForwardingRules must be added after resource is created
labels := s.scope.AdditionalLabels()
if !reflect.DeepEqual(labels, forwarding.Labels) {
Copy link
Member

Choose a reason for hiding this comment

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

Just to confirm, this is a map right? So ordering should not be an issue while diffing correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes it is a map. There's actually a predefined function https://github.com/kubernetes-sigs/cluster-api-provider-gcp/blob/main/api/v1beta1/labels.go#L29-L31 that I changed to use.

err = s.regionalforwardingrules.SetLabels(ctx, key, setLabelsRequest)
if err != nil {
return nil, err
}
Copy link
Member

Choose a reason for hiding this comment

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

Same here :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

The ForwardingRules resource requires that the SetLabels() method
be used to add the labels after the resource has been created.
@bfournie bfournie force-pushed the fwdrule-setlabels branch from 31b640b to e9eda6e Compare July 16, 2024 20:57
Copy link
Member

@damdo damdo left a comment

Choose a reason for hiding this comment

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

/lgtm

/assign @cpanato

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jul 17, 2024
@richardcase
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: bfournie, richardcase

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 17, 2024
@k8s-ci-robot k8s-ci-robot merged commit dace270 into kubernetes-sigs:main Jul 17, 2024
@k8s-ci-robot k8s-ci-robot added this to the v1.1.0 milestone Jul 17, 2024
@bfournie bfournie deleted the fwdrule-setlabels branch July 17, 2024 11:07
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/bug Categorizes issue or PR as related to a bug. 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-none Denotes a PR that doesn't merit a release note. 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.

ForwardingRules' labels must be added via the SetLabels() method

5 participants