cluster-api-provider-gcp icon indicating copy to clipboard operation
cluster-api-provider-gcp copied to clipboard

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

Open bfournie opened this issue 1 year ago • 0 comments
trafficstars

/kind bug

What steps did you take and what happened: In https://github.com/kubernetes-sigs/cluster-api-provider-gcp/pull/1275, the ForwardingRules Labels field was set in the resource definition. It turns out that some resources, including ForwardingRules, require theSetLabels() method to add the labels. 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"

This is different than other resources, for example Instances and Disks, in which the Label can be set in the resource and later modified using SetLabels(). This is the description in compute-gen.go

        // Labels: Labels to apply to this instance. These can be later modified
        // by the setLabels method.
        Labels map[string]string `json:"labels,omitempty"`

What did you expect to happen: So, the end result is that the change to add Labels to the resources when creating it works fine for Disks but does not work for ForwardingRules which require SetLabels() to be used after the resource is create.

Anything else you would like to add: Will need to change ForwardingRules to use SetLabels() .

Environment: Openshift 4.16 using cluster-api-provider-gcp as provider.

bfournie avatar Jun 28 '24 17:06 bfournie