bigtable: retry read on transient parent-table-not-ready (#25463)#80
Open
jbbqqf wants to merge 11 commits into
Open
bigtable: retry read on transient parent-table-not-ready (#25463)#80jbbqqf wants to merge 11 commits into
jbbqqf wants to merge 11 commits into
Conversation
…#25463) Adding a schema bundle right after creating its parent table can race with the table's create-operation propagation. The schema bundle POST returns 200 (the bundle exists in GCP, verified via gcloud), but the follow-up GET in the same apply returns "Parent table ... is either creating or deleting" and Terraform marks the resource tainted. Add an error_retry_predicate that recognises this transient 400 and retries the read. Same pattern as PubsubTopicProjectNotReady. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a retry predicate so
google_bigtable_schema_bundleretries its post-create Read when the parent Bigtable table is still propagating from a create operation in the same apply. This eliminates the spurious "tainted resource" outcome the OP reports.Fixes hashicorp/terraform-provider-google#25463 — see hashicorp/terraform-provider-google#25463
Why
The OP reports — and confirms via gcloud — that the
POSTto create a schema bundle succeeds, but the immediateGETagainst the same resource within the same apply returns:This is a classic "parent eventually consistent" race: Bigtable's table create returns success very fast, but a brief window remains where dependent operations against
tables/X/schemaBundles/Ysee the table as transitioning. The schema bundle resource itself was created (visible to gcloud), but Terraform reports the apply as failed and marks the bundle tainted because the post-create Read returned 400.The exact same shape of bug has a proven fix already in this codebase:
PubsubTopicProjectNotReady(mmv1/third_party/terraform/transport/error_retry_predicates.go:521) catches a transient 400 against new pubsub topics and retries. Theerror_retry_predicatesmmv1 attribute applies the predicate to all CRUD calls of the resource, transparently routing the retry through the existing transport retry helper.This PR adds:
BigtableSchemaBundleParentTableNotReadythat matches 400 + body contains"is either creating or deleting".mmv1/products/bigtable/SchemaBundle.yaml.GCP API reference: https://cloud.google.com/bigtable/docs/reference/admin/rest/v2/projects.instances.tables.schemaBundles
What changed
Edge cases tested
PubsubTopicProjectNotReady, which has been in production since 2020 (issue GoogleCloudPlatform#4349).error_retry_predicatesapplies to all CRUD calls. Update can race the same way (e.g. table being deleted concurrently); Delete is fine because the bundle is gone if its parent is gone.Test protocol
go build ./google/transport/...(after copying canonical source into tpg)Resources
Disclosure
This PR was implemented with assistance from Claude Code as part of a focused contribution batch. The diff is 17 lines split between an mmv1 YAML attribute reference and a new error-retry predicate function modeled directly on
PubsubTopicProjectNotReady. Compile was verified by hand-applying the new function to the rendered tpg transport package.