Problem
When executing a plan or apply in Terraform Enterprise, the run fails with the following generic error message:
Setup failed: Failed setting up Terraform binary: Failed pushing binary to environment: exit status 125
Prerequisites
- Terraform Enterprise version up to
v202306-1. - An installation using the legacy run pipeline.
Cause
When a Terraform Enterprise run begins, it starts a disposable worker container to perform the action. The container's startup process fails if the capacity_cpus setting in the Terraform Enterprise configuration is set to a value higher than the number of CPUs available on the host system.
Solution
To resolve this issue, you must identify the error in the worker logs and adjust the capacity_cpus setting to a valid value.
Step 1: Identify the container naming convention
Container names in Terraform Enterprise vary by version. Identify the correct prefix for your installation.
Note: For Terraform Enterprise
v202205-1throughv202308-1, container names use thetfe-prefix (e.g.,tfe-atlas). Older versions may use theptfe_prefix (e.g.,ptfe_atlas). More information is available in the v202205-1 release notes.
Step 2: Confirm the CPU allocation error
Monitor the logs for the build worker container while initiating a run that reproduces the failure. Use the appropriate container name from Step 1.
For example, for an older version:
# sudo docker logs -f ptfe_build_worker 2>&1 | grep CPU
If the cause is a CPU mismatch, an error message similar to the following will appear in the logs.
{
"@level": "error",
"@message": "(Docker: 14c3f9f7-eed6-d583-ccca-8c696036febf) Failed to start container: exit status 125\nOutput:\ndocker: Error response from daemon: Range of CPUs is from 0.01 to 2.00, as there are only 2 CPUs available.\nSee 'docker run --help'.",
"@module": "terraform-build-worker.stdlog",
"@timestamp": "2022-05-17T08:08:09.745789Z",
"git_commit": "e356de1",
"isolation_type": "docker"
}Step 3: Check the current capacity_cpus value
Check the currently configured value for capacity_cpus.
# replicatedctl app-config export --template "{{.capacity_cpus.Value}}"Step 4: Adjust the capacity_cpus value and restart Terraform Enterprise
Change the capacity_cpus value to a number that is appropriate for your system. The default value of 0 allows for unlimited CPU usage.
-
Set the
capacity_cpusvalue.# replicatedctl app-config set capacity_cpus --value 0
-
Stop the Terraform Enterprise application.
# replicatedctl app stop
-
Start the Terraform Enterprise application to apply the changes.
# replicatedctl app start
Outcome
After Terraform Enterprise restarts, subsequent plans and applies should complete successfully.
Additional Information
- For information on using custom worker images, see the Alternative Terraform Worker Image documentation.
- For more details, refer to the CPU Capacity documentation.
- This article addresses one potential cause of
exit status 125. For other causes, see Runs fail with Setup failed... exit status 125.