temporalio / helm-charts

Temporal Helm charts
MIT License
294 stars 321 forks source link

[Bug] Job resources are not getting created with terraform helm_release #404

Closed mohamedazouz closed 1 month ago

mohamedazouz commented 1 year ago

What are you really trying to do?

I'm trying to install helm chart using terraform helm provider for that I'm using terraform helm_release resource to install the chart.

I have created a ticket in terraform-helm-provider repo but it seems like the issue exists in chart itself.

Describe the bug

I'm using the following terraform code to install the chart

// Temporal Chart: https://github.com/temporalio/helm-charts

resource "helm_release" "chart" {
  name             = "temporaltest"
  chart            = /local/Temporal/chart/path"
  create_namespace = true
  values           = []

  dependency_update = true
  timeout           = 15 * 60
}

After applying above terraform code, all pods are created but they are pending for init containers to finish, it's being pending forever, here's result of kubectl get pods

temporal-cassandra-0                  1/1     Running             0          2m2s
temporal-history-6f985967d8-wrngs     0/1     Init:2/4            0          2m6s
temporal-frontend-85f6dbdd85-44s4s    0/1     Init:2/4            0          2m6s
temporal-matching-65c75675d8-lfwz5    0/1     Init:2/4            0          2m6s
temporal-worker-5c46bd7dcc-2bhf2      0/1     Init:2/4            0          2m8s

Observation

Expected Behavior

Minimal Reproduction

  1. git clone https://github.com/temporalio/helm-charts
  2. Adjust local chart path to the cloned repo path
  3. terraform apply

Environment/Versions

Terraform version: v1.2.0
Provider version: 2.9.0
Kubernetes version: 1.23

Additional context

pmorillas-apheris commented 1 year ago

Hey @mohamedazouz

Run into the same issue and setting the wait = false should workaround it https://github.com/hashicorp/terraform-provider-helm/issues/683

mohamedazouz commented 11 months ago

@pmorillas-apheris sorry for the late reply.

I'm not sure if you understand the issue i'm facing but wait will ignore the not-yet-created resources. The issue is that all pods are in init state and waiting for Cassandra schema setup job to create the proper schema but unfortunately, jobs are not being created for some reason which is which i'm asking for help.

Your workaround of using wait = false, it assumes that the issue is just wait but it's not it's because jobs are not started to setup database schema,

LukaGiorgadze commented 11 months ago

@mohamedazouz

Here's a problem:

In the server-job.yamlfile, there's a condition that checks if .Values.schema.setup.enabled is true. If this condition is met, the schema setup jobs will be executed. The issue is that when you deploy using additional config values such as values.postgresql.yaml or any other database configuration (aurora, cassandra, mysql, postgres), this setting is being overwritten and turned off because those db config values have schema.setup.enabled = false by default. For example, If you open values. postgresql.yaml, you will find:

schema:
  setup:
    enabled: false

Solution:

So, the solution is quite simple. You just need to specify schema.setup.enabled = true explicitly in your terraform file using helm_release set block. Make sure it's boolean.

Screenshot 2023-09-21 at 18 12 54 Screenshot 2023-09-21 at 18 13 26
mohamedazouz commented 10 months ago

@LukaGiorgadze Actually, the enable job didn't work with me and I didn't want to spend more time checking another workaround

robholland commented 1 month ago

This should now be fixed by #522 which removes the use of helm hooks entirely. Please re-open if you still see problems.