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

Use python to zombiekill #59

Merged
merged 1 commit into from
Nov 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/workflows/ash.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,23 @@ jobs:
- name: Set up Cloud SDK and upload csv files
uses: google-github-actions/setup-gcloud@v1
- name: Kill all active jobs older than 2 hours
shell: python -u {0}
run: |
gcloud dataflow jobs list --created-before=-p2h --status=active --filter="name:a618127503*" --format=json --region=us-central | jq -r ".[].id" | xargs -L1 gcloud dataflow jobs cancel --region=us-central1
import subprocess
import json

jobs = json.loads(subprocess.check_output([
"gcloud", "dataflow", "jobs", "list",
"--created-before=-p2h", "--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 }}"