Skip to content

testing: cozytest.sh arms cluster captures on unit-suite failures, turning a fast red into ~15 minutes of dead waits #3626

Description

Summary

hack/cozytest.sh arms its cluster-capture EXIT trap for every hack/*.bats file it runs, including purely local unit suites. The gates inside the trap are command -v kubectl and the capture script being executable (hack/cozytest.sh:110, :166), not "is there a cluster to talk to". On a runner that has a kubectl binary and no cluster, the first failing unit test therefore does not fail fast: the trap walks into the previous-logs capture under a timeout -k 30 300 and the dataplane capture under a timeout -k 30 600, so a red that should cost seconds can cost up to ~15 minutes of dead waits inside a 30-minute job budget.

Mechanism

The trap at :177 fires on the first failing test (the runner exits on first failure by design). Each capture is individually bounded, which is correct for the e2e context they were written for, but the bound is the failure mode here: kubectl exists on the unit runners, every API call it makes hangs or fails slowly against nothing, and the timeouts serially add up. The captures read state that does not exist for a unit suite, so the cost buys an empty snapshot.

Fix shape

Gate the trap on the context rather than on binary presence: arm the cluster captures only when an e2e marker is present (an env the e2e workflow sets, or a reachable API server probed with a short --request-timeout), and let unit suites die with plain output. The per-capture bounds stay as they are for the e2e path.

Activity

  1. added
    kind/bugCategorizes issue or PR as related to a bug
    area/ciIssues or PRs related to CI workflows, GitHub Actions, automation
    area/testingIssues or PRs related to testing (e2e, bats, unit tests)
    on Aug 7, 2026
  2. lexfrei commented on Aug 8, 2026

    @lexfrei
    ContributorAuthor

    Correcting the cost estimate in the description, measured with a kubectl stub that hangs instead of refusing. e2e-capture-previous-logs.sh never reaches the 300s outer cap: it self-limits its pod listing (PREVLOG_LIST_TIMEOUT=28) and exits 0 after about 28s. e2e-capture-dataplane.sh does run its full 600s, killed by the outer bound on its first unbounded kubectl get pods -A. So the realistic worst case on a runner without a cluster is about 10 minutes, not 15, plus the 360s crust-gather leg where that tool is installed.

    The measurement also explains why this survived so long: the cost depends on whether kubectl fails or hangs. On a laptop with no kubeconfig context it refuses instantly and the whole trap costs about a second, so the defect is invisible locally. It only bites where the context points at an endpoint that accepts the connection and stalls, which is exactly the CI-runner shape.

    The dataplane script's unbounded calls are now tracked separately in #3642.

  3. lexfrei commented on Sep 23, 2026

    @lexfrei
    ContributorAuthor

    Fixed by #3645. hack/cozytest.sh only arms the cluster captures for e2e suites now, so a failing unit suite doesn't walk into their timeouts.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ciIssues or PRs related to CI workflows, GitHub Actions, automationarea/testingIssues or PRs related to testing (e2e, bats, unit tests)kind/bugCategorizes issue or PR as related to a bugtriage/not-reproducibleIndicates an issue can not be reproduced as described

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions