79306747

Date: 2024-12-25 02:22:16
Score: 0.5
Natty:
Report link

I endeded up using a workaround. This is because of the workflow client libraries limitation. It does not support all capabilities on par with gcloud for example. Hence nothing much we can customize with the configuration.

To simplify, we have to use

  1. gcloud command in workflow (i use "run cloud deploy" for my use case specifically due to some of my requirements, but "run jobs create" could work as well
  2. leverage the gcloud flag options that is to "--execute-now"

https://cloud.google.com/workflows/docs/samples/workflows-cloud-build-run-gcloud

Example

- execute_monitor_job_async:
    call: gcloud
    args:
      args: $${"run jobs deploy " + monitor_job + " --image " + monitor_job_image + " --region " + gcp_region + " --update-env-vars " + full_env_vars + " --task-timeout 86400s --execute-now"}

and defining gcloud:

gcloud:
    params: [args]
    steps:
    - create_build:
        call: googleapis.cloudbuild.v1.projects.builds.create
        args:
          projectId: $${sys.get_env("gcp_project_id")}
          parent: $${"projects/" + sys.get_env("gcp_project_id") + "/locations/global"}
          body:
            serviceAccount: $${"projects/" + sys.get_env("gcp_project_id") + "/serviceAccounts/" + sys.get_env("cloud_build_sa")}
            options:
              logging: CLOUD_LOGGING_ONLY
            steps:
            - name: gcr.io/google.com/cloudsdktool/cloud-sdk
              entrypoint: /bin/bash
              args: $${["-c", "gcloud " + args + " > $$BUILDER_OUTPUT/output"]}
        result: result_builds_create
    - return_build_result:
        return: $${text.split(text.decode(base64.decode(result_builds_create.metadata.build.results.buildStepOutputs[0])), "\n")}

(Note: the "full_env_vars" details are omitted here, it's just various env vars i need for my run jobs to pass in)

The result: It will not block the workflow steps anymore. It will proceed to next step

If anyone want to read more there's a good explanation article by Mark - https://medium.com/@markwkiehl/google-cloud-run-jobs-scheduler-22a4e9252cf0

Reasons:
  • Blacklisted phrase (0.5): i need
  • Blacklisted phrase (0.5): medium.com
  • Long answer (-1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: unacorn