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

run_trigger: retry when a "locked" error is returned #178

Merged
merged 2 commits into from
Sep 21, 2020

Conversation

bendrucker
Copy link
Contributor

@bendrucker bendrucker commented May 21, 2020

Description

This PR adds retries for run trigger creation. Concurrently creating run triggers on a workspace results in an error—now those errors are considered retryable for 1 minute.

Closes #169

Testing plan

  1. Create many run triggers for a given workspace
  2. Attach them all in a single apply

I've added a new test that is able to reproduce this condition. When the test is run without the new retries, it fails with lock errors. In my initial test, 5/10 resources failed:

make testacc TESTARGS='-run TestAccTFERunTrigger_many'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run TestAccTFERunTrigger_many -timeout 15m
?   	github.com/terraform-providers/terraform-provider-tfe	[no test files]
=== RUN   TestAccTFERunTrigger_many
    TestAccTFERunTrigger_many: testing.go:569: Step 0 error: errors during apply:

        Error: Error creating run trigger on workspace ws-NNTPzRVLDRoHe6U9 with sourceable ws-KvgXdmjw462ZM2hq: Invalid Attribute

        Run Trigger creation locked by another user in your organization. Please try again

          on /var/folders/7p/z_kw6fc9693fly126tljpml40000gn/T/tf-test655254769/main.tf line 19:
          (source code not available)

   # 4 more errors truncated for brevity
--- FAIL: TestAccTFERunTrigger_many (5.48s)
FAIL
FAIL	github.com/terraform-providers/terraform-provider-tfe/tfe	5.771s
?   	github.com/terraform-providers/terraform-provider-tfe/version	[no test files]
FAIL
make: *** [testacc] Error 1

Output from acceptance tests

Please run the full suite of acceptance tests locally and include the output here.

$ make testacc TESTARGS='-run TestAccTFERunTrigger'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run TestAccTFERunTrigger -timeout 15m
?   	github.com/terraform-providers/terraform-provider-tfe	[no test files]
=== RUN   TestAccTFERunTrigger_basic
--- PASS: TestAccTFERunTrigger_basic (5.32s)
=== RUN   TestAccTFERunTrigger_basicWorkspaceID
--- PASS: TestAccTFERunTrigger_basicWorkspaceID (5.11s)
=== RUN   TestAccTFERunTrigger_updateWorkspaceExternalIDToWorkspaceID
--- PASS: TestAccTFERunTrigger_updateWorkspaceExternalIDToWorkspaceID (7.29s)
=== RUN   TestAccTFERunTrigger_many
--- PASS: TestAccTFERunTrigger_many (8.70s)
=== RUN   TestAccTFERunTriggerImport
--- PASS: TestAccTFERunTriggerImport (4.45s)
PASS
ok  	github.com/terraform-providers/terraform-provider-tfe/tfe	31.236s
?   	github.com/terraform-providers/terraform-provider-tfe/version	[no test files]

@bendrucker bendrucker force-pushed the run-triggers-retry branch from 82bead3 to 6ae5f16 Compare June 23, 2020 20:24
@bendrucker
Copy link
Contributor Author

bendrucker commented Jun 23, 2020

Resolved the merge conflict that'd resulted here, and re-ran the acceptance tests (edited the original post). Also noticed I should have been specifying the timeout in the schema, fixed that.

We're holding off on adopting run triggers until we can add several reliably, would appreciate a review here!

@koikonom
Copy link
Contributor

Hi @bendrucker, thanks for submitting this PR.

Copy link
Contributor

@koikonom koikonom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@koikonom koikonom merged commit f649fe2 into hashicorp:master Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Triggers creation fails because of locking on Terraform side
2 participants