Skip to content

Commit 479ea02

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

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

cmd/nerdctl/container/container_logs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ bar
5353
}
5454

5555
testCase.Setup = func(data test.Data, helpers test.Helpers) {
56-
helpers.Ensure("run", "--quiet", "--name", data.Identifier(), testutil.CommonImage, "sh", "-euxc", "echo foo; echo bar;")
56+
helpers.Ensure("run", "--quiet", "--name", data.Identifier(), testutil.CommonImage, "sh", "-euc", "echo foo; echo bar;")
5757
data.Labels().Set("cID", data.Identifier())
5858
}
5959

cmd/nerdctl/container/container_run_systemd_linux_test.go

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ func TestRunWithSystemdTrueEnabled(t *testing.T) {
7070
testCase.Require = require.All(
7171
require.Amd64,
7272
require.Not(nerdtest.Docker),
73+
// // runc exec can permanently fail with "exec: already started" (https://github.com/opencontainers/runc/issues/4437)
74+
// nerdtest.IsFlaky("https://github.com/opencontainers/runc/issues/4437"),
7375
)
7476

7577
testCase.Setup = func(data test.Data, helpers test.Helpers) {
@@ -89,18 +91,11 @@ func TestRunWithSystemdTrueEnabled(t *testing.T) {
8991
Output: expect.Contains("SIGRTMIN+3"),
9092
})
9193

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`)
94+
helpers.Command("exec", data.Identifier(), "sh", "-c", "--", "ps").Run(&test.Expected{
95+
ExitCode: expect.ExitCodeSuccess,
96+
})
97+
98+
return helpers.Command("exec", data.Identifier(), "sh", "-c", "--", "systemctl list-jobs")
10499
}
105100

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

0 commit comments

Comments
 (0)