terraform-operator icon indicating copy to clipboard operation
terraform-operator copied to clipboard

Terraform stuck in running state when using dependencyRef variable on non existing key

Open IbraheemAlSaady opened this issue 2 years ago • 0 comments

If the pod fails to mount the secret based on a variable that have dependencyRef on a key that does not exist, it will cause the pod to be in CreateContainerConfigError state with error couldn't find key number in Secret ....

To Reproduce The following will produce the issue

apiVersion: run.terraform-operator.io/v1alpha1
kind: Terraform
metadata:
  name: terraform-run1
spec:
  terraformVersion: 1.1.7

  module:
    source: IbraheemAlSaady/test/module
    version: 0.0.3

  variables:
    - key: length
      value: "4"

  outputs:
    - key: result
      moduleOutputName: result
---
apiVersion: run.terraform-operator.io/v1alpha1
kind: Terraform
metadata:
  name: terraform-run2
spec:
  terraformVersion: 1.1.7

  module:
    source: IbraheemAlSaady/test/module
    version: 0.0.3

  dependsOn:
    - name: terraform-run1

  variables:
    - key: length
      dependencyRef:
        name: terraform-run1
        key: invalid-key

Expected behavior If the pod hit an error, we need to update the Terraform status to Failed

Current evaluations are only happening on the job, the job is not aware that pod is in that state. We probably need to validate the pod status as well

Possibly we need to do the pod evaluation when the job is in a running state

Versions

  • Operator: 0.1.1
  • Runner: 0.4.0

IbraheemAlSaady avatar Jul 22 '22 08:07 IbraheemAlSaady