-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: service account-related BulkInsert error not surfaced to user #7876
Comments
It looks like Compute Engine uses its own Operations client, not the [1] google-cloud-go/longrunning/longrunning.go Line 106 in bd90ad9
[2]
|
@ijrsvt you're right, but we can't use your suggestion directly. I've filed googleapis/gapic-generator-go#1320 to fix this in our client generator. We can't use @hanming-lu in the mean time, you can do something similar to what @ijrsvt suggests and check the error via |
Thanks for the quick follow up @noahdietz, could you elaborate on what you mean by non-standard? Are there other APIs that have this property? |
Well, you nailed it when you pointed out So, this was just a mistake on our part while implementing generator support. We left out this admittedly crucial piece. |
@noahdietz, can you comment on the difference between Code:
Produces:
|
@ijrsvt I don't work on the Compute API, but I'm not surprised that this is the case. I already documented that potential issue in the issue I filed on the generator - the first step is returning an error in the first place, the second is figuring out how to give the most descriptive error possible (or at least make that information readily available). Fundamentally, the Compute |
I just hit this today while trying to delete a network that still had a subnetwork in it, and the error was undetected. I've noticed that the workaround of checking the http status doesn't work if the operation succeeded (at least in the network deletion case) because that field is not present in the result. So you have to check if it's there at all, and then check it against Here's my temporary workaround: // ComputeOperationError is a wrapper around a compute.Operation that has
// errored out.
//
// TODO (https://github.com/googleapis/google-cloud-go/issues/7876): Remove once this is fixed.
type ComputeOperationError struct {
Op *computepb.Operation
}
func (e *ComputeOperationError) Error() string {
if e.Op.GetStatus() != computepb.Operation_DONE {
return fmt.Sprintf("operation %q is not done", e.Op.GetName())
}
if len(e.Op.GetError().GetErrors()) > 0 && len(e.Op.GetError().GetErrors()[0].GetMessage()) > 0 {
return e.Op.GetError().Errors[0].GetMessage()
}
return e.Op.GetHttpErrorMessage()
}
// ErrorFromComputeOperation returns an error if the compute.Operation has
// errored out. Otherwise, it returns nil.
func ErrorFromComputeOperation(op *compute.Operation) error {
if op.Proto().HttpErrorStatusCode != nil && op.Proto().GetHttpErrorStatusCode() != http.StatusOK {
return &ComputeOperationError{op.Proto()}
}
return nil
} |
Thanks @krousey you're right, my mistake, I spend so much time in gRPC where Status OK is |
Is there a gRPC version of the compute API? |
Nope, but we support all of Cloud in this repo and the vast majority support gRPC or HTTP-JSON. Compute does not, I just wasn't thinking straight. |
Update: we have fixed the generator to do the following:
Note: We are working on figuring out how to unpack the error detail info in the We hope to have the Compute code regenerated soon and a release following that. |
@noahdietz thank you for the update! May I ask if there is an estimate (i.e. days or weeks or months) on when a release with the fix will happen? |
I'm hoping we can get it in this week's release, but if not this week then definitely next. |
Ok so we have the initial changes merged into google-cloud-go/compute/apiv1/operations.go Lines 192 to 199 in 151908a
We want to get a test case into our integration tests, and waiting on finding a good error mode to reliably test with. I'm hoping we can release this code next week. Feel free to try it yourself though if you want to wire up the unreleased dependency. |
Ok so the above change was released in I'd appreciate some verification from folks on this thread that the behavior you expect is fulfilled. |
Thank you for the update! Will take a look later this week. |
Confirming an error is returned, and it looks like below, thank you!
|
Fantastic! |
Client
compute "cloud.google.com/go/compute/apiv1"
computepb "cloud.google.com/go/compute/apiv1/computepb"
instanceClient := compute.NewInstancesRESTClient(context.TODO())
instanceClient.BulkInsert()
Go Environment
$ go version
go version go1.20.3 linux/amd64
$ go env
Not relevant
Code
e.g.
Expected behavior
err1 != nil
orerr2 != nil
Actual behavior
err1 == nil
anderr2 == nil
The text was updated successfully, but these errors were encountered: