Skip to content

feat: add retries to TF init step #500

@b-

Description

@b-

Is your feature request related to a problem

Lately I've been experiencing a lot of context deadline exceeded's during the init stage of the workflow.

Example 1:

Error: Failed to install provider

Error while installing hashicorp/time v0.13.1: could not query provider
registry for registry.terraform.io/hashicorp/time: the request failed after 2
attempts, please try again later: Get
"https://registry.terraform.io/v1/providers/hashicorp/time/0.13.1/download/linux/amd64":
context deadline exceeded

Example 2:

Run # TF initialize.
Initializing the backend...
Initializing modules...

Error: Failed to request discovery document: Get "https://app.terraform.io/.well-known/terraform.json": context deadline exceeded

Over the past day or so this has happened at various points in the init process, probably about a dozen times. Re-running the job usually clears it up.

Describe the solution you'd like

Detecting failures during init and retrying a couple of times (maybe let the workflow specify a init-retry-count param?) would help.

I know this is an issue with GHA's network and Terraform's registry, rather than an issue with your code. However, I see that both Hashicorp and GitHub's status pages indicate that everything is fine, so I don't know if or when this will clear up.

Describe alternatives you've considered

Since I couldn't find an option to skip the init step when running tf-via-pr with command: plan or command: apply, I don't think there are any alternatives. I actually noticed my workflow is using tf-via-pr to run an init earlier on in the workflow anyway, so maybe breaking that out would allow the logic to be altered and additional retries to be performed.

As an aside, I wonder if breaking the action up into more individual jobs/steps and a recommended workflow for putting them together in a repository (or even in a reusable workflow that's then consumed by a repo), a la https://github.com/dflook/terraform-github-actions/tree/main/example_workflows might make tailoring/hacking on the workflow logic a little less intimidating!

Additional context

n/a

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions