Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Enable flow run suspend/resume with Cloud Run workers via unique Job names #249

Merged
merged 13 commits into from
Feb 22, 2024

Conversation

kevingrismore
Copy link
Contributor

@kevingrismore kevingrismore commented Feb 5, 2024

Lack of unique Cloud Run job names causes a number of retry/resume-oriented failure modes:

  • With Keep Job After Completion enabled:
    • Crash on all UI/external flow run retries
    • Crash on suspend/resume
  • With Keep Job After Completion disabled:
    • Crash on speedy UI/external flow run retries
    • Crash on suspend/resume

In the second category, even with job auto-deletion, the gap in time between attempted job deletion and new job creation upon retrying/resuming is not long enough for the same job name to become available.

Worker 'CloudRunWorkerV2 344ea0bf-4ec7-403a-a406-6ace64b19901' submitting flow run '7bd88a94-7bb0-4bca-be28-73416b06b0c7'
Creating Cloud Run JobV2 prefect-mu6-altair
...
Worker 'CloudRunWorkerV2 344ea0bf-4ec7-403a-a406-6ace64b19901' submitting flow run '7bd88a94-7bb0-4bca-be28-73416b06b0c7'
Creating Cloud Run JobV2 prefect-mu6-altair
Failed to submit flow run '7bd88a94-7bb0-4bca-be28-73416b06b0c7' to infrastructure.
...
googleapiclient.errors.HttpError: https://run.googleapis.com/v2/projects/prefect-sbx-sales-engineering/locations/us-central1/jobs?jobId=prefect-mu6-altair&alt=json returned "Resource 'prefect-mu6-altair' already exists.". Details: "Resource 'prefect-mu6-altair' already exists.">

This PR adds a similar naming convention to Cloud Run jobs that was used in the corresponding infrastructure block so retried/resumed job names don't overlap.

Example

Worker 'CloudRunWorker d0352da8-db2c-4947-9e05-cfe2ab9f0f3f' submitting flow run '74169b6b-b830-41c6-a96e-3d9bb13291fb'
Creating Cloud Run Job sigma110-kochab-g-663160a35deb407ca1f1696e21df5c80
...
Finished in state Resuming(type=SCHEDULED)
...
Worker 'CloudRunWorker d0352da8-db2c-4947-9e05-cfe2ab9f0f3f' submitting flow run '74169b6b-b830-41c6-a96e-3d9bb13291fb'
Creating Cloud Run Job sigma110-kochab-g-2f3a2079986848cf966543267030ee40

Checklist

  • References any related issue by including "Closes #" or "Closes ".
    • If no issue exists and your change is not a small fix, please create an issue first.
  • Includes tests or only affects documentation.
  • Passes pre-commit checks.
    • Run pre-commit install && pre-commit run --all locally for formatting and linting.
  • Includes screenshots of documentation updates.
    • Run mkdocs serve view documentation locally.
  • Summarizes PR's changes in CHANGELOG.md

@kevingrismore kevingrismore marked this pull request as ready for review February 5, 2024 04:25
@kevingrismore kevingrismore requested a review from a team as a code owner February 5, 2024 04:25
prefect_gcp/workers/cloud_run_v2.py Outdated Show resolved Hide resolved
prefect_gcp/workers/cloud_run_v2.py Outdated Show resolved Hide resolved
Copy link
Contributor

@zzstoatzz zzstoatzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this LGTM!

prefect_gcp/utilities.py Outdated Show resolved Hide resolved
Copy link
Member

@desertaxle desertaxle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kevingrismore kevingrismore merged commit 72bc6ea into main Feb 22, 2024
10 checks passed
@kevingrismore kevingrismore deleted the cloud-run-suspend branch February 22, 2024 23:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants