Problem
Runs on Terraform Enterprise workspaces are not executing. They are stuck in Plan queued
state.
Prerequisites
- Terraform Enterprise FDO on OpenShift
Cause
Terraform Enterprise will use a default worker to execute runs on a workspace. When running Terraform Enterprise on OpenShift the default worker is not able to execute a run. You will see the following error in the Terraform Enterprise logs:
{"@level":"debug","@message":"kubeconfig path is not specified.
App will fall back to using inClusterConfig or default config",
"@module":"task-worker.executor","@timestamp":"2024-07-15T12:33:54.497881Z"}
W0715 12:33:54.497906 65 client_config.go:618]
Neither --kubeconfig nor --master was specified. Using the inClusterConfig.
This might not work.
{"@level":"error","@message":"error running task instance",
"@module":"task-worker.executor","@timestamp":"2024-07-15T12:33:58.515414Z",
"err":"error waiting for kubernetes container to start: pod container is not ready:
kubernetes container terminated. reason: Error, message: , exit code: 1"}
Solution
Follow the OpenShift requirements as documented here
- Use a custom agent image
FROM hashicorp/tfc-agent
USER root
RUN mkdir /.tfc-agent && \
chmod 770 /.tfc-agent
USER tfc-agent
- Use the created custom agent image in your Terraform Enterprise environment using the following parameters
TFE_RUN_PIPELINE_IMAGE
TFE_RUN_PIPELINE_KUBERNETES_IMAGE_PULL_SECRET_NAME
Outcome
Runs will execute using the custom agent image
Additional Information
-
OpenShift requirements can be found here