Skip to content

test: extend EnsureContainerExited deadline to fix flaky restart tests#5044

Merged
ktock merged 1 commit into
containerd:mainfrom
AkihiroSuda:fix-5030
Jul 7, 2026
Merged

test: extend EnsureContainerExited deadline to fix flaky restart tests#5044
ktock merged 1 commit into
containerd:mainfrom
AkihiroSuda:fix-5030

Conversation

@AkihiroSuda

Copy link
Copy Markdown
Member

TestRunRestartWithOnFailure runs a container with --restart=on-failure:2 and then uses nerdtest.EnsureContainerExited to wait for the container to reach the "exited" state.

However, a stopped container whose restart labels still satisfy restart.Reconcile() is reported by nerdctl as "restarting", not "exited" (see dockercompat.statusFromNative). For on-failure:2, this means the container only shows "exited" after the containerd restart monitor has performed both restarts and bumped the restart count label to 2. Since the monitor only reconciles every 10 seconds by default, convergence takes ~20+ seconds in the worst case - right at (or beyond) the ~20 seconds budget of EnsureContainerExited (20 retries x 1s sleep), especially on slow CI runners. This is the source of the observed "container ... still not exited after 20 retries" flake.

Replace the retry counter with a 60-second deadline (keeping the 1-second poll interval), matching the wait budget already used by TestRunRestartWithUnlessStopped. This also covers TestUpdateRestartPolicy, which calls the same helper with an on-failure:2 policy. Passing runs are not slowed down, as the loop still exits on the first observation of the exited state.

Fixes #5030

Assisted-by: Claude Fable 5 noreply@anthropic.com

TestRunRestartWithOnFailure runs a container with --restart=on-failure:2
and then uses nerdtest.EnsureContainerExited to wait for the container to
reach the "exited" state.

However, a stopped container whose restart labels still satisfy
restart.Reconcile() is reported by nerdctl as "restarting", not
"exited" (see dockercompat.statusFromNative). For on-failure:2, this
means the container only shows "exited" after the containerd restart
monitor has performed both restarts and bumped the restart count label
to 2. Since the monitor only reconciles every 10 seconds by default,
convergence takes ~20+ seconds in the worst case - right at (or beyond)
the ~20 seconds budget of EnsureContainerExited (20 retries x 1s sleep),
especially on slow CI runners. This is the source of the observed
"container ... still not exited after 20 retries" flake.

Replace the retry counter with a 60-second deadline (keeping the
1-second poll interval), matching the wait budget already used by
TestRunRestartWithUnlessStopped. This also covers TestUpdateRestartPolicy,
which calls the same helper with an on-failure:2 policy. Passing runs are
not slowed down, as the loop still exits on the first observation of the
exited state.

Fixes containerd#5030

Assisted-by: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
@AkihiroSuda AkihiroSuda added the area/ci e.g., CI failure label Jul 5, 2026
@AkihiroSuda AkihiroSuda added this to the v2.4.0 milestone Jul 6, 2026
@AkihiroSuda AkihiroSuda marked this pull request as ready for review July 6, 2026 04:26
@AkihiroSuda AkihiroSuda requested a review from ktock July 7, 2026 00:58
@ktock ktock merged commit 18beac5 into containerd:main Jul 7, 2026
50 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci e.g., CI failure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: TestRunRestartWithOnFailure (specific to containerd v1.7? or Ubuntu 22.04 host?)

3 participants