Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting a weird error when passing a json file as a value in a set #1566

Open
Gunnar-Stunnar opened this issue Jan 19, 2025 · 0 comments
Open
Assignees
Labels

Comments

@Gunnar-Stunnar
Copy link

Terraform, Provider, Kubernetes and Helm Versions

Terraform version: v1.10.1
Provider version: v2.16.1
Kubernetes version: 1.29.11

Affected Resource(s)

Terraform Configuration Files

resource "helm_release" "gpu-worker-node" {
  name       = "prefect-worker-GPU-worker"
  chart      = "prefect-worker"
  repository = "https://prefecthq.github.io/prefect-helm"
  namespace  = var.namespace

  set {
    name  = "worker.apiConfig"
    value = "server"
  }

  set {
    name  = "worker.serverApiConfig.apiUrl"
    value = "${var.prefectServerAddress}/api"
    # value = "http://prefect-server.prefect-server.svc.cluster.local:4200/api"
  }

  set {
    name  = "worker.serverApiConfig.uiUrl"
    value = var.prefectServerAddress
  }

  set {
    name  = "worker.config.workPool"
    value = var.workPool
  }

  set {
    name  = "worker\\.config\\.baseJobTemplate\\.configuration"
    type = "string"
    value = "${file("${path.module}/gpuJob.json")}"
  }

  # add workers
  dynamic "set" {
    for_each = zipmap(tolist(var.workQueues), range(length(var.workQueues)))
    content {
      name  = "worker.config.workQueues[${set.value}]"
      value = "ocr-${set.key}"
    }
  }

  verify = false
}

--- json file ---

{
  "job_configuration": {
    "command": "{{ command }}",
    "env": "{{ env }}",
    "labels": "{{ labels }}",
    "name": "{{ name }}",
    "namespace": "{{ namespace }}",
    "job_manifest": {
      "apiVersion": "batch/v1",
      "kind": "Job",
      "metadata": {
        "generateName": "{{ name }}-",
        "labels": "{{ labels }}",
        "namespace": "{{ namespace }}"
      },
      "spec": {
        "backoffLimit": 0,
        "template": {
          "spec": {
            "completions": 1,
            "containers": [
              {
                "args": "{{ command }}",
                "env": "{{ env }}",
                "image": "{{ image }}",
                "imagePullPolicy": "{{ image_pull_policy }}",
                "name": "prefect-job"
              }
            ],
            "parallelism": 1,
            "restartPolicy": "Never",
            "serviceAccountName": "{{ service_account_name }}",
            "tolerations": [
              {
                "key": "nvidia.com/gpu",
                "operator": "Exists",
                "effect": "NoSchedule"
              }
            ]
          }
        },
        "ttlSecondsAfterFinished": "{{ finished_job_ttl }}"
      }
    },
    "cluster_config": "{{ cluster_config }}",
    "job_watch_timeout_seconds": "{{ job_watch_timeout_seconds }}",
    "pod_watch_timeout_seconds": "{{ pod_watch_timeout_seconds }}",
    "stream_output": "{{ stream_output }}"
  },
  "variables": {
    "description": "Default variables for the Kubernetes worker.\n\nThe schema for this class is used to populate the `variables` section of the default\nbase job template.",
    "properties": {
      "name": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "Name given to infrastructure created by a worker.",
        "title": "Name"
      },
      "env": {
        "additionalProperties": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ]
        },
        "description": "Environment variables to set when starting a flow run.",
        "title": "Environment Variables",
        "type": "object"
      },
      "labels": {
        "additionalProperties": {
          "type": "string"
        },
        "description": "Labels applied to infrastructure created by a worker.",
        "title": "Labels",
        "type": "object"
      },
      "command": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "The command to use when starting a flow run. In most cases, this should be left blank and the command will be automatically generated by the worker.",
        "title": "Command"
      },
      "namespace": {
        "default": "default",
        "description": "The Kubernetes namespace to create jobs within.",
        "title": "Namespace",
        "type": "string"
      },
      "image": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "The image reference of a container image to use for created jobs. If not set, the latest Prefect image will be used.",
        "examples": [
          "docker.io/prefecthq/prefect:3-latest"
        ],
        "title": "Image"
      },
      "service_account_name": {
        "anyOf": [
          {
            "type": "string"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "The Kubernetes service account to use for job creation.",
        "title": "Service Account Name"
      },
      "image_pull_policy": {
        "default": "IfNotPresent",
        "description": "The Kubernetes image pull policy to use for job containers.",
        "enum": [
          "IfNotPresent",
          "Always",
          "Never"
        ],
        "title": "Image Pull Policy",
        "type": "string"
      },
      "finished_job_ttl": {
        "anyOf": [
          {
            "type": "integer"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "The number of seconds to retain jobs after completion. If set, finished jobs will be cleaned up by Kubernetes after the given delay. If not set, jobs will be retained indefinitely.",
        "title": "Finished Job TTL"
      },
      "job_watch_timeout_seconds": {
        "anyOf": [
          {
            "type": "integer"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "Number of seconds to wait for each event emitted by a job before timing out. If not set, the worker will wait for each event indefinitely.",
        "title": "Job Watch Timeout Seconds"
      },
      "pod_watch_timeout_seconds": {
        "default": 60,
        "description": "Number of seconds to watch for pod creation before timing out.",
        "title": "Pod Watch Timeout Seconds",
        "type": "integer"
      },
      "stream_output": {
        "default": true,
        "description": "If set, output will be streamed from the job to local standard output.",
        "title": "Stream Output",
        "type": "boolean"
      },
      "cluster_config": {
        "anyOf": [
          {
            "$ref": "#/definitions/KubernetesClusterConfig"
          },
          {
            "type": "null"
          }
        ],
        "default": null,
        "description": "The Kubernetes cluster config to use for job creation."
      }
    },
    "type": "object",
    "definitions": {
      "KubernetesClusterConfig": {
        "block_schema_references": {},
        "block_type_slug": "kubernetes-cluster-config",
        "description": "Stores configuration for interaction with Kubernetes clusters.\n\nSee `from_file` for creation.",
        "properties": {
          "config": {
            "description": "The entire contents of a kubectl config file.",
            "title": "Config",
            "type": "object"
          },
          "context_name": {
            "description": "The name of the kubectl context to use.",
            "title": "Context Name",
            "type": "string"
          }
        },
        "required": [
          "config",
          "context_name"
        ],
        "secret_fields": [],
        "title": "KubernetesClusterConfig",
        "type": "object"
      }
    }
  }
}

Debug Output

NOTE: In addition to Terraform debugging, please set HELM_DEBUG=1 to enable debugging info from helm.

│         "description": "Stores configuration for interaction with Kubernetes clusters.\n\nSee `from_file` for creation.",
│         "properties": {
│           "config": {
│             "description": "The entire contents of a kubectl config file.",
│             "title": "Config",
│             "type": "object"
│           },
│           "context_name": {
│             "description": "The name of the kubectl context to use.",
│             "title": "Context Name",
│             "type": "string"
│           }
│         },
│         "required": [
│           "config",
│           "context_name"
│         ],
│         "secret_fields": [],
│         "title": "KubernetesClusterConfig",
│         "type": "object"
│       }
│     }
│   }
│ }, key "}\"" has no value (cannot end with ,)
│ 
│   with module.gpu-worker.helm_release.gpu-worker-node,
│   on ../modules/gpu-resource/helm-resources.tf line 1, in resource "helm_release" "gpu-worker-node":
│    1: resource "helm_release" "gpu-worker-node" {

Panic Output

Steps to Reproduce

  1. terraform plan --var-file="./tfvars/terraform.tfvars" --out=tfplan
  2. terraform apply tfplan

Expected Behavior

apply prefect-worker to kubernete cluster with the given a given job config:
Replicate this command:
helm install prefect-worker prefect/prefect-worker -f values.yaml --set-file worker.config.baseJobTemplate.configuration=base-job-template.json

Actual Behavior

returning this error when trying to apply
│ }, key "}\"" has no value (cannot end with ,)

Important Factoids

I am using azure kubernete servies

References

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants