Skip to content

test(e2e): capture_node writes unprefixed node/nf and can clobber its caller's loop variable #3675

Description

capture_node() in hack/e2e-capture-dataplane.sh assigns node=$1 and nf="$OUT/node-$node.txt" without any prefix or scoping, while its only caller binds node in the loop it runs from:

while IFS='|' read -r ns pod podip node _ready _phase; do
  ...
  capture_node "$node"
  ...
  agent=$(pod_on_node "$CILIUM_NS" k8s-app=cilium "$node")

Harmless today, because the caller passes the same $node it just read, so the write lands on the value already there. It stops being harmless the moment someone calls capture_node with a different node inside that loop: the assignment silently rewrites the loop variable, and the rest of that iteration follows it. Downstream of the call, the rest of the iteration reads $node in its pod lookups (k8s-app=cilium, app=ovs, app=kube-ovn-cni) and in the headers it writes. The cni lookup is the one that hurts: ip route get and conntrack run through that pod, so a swapped node yields another machine's routing and conntrack state, filed under the right pod's name. Nothing fails; the output just describes the wrong node, and reads as if it did not.

The newer code in the same file uses _cpd_ and _cpr_ prefixes for exactly this reason, so this is one of the last spots on the old convention.

Fix: prefix both variables the way the rest of the file does. The script targets POSIX sh, so local is not the tool here.

Pre-existing, not introduced by anything currently in flight.

Activity

  1. added
    kind/cleanupCategorizes issue or PR as related to cleanup of code, process, or technical debt
    area/testingIssues or PRs related to testing (e2e, bats, unit tests)
    triage/acceptedIndicates an issue is ready to be actively worked on
    priority/backlogGeneral backlog priority. Lower than priority/important-longterm
    and removed
    triage/needs-triageIndicates an issue needs triage by a maintainer
    on Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area/testingIssues or PRs related to testing (e2e, bats, unit tests)kind/cleanupCategorizes issue or PR as related to cleanup of code, process, or technical debtpriority/backlogGeneral backlog priority. Lower than priority/important-longtermtriage/acceptedIndicates an issue is ready to be actively worked on

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions