hashicorp / setup-terraform

Sets up Terraform CLI in your GitHub Actions workflow.
https://developer.hashicorp.com/terraform/tutorials/automation/github-actions
Mozilla Public License 2.0
1.34k stars 235 forks source link

Fails with AggregateError in self-hosted runners #425

Open yashid-mohamed opened 2 weeks ago

yashid-mohamed commented 2 weeks ago

Hi,

We are facing this issue where the setup-terraform@v3 action starts to fail with an AggregateError when this action is being invoked within a GitHub Actions self hosted runner (ubuntu 22.04) hosted in a Azure Kubernetes cluster using Actions Runner Controller.

Failed Run

##[debug]Evaluating condition for step: 'Run hashicorp/setup-terraform@v3'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Run hashicorp/setup-terraform@v[3](https://github.com/yashid-mohamed/my-test-app/actions/runs/9842799277/job/27172577799#step:4:3)
##[debug]Loading inputs
##[debug]Loading env
Run hashicorp/setup-terraform@v3
##[debug]Finding releases for Terraform version ~1.0
**Error: AggregateError**
##[debug]Node Action run completed with exit code 1
##[debug]Finishing: Run hashicorp/setup-terraform@v3

Successful Run

##[debug]Evaluating condition for step: 'Run hashicorp/setup-terraform@v3'
##[debug]Evaluating: success()
##[debug]Evaluating success:
##[debug]=> true
##[debug]Result: true
##[debug]Starting: Run hashicorp/setup-terraform@v3
##[debug]Loading inputs
##[debug]Loading env
Run hashicorp/setup-terraform@v3
##[debug]Finding releases for Terraform version ~1.0
##[debug]Getting build for Terraform version 1.0.11: linux amd64
##[debug]Downloading Terraform CLI from https://releases.hashicorp.com/terraform/1.0.11/terraform_1.0.11_linux_amd64.zip
##[debug]Downloading https://releases.hashicorp.com/terraform/1.0.11/terraform_1.0.11_linux_amd64.zip
##[debug]Destination /home/runner/_work/_temp/43b4ccd6-66ca-4abd-b118-9e973a0d0cb[2](https://github.com/yashid-mohamed/my-test-app/actions/runs/9855362015/job/27240248601#step:4:2)
##[debug]download complete
##[debug]Extracting Terraform CLI zip file
/usr/bin/unzip -o /home/runner/_work/_temp/4[3](https://github.com/yashid-mohamed/my-test-app/actions/runs/9855362015/job/27240248601#step:4:3)b4ccd6-66ca-4abd-b118-9e973a0d0cb2
Archive:  /home/runner/_work/_temp/[4](https://github.com/yashid-mohamed/my-test-app/actions/runs/9855362015/job/27240248601#step:4:4)3b4ccd6-66ca-4abd-b118-9e973a0d0cb2
  inflating: terraform               
##[debug]Terraform CLI path is /home/runner/_work/_temp/e228[5](https://github.com/yashid-mohamed/my-test-app/actions/runs/9855362015/job/27240248601#step:4:5)ab8-10f1-4d98-b69d-9dc424a5c348.
##[debug]Node Action run completed with exit code 0
##[debug]Finishing: Run hashicorp/setup-terraform@v3

I suspect that it might be due to rate limit issue because the same action works fine when re-run later after some time / next day.

Can someone please help shed some light on why the action fails with an AggregateError and also how we can overcome this while using self-hosted GitHub runners?

Thanks!

Note - I'm installing node v20.15.0 in a previous step in the same workflow using the setup-node@v4 action. We have not seen this issue occur when using the GitHub hosted runners.

V-know commented 1 week ago

Add one more scenario. We are facing the same issue now.

Run hashicorp/setup-terraform@v3
  with:
    cli_config_credentials_hostname: app.terraform.io
    terraform_version: latest
    terraform_wrapper: true
  env:
    ALICLOUD_ACCESS_KEY_SECRET: ***
    ALIBABA_CLOUD_SECURITY_TOKEN: ***
    ALICLOUD_ACCESS_KEY_STS_TOKEN: ***
    ALIBABACLOUD_SECURITY_TOKEN: ***
    ALICLOUD_SECURITY_TOKEN: ***
Error: AggregateError

We use apt-get to install terraform as the workaround solution, it works. But we still want to know the root cause and hope to fix this problem as soon as possible. Thank you.

     - name: 'Terraform Setup'
        run: |
          sudo apt-get update && sudo apt-get install -y gnupg software-properties-common
          wget -O- https://apt.releases.hashicorp.com/gpg | \
          gpg --dearmor | \
          sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null
          gpg --no-default-keyring \
          --keyring /usr/share/keyrings/hashicorp-archive-keyring.gpg \
          --fingerprint
          echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \
          https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \
          sudo tee /etc/apt/sources.list.d/hashicorp.list
          sudo apt update
          sudo apt-get install terraform