Added part two of cloud run job reporting server/#4986#867
Conversation
ToreMerkely
commented
May 8, 2026
- feat(cloudrun): list Cloud Run Jobs via JobsClient (Slice 2, #4986)
- feat(cloudrun): emit Cloud Run Jobs in env snapshots (Slice 3, #4986)
Add the internal primitives for surfacing Cloud Run Jobs alongside
Services in env snapshots. Jobs do not have a revision/traffic-split
model — there is one current image per Job, taken from
Template.Template.Containers in the Job resource.
- New `Job` struct (Name, Digests, CreatedAt) mirroring `Revision`.
- `apiClient` interface gains `listJobs`; production `gcpAPI` uses
`run.NewJobsClient` and the same iterator pattern as listServices.
- `Client.ListJobs(ctx, project, region)` returns `[]Job`.
- `New()` constructs the JobsClient and cleans up the existing two
clients on construction error. `Close()` joins all three.
- Unlike Services, ListJobs returns the full Job (with Template
populated), so no per-resource follow-up call is needed.
No caller wires this up yet — that's Slice 3 (cmd layer + snapshot
payload). Tests cover empty input, digest-pinned and tag-pinned
images, multi-container task templates, multi-job listings, nil
CreateTime, and error propagation.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Wire ListJobs end-to-end so idle Cloud Run Jobs surface in
\`kosli snapshot cloud-run\` alongside Service revisions. The whole
point of #4986: a Cloud Run Job's image lives on the Job resource
itself, not on a running Execution, so batch / scheduled / event-
driven Jobs that spend most of their time idle were previously
invisible.
- \`cloudRunLister\` interface gains ListJobs.
- \`run()\` lists Jobs alongside Services and applies the same name
filter to both, so existing --services / --exclude / -regex flags
work uniformly across kinds (the kosli-reporter self-reference
filter that the test bed relies on continues to work via
--exclude kosli-reporter).
- \`ToEnvRequest(services, jobs)\` emits service artifacts first, then
one artifact per job (kind=job, jobName).
- Success log "[N] revisions were reported" → "[N] artifacts were
reported" since the count now mixes revisions and jobs.
Tests cover: dry-run output containing both kinds, the live-server
happy-path with 2 services + 1 job → 3 artifacts, and the filter
applying to job names.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Claude finished @ToreMerkely's task in 1m 28s —— View job PR Review: Cloud Run Job Reporting (Slices 2–6, #4986)
Static AnalysisAll three checks pass cleanly — SummaryThis is a well-structured, clean PR. The five slices follow the repo's TDD/thin-vertical-slice conventions closely: each commit adds one capability, the codebase stays green throughout, and the test coverage is thorough. I have no blocking issues. What's Done Well
Minor Observations (Non-blocking)
Verdict: This PR is ready to merge. Clean implementation, thorough tests, good help text. Nice work. |
Pull request was converted to draft
…lude-regex (Slice 4, #4986) The cloud-run filter now applies uniformly to Cloud Run service names and Cloud Run Job names (since Slice 3). The old "--services" naming is misleading once jobs are in the mix, so flip to a kind-neutral "--include" / "--include-regex" pair. The exclude flags keep their names but their descriptions are updated to reflect the broader scope. - --services → --include - --services-regex → --include-regex - --exclude (description: now "service or job names") - --exclude-regex (description: same) Also rename the internal `serviceFilter` field on snapshotCloudRunOptions to `resourceFilter`, matching the field's now- broader scope. PreRunE mutex pairs and error messages follow the new flag names. The cloud-run command and the server's cloud-run env type are still hidden / pre-release, so this is a free rename — no users depend on the old flag names yet. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The short and long descriptions for \`kosli snapshot cloud-run\` only
mentioned services. Update them to:
- Explicitly cover both kinds at the top level ("services and jobs").
- Spell out the per-kind artifact mapping: services emit one artifact
per traffic revision, jobs emit one artifact per Job (since Jobs
don't have a revision/traffic-split model).
- Note that idle Jobs (no running Execution) are included — the
headline value-add of #4986.
- Document that the --include / --exclude filters apply uniformly to
both service and job names.
The "hidden, in-development" disclaimer stays.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Addressed the three follow-up items from the review summary:
The cloud-run command and the server's cloud-run env type are still hidden / pre-release, so the flag rename is a free change with no users on the old names. |
… 6, #4986)
\`kosli snapshot cloud-run\` was the only \`snapshot\` subcommand without
an \`Example\` block. Bring it to parity with ECS / Lambda / S3 / K8S /
Azure Apps / Docker / Path / Server, and flesh out the Long description.
- New snapshotCloudRunExample with three idiomatic invocations: full
snapshot, --include subset, and --exclude (with kosli-reporter as
the canonical "skip the Job that runs this command" case).
- Long description gains: a paragraph on GCP Application Default
Credentials and the roles/run.viewer requirement, and a paragraph
on filter usage (include vs exclude mutex, case-sensitivity, both
kinds covered) — same style ECS uses.
- \`Example: snapshotCloudRunExample\` wired into the cobra command.
Help output and the Mintlify docs generator both pick this up. Caret
quoting (^...^) is the existing convention — the docgen replaces it
with backticks; --help shows literal carets, same as every other
command.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>