Skip to content
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

compute: unable to resize instance group to 0 #5174

Closed
matihost opened this issue Nov 26, 2021 · 4 comments
Closed

compute: unable to resize instance group to 0 #5174

matihost opened this issue Nov 26, 2021 · 4 comments
Assignees
Labels
api: compute Issues related to the Compute Engine API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@matihost
Copy link

https://github.com/googleapis/google-cloud-go/blob/main/compute/apiv1/instance_group_managers_client.go#L1301

When size is 0, the size parameter is not added to HTTP param - and server returns 400 bad request - leading to unability to resize intance group to 0.

The gcloud cli works:

gcloud compute instance-groups managed resize NAME  --zone=ZONE --size=0
@matihost matihost added the triage me I really want to be triaged. label Nov 26, 2021
@matihost matihost changed the title unable to resize instance group to 0 compute: unable to resize instance group to 0 Nov 26, 2021
@product-auto-label product-auto-label bot added the api: compute Issues related to the Compute Engine API. label Nov 27, 2021
@codyoss codyoss added status: investigating The issue is under investigation, which is determined to be non-trivial. and removed triage me I really want to be triaged. labels Nov 29, 2021
@codyoss codyoss self-assigned this Nov 29, 2021
@codyoss
Copy link
Member

codyoss commented Nov 29, 2021

cc @noahdietz WDYT? A bug perhaps?

@codyoss codyoss assigned noahdietz and unassigned codyoss Nov 29, 2021
@noahdietz
Copy link
Contributor

Yep, this is a bug. There are only 3 int32 fields in compute that are marked as REQUIRED (and thus not optional->*int32), and I believe the intention of this code was to prevent sending unset fields (default empty) in the request. In the event that a number field is REQUIRED, 0 is a valid value and we must send it.

This does potentially open up users to some confusing errors/scenarios if they don't set the field (because there isn't a good way to enforce required fields in Go unless they are pointers) and the default empty 0 is sent.

We probably want to include some extra documentation to the method to ensure it is explicitly set by the user. I will open an issue on the generator to fix this and we can close this one when it is regenerated. Extra documentation might come in a separate issue/PR as that might benefit non-diregapic clients as well.

@codyoss codyoss added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. and removed status: investigating The issue is under investigation, which is determined to be non-trivial. labels Nov 30, 2021
@noahdietz
Copy link
Contributor

Opened googleapis/gapic-generator-go#819 to track the bug fix.

codyoss pushed a commit that referenced this issue Dec 3, 2021
In REST clients, singular, primitive required fields will be added to query params regardless of if they are default empty value or not.

This is the fix for #5174 which will come in the next regen.
@noahdietz
Copy link
Contributor

https://pkg.go.dev/cloud.google.com/[email protected] should have the fix

params := url.Values{}
if req != nil && req.RequestId != nil {
params.Add("requestId", fmt.Sprintf("%v", req.GetRequestId()))
}
params.Add("size", fmt.Sprintf("%v", req.GetSize()))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: compute Issues related to the Compute Engine API. priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

3 participants