Skip to content

chore(testgrid): document cancel API + host-side VM reconciliation in failure-analysis skill - #6211

Open
xavpaice wants to merge 5 commits into
mainfrom
docs/testgrid-skill-cancel-reconcile
Open

xavpaice wants to merge 5 commits into
mainfrom
docs/testgrid-skill-cancel-reconcile

Conversation

@xavpaice

@xavpaice xavpaice commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

Updates the testgrid-failure-analysis skill's cancellation and host-cleanup runbooks for the unified cancel mechanism added in replicatedhq/kURL-testgrid#1080 (merged 2026-10-14), which supersedes the skip-then-finish two-step the skill previously documented — plus two small adjacent corrections found in review.

Changes:

  • Cancel section (SKILL.md): documents POST /api/v1/ref/{refId}/cancel / POST /v1/ref/{refId}/cancel / POST /v1/instance/{id}/cancel (pending → skipped, running → finished with cancelled_at, response counts, Cancelled UI state), the runner-facing GET /v1/instances/cancelled 24h feed, and the host-side ReconcileCancelledVMIs behavior (matches by testid annotation or {instanceId}- prefix, also deletes PVCs/PVs/cloud-init secrets immediately instead of waiting for the ~8h age-based cleanup). Keeps the legacy /v1/skip + /v1/instance/{id}/finish endpoints documented as the fallback for DB-only zombies.
  • Host cleanup section (SKILL.md): cancel-by-design cannot touch already-finished instances; the follow-up fixes kURL-testgrid#1084 (stuck -sendlogs VMs reaped on a 30-minute leash) and Automated Kubernetes version update #1087 (sibling VMs reaped 10 minutes after initialprimary completes, logs shipped first) are noted, so manual VMI deletion is only needed for hosts on an older tgrun or for a finished instance whose initialprimary never stopped. Documents the discriminator endpoints (/v1/instance/{id}/status returns {} while running vs {"isSuccess":...} when finished; /v1/instance/{id}/cancelled).
  • New diagnostic (SKILL.md): the dequeue gate — a single Pending virt-launcher-* pod makes a host's runner stop picking up work (canScheduleNewVM), which is how zombie-VM buildup presents as "no new tests getting scheduled". Includes per-host check commands; notes runner heartbeats are statsd-only.
  • fetch.py (small behavior change, not docs-only): the failure filter now excludes instances with cancelledAt set — cancelled-while-running instances otherwise report as failures (cancel sets isSuccess=false, finishedAt, failure_reason='cancelled', and leaves isSkipped false) and would be pointlessly log-fetched. The SKILL.md "what it does" line matches.
  • AGENTS.md: the Testgrid API section now documents the cancel endpoints/reconciliation and the testgrid-checker latest-comment-prefix behavior. (This file also puts the PR outside the workflows' paths-ignore: ['.claude/**'], so the full build-test suite runs — see "Steps to reproduce" for verification that this changes no behavior.)

cancelledAt field verified against the live API (run pr-6204-900a11b-containerd-2.3.6-... / -ekco-..., fetched 2026-10-16):

instance state isSuccess isSkipped finishedAt cancelledAt failureReason counted as failure?
cancelled while running false false set set "cancelled" no (excluded by the new filter; previously yes — the bug)
cancelled while pending false true set set "" no (was already excluded via isSkipped)
normal success true false set null "" no
real failure false false set null "kurl_install" yes (still included)

All other statements were verified live against the production Testgrid fleet on 2026-10-15/16: cancelled-while-running instances from a cancelled batch had zero VMIs left on the hosts, and a status-discriminating cleanup pass deleted only VMs belonging to finished/cancelled instances while sparing in-flight tests.

Which issue(s) this PR fixes:

None.

Special notes for your reviewer:

Skill/docs + one two-line behavior filter in fetch.py. kURL-testgrid#1080's rollout note matters here: the cancel API exists in tgapi regardless, but each runner host's tgrun must be new enough to reconcile (strings /bin/tgrun | grep -c ReconcileCancelledVMIs); the prd hosts were verified to have it as of 2026-10-15 22:00Z. The sendlogs/sibling fixes (#1084/#1087) are merged but likewise need a host rollout to take effect.

Steps to reproduce

Read the rendered SKILL.md sections "Cancelling queued or stuck work via the API" and "Cleaning up VMs on the Testgrid hosts". The fetch.py filter change is covered by the live-API field table above; CI runs the full build-test suite (AGENTS.md is outside the workflows' .claude/** paths-ignore).

Does this PR introduce a user-facing change?

NONE

Does this PR require documentation?

NONE

… failure-analysis skill

kURL-testgrid #1080 added unified cancel endpoints and host-side
reconciliation, superseding the skip-then-finish two-step and the note
that API cancellation never stops running VMs:

- POST /api/v1/ref/{refId}/cancel and /v1/ref/{refId}/cancel cancel a
  whole run (pending skipped, running finished with cancelled_at) and
  runner hosts delete the VMs/PVCs/PVs/secrets within one 30s
  ReconcileCancelledVMIs loop; GET /v1/instances/cancelled is the
  runner-facing feed.
- Documented how to verify a host's tgrun has the reconcile code, and
  the cases cancel still cannot reach: finished-but-leaked test VMs
  (with the /v1/instance/{id}/status discriminator) and stuck sendlogs
  VMs (reaped only at 8h, Shortcut #140012).
- Added the dispatch-gate diagnostic: a Pending virt-launcher pod
  stops that host's dequeue loop (canScheduleNewVM), which is how
  zombie-VM buildup presents as 'no new tests getting scheduled'.
@xavpaice
xavpaice requested a review from a team as a code owner October 16, 2026 01:31
@xavpaice xavpaice added the type::docs Improvements or additions to documentation label Oct 16, 2026
@doomer-ai

doomer-ai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Doomer review
Review completed.

Doomer review: View on doomer.ai

Automatic approval: Enabled

Cancelled instances (cancelled_at set) are deliberate aborts, not test
failures; since kURL-testgrid#1080 sets cancelled_at on every cancelled
instance, filter them out of fetch.py's failure set and say so in the
skill.

@doomer-ai doomer-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Doomer ran successfully and found no issues.

doomer-ai[bot]
doomer-ai Bot previously approved these changes Oct 16, 2026
…p runbook

kURL-testgrid #1084 (stuck -sendlogs VMIs reaped at 30 minutes) and
- #1087 (sibling VMs reaped 10 minutes after initialprimary completes,
logs shipped first) close the leak paths this section previously sent
operators to clean by hand. Manual deletion is now only needed for
hosts on an older tgrun or a finished instance whose initialprimary VM
never stopped.

@doomer-ai doomer-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Doomer ran successfully and found no issues.

doomer-ai[bot]
doomer-ai Bot previously approved these changes Oct 16, 2026
The cancel endpoints and runner-side reconciliation (kURL-testgrid
#1080) plus the testgrid-checker's latest-comment-prefix behavior were
undocumented here; add them to the Testgrid API section.
if not i.get("isSuccess")
and not i.get("isUnsupported")
and not i.get("isSkipped")
and not i.get("cancelledAt") # cancelled instances are not failures

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

If you have the time

Line 111 changes fetch.py behavior, but the PR claims docs-only. List the filter change in the PR body or split it out, and confirm the field name against a live API response before merge.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done — the PR body no longer claims docs-only: it now lists the fetch.py filter change explicitly, including the live-API verification table for cancelledAt (cancelled-running vs cancelled-pending vs success vs failure) pulled from the API just now.

@doomer-ai

doomer-ai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

Review complete. Approval is waiting on 1 unresolved review conversation. Address the comments or explain your disagreement in those conversations. Doomer will check again when they are resolved.

Open the review and findings

Reviewed commit: 30a71dd

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type::docs Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant