Skip to content

e2e: add flannel resilience/recovery tests - #2538

Merged
thomasferrandiz merged 3 commits into
masterfrom
thomasferrandiz-e2e-resilience-tests
Aug 14, 2026
Merged

thomasferrandiz merged 3 commits into
masterfrom
thomasferrandiz-e2e-resilience-tests

Conversation

@thomasferrandiz

Copy link
Copy Markdown
Contributor

What this covers

Adds a new spec e2e/resilience_test.go to the kind-based e2e suite (e2e build tag) that exercises flannel's recovery paths. It runs on a single cheap backend — vxlan with iptables — against the shared kind cluster, installed once in BeforeAll via the existing prepareTest helper and torn down in AfterAll with deleteFlannel.

Scenarios

  1. Pod restart recovery — creates two multitool pods on separate nodes, verifies cross-node ping, then deletes and recreates one pod on the same node. Asserts connectivity recovers with the pod's new IP (re-read via podIP), proving flannel re-wires a new pod/veth and re-allocates within the node subnet.

  2. Flannel DaemonSet rolling restart + subnet lease persistence — captures each node's FLANNEL_SUBNET line from /run/flannel/subnet.env before restarting kube-flannel-ds (rollout restart via a kubectl.kubernetes.io/restartedAt annotation patch on the typed AppsV1 client). After waitForFlannelRollout + waitForSubnetEnv, it asserts the FLANNEL_SUBNET line is unchanged (leases stable across a flanneld restart) and that pod-to-pod connectivity still works.

Helpers added

  • restartFlannelDaemonSet(ctx) on *kindCluster (flannel.go)
  • deletePod(ctx, ns, name) — idempotent, ignores NotFound (kube.go)
  • subnetEnv(ctx, node) + flannelSubnetLine(...) (kube.go)

Reuses existing wait/exec helpers and code style throughout; the backend matrix in connectivity_test.go is untouched.

Design notes

Deliberately avoids full node reboots / docker restart of a kind node — those are too flaky and slow for CI. The pod restart and DaemonSet rolling restart cover the realistic flanneld-recovery paths. Timeouts mirror the durations used elsewhere (rollout up to 5m, ping up to 1m).

Validation

  • gofmt -l e2e — clean
  • go vet -tags e2e ./... — clean

A real kind cluster isn't runnable in this environment (no Docker/kind), so the full suite was not executed; the change compiles and vets cleanly under the e2e build tag.

thomasferrandiz and others added 2 commits August 13, 2026 17:44
Add a new kind-based e2e spec exercising flannel recovery paths on a
single cheap backend (vxlan, iptables) against the shared cluster:

- pod restart recovery: delete and recreate a pod, assert cross-node
  connectivity recovers with the new pod IP/veth.
- flannel DaemonSet rolling restart: restart kube-flannel-ds and assert
  pod-to-pod connectivity still works and /run/flannel/subnet.env leases
  (FLANNEL_SUBNET) are unchanged across the restart.

Adds helpers restartFlannelDaemonSet, deletePod (idempotent), and
subnetEnv. Deliberately avoids full node reboots as too flaky for CI.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Recreate the named test pods before the DaemonSet restart scenario so the ordered resilience specs do not collide with pods left by the previous scenario. Also wait for pod IP assignment before using a pod IP in connectivity checks.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI 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.

Pull request overview

Adds a new kind-based e2e “resilience” spec that exercises flannel recovery behavior (pod recreation and flanneld rolling restart) on the vxlan+iptables backend, and introduces a few helper methods to support those scenarios.

Changes:

  • Added e2e/resilience_test.go with ordered resilience/recovery scenarios for pod restart and DaemonSet rolling restart.
  • Added Kubernetes helper utilities for idempotent pod deletion and reading/parsing /run/flannel/subnet.env.
  • Added a kindCluster helper to trigger a DaemonSet rolling restart via a strategic merge patch.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
e2e/resilience_test.go New ordered resilience suite validating connectivity recovery and subnet lease stability across flannel restarts.
e2e/kube.go Adds helpers for deleting a pod, reading subnet.env, extracting FLANNEL_SUBNET, and makes pod IP retrieval wait until assigned.
e2e/flannel.go Adds restartFlannelDaemonSet helper to trigger a rolling restart of kube-flannel-ds.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread e2e/resilience_test.go Resolved
Comment thread e2e/resilience_test.go Resolved
- AfterAll now deletes the test pods it created (not just flannel) so the
  shared cluster is genuinely left clean for later specs.
- Reword the recreated-pod comment to focus on connectivity recovery and
  re-wiring; host-local IPAM may legally reuse a freed IP, so the test
  does not require a new address.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@thomasferrandiz
thomasferrandiz merged commit 28d6cc9 into master Aug 14, 2026
11 checks passed
thomasferrandiz pushed a commit that referenced this pull request Aug 27, 2026
#2538 and #2537 each added a kindCluster.deletePod helper. Both changes
merged cleanly, but together they leave the e2e package with duplicate
method definitions.

Keep the version from #2538 because its resilience callers recreate pods
under the same names immediately and need deletion to finish first. The
service/DNS cleanup can use the same stronger helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants