test: extend EnsureContainerExited deadline to fix flaky restart tests#5044
Merged
Conversation
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>
opjt
approved these changes
Jul 6, 2026
ktock
approved these changes
Jul 7, 2026
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.
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