Skip to content

Integration tests: wait until stopped ZooKeeper nodes leave the container list before starting them again - #128323

Merged
alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:integration-harness-wait-nodes-stopped
Nov 5, 2026
Merged

alexey-milovidov merged 1 commit into
ClickHouse:masterfrom
groeneai:integration-harness-wait-nodes-stopped

Conversation

@groeneai

@groeneai groeneai commented Oct 30, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #118399
Related: #116044

Changelog category (leave one):

  • CI Fix or Improvement (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

The integration test harness waits until nodes it stopped or killed are no longer listed as running, so a following docker compose start no longer skips one of them.

Description

Requested in #118399. #116044 only reports the failed start; this prevents it.

test_keeper_session_refuse_stale_server fails with Cannot wait ZooKeeper container after kazoo ValueError: bad hostname: one ZooKeeper node is never started again after the test's own restart, so it has no IP. Failing jobs: #118399, arm_binary 3/4, master 509fb368, arm_binary distributed plan 3/4.

Root cause: on the runner's Docker Engine 27.0.3, stop and kill return before GET /containers/json shows the container stopped (moby/moby#50133; Engine 28.3 fixed it for stop only, kill still returns early on current Engines). docker compose start lists the project once and skips every container listed as running. In both jobs the list came ~60 ms after zoo3's stop returned and ~100 ms before its stopped state was published, so zoo3 got no POST /start and compose still exited 0. #109037 made the restart one compose call; that did not help, because the skip comes from the stale list.

Change: wait_integration_nodes_stopped polls that same list (bounded, 30 s, raises with the names) after stop_zookeeper_nodes and after process_integration_nodes stop/kill. When the list is already current, it is one list call.

Validation: in the CI runner image (Docker 27.0.3, compose 2.29.7) with fsync delay injected into the nested dockerd, the real harness methods failed 17/20 (stop) and 19/20 (single-node kill) before, 0/20 and 0/20 after; disabling the wait brings it back (19/20). The affected tests pass locally.

Upgrading docker-ce in the runner image to >= 28.3 would fix the stop path seen here, but not kill, so the wait stays useful after such an upgrade.


Workflow [PR]
Sync PR [sync-upstream/pr/128323]

Version info

  • Merged into: 26.11.1.1398-master (included in 26.11 and later)

…restarting them

`test_keeper_session_refuse_stale_server` failed with `Cannot wait ZooKeeper
container` (kazoo `ValueError: bad hostname`): after the test's own restart one
ZooKeeper node was never started again and had no IP.

On Docker Engine 27.0.3 (the integration runner image), `stop` and `kill`
return when the exit handler marks the container stopped, but the handler
publishes that state to the view behind `GET /containers/json` only after two
fsync'd config writes (moby/moby#50133, fixed in Engine 28.3).
`docker compose start` lists the project once and skips every container listed
as running, so when its list lands in that gap the last-stopped node gets no
`POST /start` and compose still exits 0. Measured in two CI jobs: the list came
~60 ms after zoo3's stop returned and ~100 ms before its stopped state was
visible. ClickHouse#109037 made the restart a single compose call, which did not help:
the skip comes from the stale list, not from concurrent compose commands.

`wait_integration_nodes_stopped` polls that same list (the project label, the
`State` field compose checks) after `stop_zookeeper_nodes` and after
`process_integration_nodes` stop/kill, and raises with the container names if
they are still listed as running after 30 s. Inspect is not used as the oracle
because it takes the container lock and reports `exited` before the list does.
On a fixed Engine the wait is one list call.

Validated in the CI runner image (Docker 27.0.3, compose 2.29.7) as a nested
dockerd with an fsync delay injected: the real harness methods failed 17/20
(stop) and 19/20 (single-node kill) before, 0/20 and 0/20 after, and 19/20 again
with the wait disabled.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review: adjudication log (click to expand)

Pre-publication review by an independent model (engine: codex; 2 runs, 2 findings) plus my own review (2 findings). No blocker or major.

# Sev Finding Verdict Evidence / action
1 💡 The comment scopes the race to Engine < 28.3 for both stop and kill (cluster.py, wait_integration_nodes_stopped) AGREE moby PR #50136 fixed only daemon/stop.go; kill still returns before the list update on current Engines. Description corrected; noted, code comment unchanged.
2 💡 Related PR links were hidden inside the template's HTML comment AGREE Visible full-URL Related: lines added.
3 💡 The pre-existing comment in process_integration_nodes still blames concurrent compose calls AGREE, noted Outside this diff; left as is.

Severity: ❌ blocker / ⚠️ major / 💡 nit.

Session id: cron:clickhouse-review-slot-8:20261030-231100

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @leshikus, could you review this and add the can be tested label so CI runs? On the runner's Docker 27.0.3, stop/kill return before GET /containers/json shows the container stopped, so the next docker compose start skips the last-stopped node; the harness now waits on that list after its own stop/kill.

@clickhouse-gh

clickhouse-gh Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [927b3db]

Summary: ✅


AI Review

Summary

This PR waits until Docker's container list stops reporting the requested ZooKeeper/Keeper nodes as running after stop or kill, preventing a subsequent docker compose start from silently skipping them. Reviewed head 927b3db8e3e5caff7146239b847a426e3359dc4e, the full diff, affected callers, and all prior discussion. No actionable findings.

Missing context / blind spots
  • ⚠️ Targeted integration CI was still running at review time. Regression evidence comes from the PR's reported Docker 27.0.3 fault-injection runs, including the disabled-wait negative control; these were not independently repeated. The completed CI result would provide independent validation.
Final Verdict

✅ Approve — no changes requested.

@clickhouse-gh clickhouse-gh Bot added pr-ci comp-testing Test content only (no production code). labels Oct 30, 2026
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 31, 2026
@alexey-milovidov alexey-milovidov self-assigned this Nov 5, 2026
@alexey-milovidov
alexey-milovidov added this pull request to the merge queue Nov 5, 2026
Merged via the queue into ClickHouse:master with commit 88c7325 Nov 5, 2026
529 of 531 checks passed
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-synced-to-cloud The PR is synced to the cloud repo label Nov 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-testing Test content only (no production code). pr-ci pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants