<@ULVA73B9P> I have been trying to add my cloud sq...
# ask-marvin
m
@Marvin I have been trying to add my cloud sql instance to my job configuration in my work pool but everytime I make the change all deployments using the workpool crashes. My job config that keep crashes, look like this. Does anyone know what I am doing wrong
Copy code
{
  "job_configuration": {
    "env": "{{ env }}",
    "name": "{{ name }}",
    "labels": "{{ labels }}",
    "region": "{{ region }}",
    "command": "{{ command }}",
    "timeout": "{{ timeout }}",
    "job_body": {
      "kind": "Job",
      "spec": {
        "template": {
          "metadata": {
            "annotations": {
              "<http://run.googleapis.com/vpc-access-connector|run.googleapis.com/vpc-access-connector>": "{{ vpc_connector_name }}"
            }
          },
          "spec": {
            "template": {
              "spec": {
                "containers": [
                  {
                    "image": "{{ image }}",
                    "command": "{{ command }}",
                    "resources": {
                      "limits": {
                        "cpu": "{{ cpu }}",
                        "memory": "{{ memory }}"
                      },
                      "requests": {
                        "cpu": "{{ cpu }}",
                        "memory": "{{ memory }}"
                      }
                    }
                  }
                ],
                "timeoutSeconds": "{{ timeout }}",
                "serviceAccountName": "{{ service_account_name }}"
              }
            }
          }
        }
      },
      "metadata": {
        "name": "{{ name }}",
        "annotations": {
          "<http://run.googleapis.com/launch-stage|run.googleapis.com/launch-stage>": "BETA"
        }
      },
      "apiVersion": "<http://run.googleapis.com/v1|run.googleapis.com/v1>"
    },
    "keep_job": "{{ keep_job }}",
    "credentials": "{{ credentials }}"
  }
}
I get an error message that looks like this
Copy code
Failed to generate job configuration: 1 validation error for PushPoolCloudRunWorkerJobConfiguration
job_body
  Value error, Job is missing required attributes at the following paths: /spec/template/spec/template [type=value_error, input_value={'kind': 'Job', 'spec': {...'<http://run.googleapis.com/v1|run.googleapis.com/v1>'}, input_type=dict]
    For further information visit <https://errors.pydantic.dev/2.9/v/value_error>
m
Your message was too long by 251 tokens - please shorten it and try again. For reference, here's your message at the allowed limit:
I have been trying to add my cloud sql instance to my job configuration in my work pool but everytime I make the change all deployments using the workpool crashes. My job config that keep crashes, look like this. Does anyone know what I am doing wrong
```{ "job_configuration": { "env": "{{ env }}", "name": "{{ name }}", "labels": "{{ labels }}", "region": "{{ region }}", "command": "{{ command }}", "timeout": "{{ timeout }}", "job_body": { "kind": "Job", "spec": { "template": { "metadata": { "name": "{{ name }}", "annotations": { "<http://run.googleapis.com/cloudsql-instances%7Crun.googleapis.com/cloudsql-instances>": "{{ cloudsql_instance }}" } }, "spec": { "template": { "spec": { "containers": [ { "image": "{{ image }}", "command": "{{ command }}", "resources": { "limits": { "cpu": "{{ cpu }}", "memory": "{{ memory }}" }, "requests": { "cpu": "{{ cpu }}", "memory": "{{ memory }}" } } } ], "timeoutSeconds": "{{ timeout }}", "serviceAccountName": "{{ service_account_name }}" }
n
hi @Michael - it looks like there might be an extra layer of nesting? like
Copy code
"spec": {
        "template": {
seems to be inside itself, are you building this programmatically somehow?
m
Hi @Nate, the documentation didn't help, was adapting from a solution I saw online. So I am trying to connect to CloudSQL when I send the flow to be ran in Cloud Run. The only way is to add it to the base job template found in the advanced tab of the Work pool. I didn't find any documentation on how to do this so I just adapted mine from a solution I saw at https://linen.prefect.io/t/15996175/is-it-possible-to-add-a-cloud-sql-connection-with-a-serverle
n
ok, i’m suggesting that maybe you have accidentally doubly nested the spec portion of your job config because of the validation error message shown above
or which work pool type are you trying to use? i would have guessed cloud run but your example above doesnt look like the default base job template for that type
m
It is actually cloud Run šŸ˜…
I honestly don't understand the structure of the json or where to add the connection field so I did an interpolation and hoped for the best. I am using the Cloud Run push @Nate
n
so i think the cloudsql instances are only supported in the cloud run v2 hybrid worker, meaning you'd have to run this worker yourself, though we could definitely get support added to the push pool at some point we'd essentially just have to port this PR
m
Okay, thank you very much for this, I would try it out. Just have to configure my worker first šŸ˜…
šŸ‘ 1
m
Finally @Nate which do you think is better for a Worker, Cloud Run service or a Kubernetes cluster?
n
cloud run service unless you have some strong idiosyncratic reason to use kubernetes
if only because thats what the guide will show, but operationally i dont think thered be a big advantage to running the worker in k8s
bc then (I think) you'd have to think about networking to let the worker pod spin up cloud run stuff, since pods are usually in private subnets etc
m
Not really. Thank you very much I really appreciate it
n
šŸ‘
m
@Nate I was able to change the kind of work pol, Now I am facing the final boss, the validation error