Skip to content

Kill all the zombies πŸ§Ÿβ€β™‚οΈ #3750

Kill all the zombies πŸ§Ÿβ€β™‚οΈ

Kill all the zombies πŸ§Ÿβ€β™‚οΈ #3750

Workflow file for this run

name: Kill all the zombies πŸ§Ÿβ€β™‚οΈ
on:
schedule:
- cron: '0 */2 * * *'
workflow_dispatch:
jobs:
kill-zombies:
name: I am here to chew gum, and kill stuck jobs, and I am all out of gum!
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Authenticate to Google Cloud
id: "auth"
uses: google-github-actions/auth@v2
with:
credentials_json: "${{ secrets.GCP_DATAFLOW_SERVICE_KEY }}"
- name: Set up Cloud SDK and upload csv files
uses: google-github-actions/setup-gcloud@v2
- name: Kill all active jobs older than 6 hours
shell: python -u {0}
run: |
import subprocess
import json
jobs = json.loads(subprocess.check_output([
"gcloud", "dataflow", "jobs", "list",
"--created-before=-p6h", "--status=active",
"--filter=name:a618127503*", "--format=json",
"--region=us-central1"
]))
if jobs:
for job in jobs:
subprocess.check_call([
"gcloud", "dataflow", "jobs", "cancel",
str(job["id"]),
"--region=us-central1"
])
env:
GOOGLE_APPLICATION_CREDENTIALS: "${{ steps.auth.outputs.credentials_file_path }}"