Skip to content

Commit fdb76c7

Browse files
fix: Add delay for systemd to startup before running exec
Signed-off-by: Shubhranshu Mahapatra <shubhum@amazon.com>
1 parent e721fde commit fdb76c7

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

cmd/nerdctl/container/container_run_systemd_linux_test.go

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package container
1919
import (
2020
"errors"
2121
"testing"
22+
"time"
2223

2324
"github.com/containerd/nerdctl/mod/tigron/expect"
2425
"github.com/containerd/nerdctl/mod/tigron/require"
@@ -70,11 +71,14 @@ func TestRunWithSystemdTrueEnabled(t *testing.T) {
7071
testCase.Require = require.All(
7172
require.Amd64,
7273
require.Not(nerdtest.Docker),
74+
// // runc exec can permanently fail with "exec: already started" (https://github.com/opencontainers/runc/issues/4437)
75+
// nerdtest.IsFlaky("https://github.com/opencontainers/runc/issues/4437"),
7376
)
7477

7578
testCase.Setup = func(data test.Data, helpers test.Helpers) {
7679
helpers.Ensure("run", "-d", "--name", data.Identifier(), "--systemd=true", "--entrypoint=/sbin/init", testutil.SystemdImage)
7780
nerdtest.EnsureContainerStarted(helpers, data.Identifier())
81+
time.Sleep(10 * time.Second)
7882
}
7983

8084
testCase.Cleanup = func(data test.Data, helpers test.Helpers) {
@@ -89,18 +93,7 @@ func TestRunWithSystemdTrueEnabled(t *testing.T) {
8993
Output: expect.Contains("SIGRTMIN+3"),
9094
})
9195

92-
// waits for systemd to become ready and lists systemd jobs
93-
return helpers.Command("exec", data.Identifier(), "sh", "-c", "--", `tries=0
94-
until systemctl is-system-running >/dev/null 2>&1; do
95-
>&2 printf "Waiting for systemd to come up...\n"
96-
sleep 1s
97-
tries=$(( tries + 1))
98-
[ $tries -lt 10 ] || {
99-
>&2 printf "systemd failed to come up in a reasonable amount of time\n"
100-
exit 1
101-
}
102-
done
103-
systemctl list-jobs`)
96+
return helpers.Command("exec", data.Identifier(), "sh", "-c", "--", "systemctl list-jobs")
10497
}
10598

10699
testCase.Expected = test.Expects(expect.ExitCodeSuccess, nil, expect.Contains("jobs"))

0 commit comments

Comments
 (0)