test(e2e): wait for etcd quorum convergence in k0s multi-cp test - #591
Open
yansun1996 wants to merge 1 commit into
Open
test(e2e): wait for etcd quorum convergence in k0s multi-cp test#591yansun1996 wants to merge 1 commit into
yansun1996 wants to merge 1 commit into
Conversation
The multi-control-plane test asserted a 3-member etcd quorum in a single shot immediately after the cluster reported phase=ready. But `ready` is set once every k0scontroller unit is systemd-active, which precedes the embedded etcd finishing quorum formation, so the assertion intermittently observed etcd mid-join (2 of 3 members) and failed. Add a wait_etcd_members(count, timeout) poller that mirrors wait_k8s_phase and use it in place of the one-shot count. A permanent stall below the target still fails the assertion, so the test keeps its diagnostic value.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces flakiness in the native-host k0s multi-control-plane E2E suite by adding an explicit wait for embedded etcd quorum formation after the cluster reports phase: ready.
Changes:
- Add a
wait_etcd_members(count, timeout=120)polling helper to the E2E cluster harness. - Update the
test_three_control_planes_form_etcd_quorumtest to wait for etcd membership convergence before asserting the quorum size.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| tests/native_host/e2e/test_k8s_multicp.py | Switch etcd quorum assertion to a polling-based wait to avoid mid-join races. |
| tests/native_host/e2e/cluster.py | Introduce wait_etcd_members helper to poll etcd_member_count() until the expected member count is observed or timeout. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #591 +/- ##
==========================================
+ Coverage 76.30% 76.32% +0.02%
==========================================
Files 166 166
Lines 65511 65511
==========================================
+ Hits 49984 49999 +15
+ Misses 15527 15512 -15 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this fixes
The native-k0s multi-control-plane E2E test
test_three_control_planes_form_etcd_quorumis intermittently red in theE2E / native-hostjob:The surrounding CI runs pass, so it's a flaky convergence race, not a regression.
Root cause
The cluster's
phase: readyis set as soon as everyk0scontrollerunit is systemd-active (converge_provisioninggates on each node's component state reported asactive, which is the unit'ssystemctl ActiveState). Systemd-active precedes the embedded etcd finishing quorum formation: a secondary control-plane's unit isactivethe moment the k0s process starts, but its etcd member joins the quorum a short moment later.The test asserted
etcd_member_count() == 3in a single shot immediately afterwait_k8s_phase("ready"), with no settle window, so it could observe etcd mid-join (2 of 3). The failing run's own output confirms this: phaseready, all three control planes assigned, all three controllersactive, but etcd had only 2 members at that instant.This is a test-only timing gap. Marking the cluster ready on unit-active (then self-healing) is reasonable product behavior; etcd quorum is eventually-consistent behind it. Only the test treated the two as synchronous.
Approach
Add a
wait_etcd_members(count, timeout=120)helper to the harness that pollsetcd_member_count()until it reaches the target, mirroring the existingwait_k8s_phasepoller, and use it in place of the one-shot read.The test keeps its diagnostic value: a permanent stall below the target returns the last observed count, so
assert members == 3still fails (with the observed count in the message), and an over-count also fails rather than being masked.How it was tested