Skip to content

Commit 4924efa

Browse files
authored
test(storage): do not fail on precondition failure for bucket updates (#10284)
1 parent 882fe5c commit 4924efa

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

storage/integration_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5821,6 +5821,14 @@ func (h testHelper) mustUpdateBucket(b *BucketHandle, ua BucketAttrsToUpdate, me
58215821
h.t.Helper()
58225822
attrs, err := b.If(BucketConditions{MetagenerationMatch: metageneration}).Update(context.Background(), ua)
58235823
if err != nil {
5824+
var apiErr *apierror.APIError
5825+
if ok := errors.As(err, &apiErr); ok {
5826+
// Update may already have succeeded with retry; if so, log and grab attrs.
5827+
if apiErr.HTTPCode() == http.StatusPreconditionFailed || apiErr.GRPCStatus().Code() == codes.FailedPrecondition {
5828+
log.Println("bucket update failed due to precondition; likely succeeded but retried - grabbing attrs instead")
5829+
return h.mustBucketAttrs(b)
5830+
}
5831+
}
58245832
h.t.Fatalf("BucketHandle(%q).Update: %v", b.BucketName(), err)
58255833
}
58265834
return attrs

0 commit comments

Comments
 (0)