Skip to content

Commit 67601c4

Browse files
committed
Update systemd logic, cleanup redundancy
Signed-off-by: Arjun Raja Yogidas <[email protected]>
1 parent 59253e9 commit 67601c4

File tree

9 files changed

+306
-143
lines changed

9 files changed

+306
-143
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ RUN apt-get update -qq && apt-get install -qq -y --no-install-recommends \
286286
bash-completion \
287287
ca-certificates curl \
288288
iproute2 iptables \
289-
dbus dbus-user-session systemd systemd-sysv \
289+
dbus dbus-user-session dbus-x11 systemd systemd-sysv \
290290
fuse3
291291
COPY --from=build-full /docker-entrypoint.sh /docker-entrypoint.sh
292292
COPY --from=out-full / /usr/local/

cmd/nerdctl/container/container_health_check_linux_test.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
"github.com/containerd/nerdctl/mod/tigron/tig"
3333

3434
"github.com/containerd/nerdctl/v2/pkg/healthcheck"
35-
"github.com/containerd/nerdctl/v2/pkg/rootlessutil"
3635
"github.com/containerd/nerdctl/v2/pkg/testutil"
3736
"github.com/containerd/nerdctl/v2/pkg/testutil/nerdtest"
3837
)
@@ -44,9 +43,9 @@ func TestContainerHealthCheckBasic(t *testing.T) {
4443
testCase.Require = require.Not(nerdtest.Docker)
4544

4645
// Skip systemd tests in rootless environment to bypass dbus permission issues
47-
if rootlessutil.IsRootless() {
48-
t.Skip("systemd healthcheck tests are skipped in rootless environment")
49-
}
46+
// if rootlessutil.IsRootless() {
47+
// t.Skip("systemd healthcheck tests are skipped in rootless environment")
48+
// }
5049

5150
testCase.SubTests = []*test.Case{
5251
{
@@ -146,9 +145,9 @@ func TestContainerHealthCheckAdvance(t *testing.T) {
146145
testCase.Require = require.Not(nerdtest.Docker)
147146

148147
// Skip systemd tests in rootless environment to bypass dbus permission issues
149-
if rootlessutil.IsRootless() {
150-
t.Skip("systemd healthcheck tests are skipped in rootless environment")
151-
}
148+
// if rootlessutil.IsRootless() {
149+
// t.Skip("systemd healthcheck tests are skipped in rootless environment")
150+
// }
152151

153152
testCase.SubTests = []*test.Case{
154153
{
@@ -618,9 +617,9 @@ func TestHealthCheck_SystemdIntegration_Basic(t *testing.T) {
618617
testCase := nerdtest.Setup()
619618
testCase.Require = require.Not(nerdtest.Docker)
620619
// Skip systemd tests in rootless environment to bypass dbus permission issues
621-
if rootlessutil.IsRootless() {
622-
t.Skip("systemd healthcheck tests are skipped in rootless environment")
623-
}
620+
// if rootlessutil.IsRootless() {
621+
// t.Skip("systemd healthcheck tests are skipped in rootless environment")
622+
// }
624623

625624
testCase.SubTests = []*test.Case{
626625
{
@@ -802,9 +801,9 @@ func TestHealthCheck_SystemdIntegration_Advanced(t *testing.T) {
802801
testCase := nerdtest.Setup()
803802
testCase.Require = require.Not(nerdtest.Docker)
804803
// Skip systemd tests in rootless environment to bypass dbus permission issues
805-
if rootlessutil.IsRootless() {
806-
t.Skip("systemd healthcheck tests are skipped in rootless environment")
807-
}
804+
// if rootlessutil.IsRootless() {
805+
// t.Skip("systemd healthcheck tests are skipped in rootless environment")
806+
// }
808807

809808
testCase.SubTests = []*test.Case{
810809
{

cmd/nerdctl/container/container_run.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,9 @@ func runAction(cmd *cobra.Command, args []string) error {
447447
}
448448

449449
// Setup container healthchecks.
450-
if err := healthcheck.CreateTimer(ctx, c, (*config.Config)(&createOpt.GOptions)); err != nil {
450+
if err := healthcheck.CreateAndStartTimer(ctx, c, (*config.Config)(&createOpt.GOptions)); err != nil {
451451
return fmt.Errorf("failed to create healthcheck timer: %w", err)
452452
}
453-
if err := healthcheck.StartTimer(ctx, c, (*config.Config)(&createOpt.GOptions)); err != nil {
454-
return fmt.Errorf("failed to start healthcheck timer: %w", err)
455-
}
456453

457454
if createOpt.Detach {
458455
fmt.Fprintln(createOpt.Stdout, id)

hack/test-integration.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ for arg in "$@"; do
5050
done
5151

5252
if [ "$needsudo" == "true" ] || [ "$needsudo" == "yes" ] || [ "$needsudo" == "1" ]; then
53-
gotestsum "${args[@]}" -- -timeout="$timeout" -p 1 -exec sudo -args -test.allow-kill-daemon "$@"
53+
gotestsum "${args[@]}" -- -timeout="$timeout" -p 1 -exec sudo -v -run TestHealthCheck_SystemdIntegration_Advanced -args -test.allow-kill-daemon ./cmd/nerdctl/container/
5454
else
55-
gotestsum "${args[@]}" -- -timeout="$timeout" -p 1 -args -test.allow-kill-daemon "$@"
55+
gotestsum "${args[@]}" -- -timeout="$timeout" -p 1 -v -run TestHealthCheck_SystemdIntegration_Advanced -args -test.allow-kill-daemon ./cmd/nerdctl/container/
5656
fi

pkg/containerutil/containerutil.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,9 @@ func Start(ctx context.Context, container containerd.Container, isAttach bool, i
293293
}
294294

295295
// If container has health checks configured, create and start systemd timer/service files.
296-
if err := healthcheck.CreateTimer(ctx, container, cfg); err != nil {
296+
if err := healthcheck.CreateAndStartTimer(ctx, container, cfg); err != nil {
297297
return fmt.Errorf("failed to create healthcheck timer: %w", err)
298298
}
299-
if err := healthcheck.StartTimer(ctx, container, cfg); err != nil {
300-
return fmt.Errorf("failed to start healthcheck timer: %w", err)
301-
}
302299

303300
if !isAttach {
304301
return nil
@@ -532,12 +529,9 @@ func Unpause(ctx context.Context, client *containerd.Client, id string, cfg *con
532529
}
533530

534531
// Recreate healthcheck related systemd timer/service files.
535-
if err := healthcheck.CreateTimer(ctx, container, cfg); err != nil {
532+
if err := healthcheck.CreateAndStartTimer(ctx, container, cfg); err != nil {
536533
return fmt.Errorf("failed to create healthcheck timer: %w", err)
537534
}
538-
if err := healthcheck.StartTimer(ctx, container, cfg); err != nil {
539-
return fmt.Errorf("failed to start healthcheck timer: %w", err)
540-
}
541535

542536
switch status.Status {
543537
case containerd.Paused:

pkg/healthcheck/healthcheck_manager_darwin.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ func CreateTimer(ctx context.Context, container containerd.Container, cfg *confi
2929
return nil
3030
}
3131

32+
// CreateAndStartTimer sets up the transient systemd timer and service for healthchecks.
33+
func CreateAndStartTimer(ctx context.Context, container containerd.Container, cfg *config.Config) error {
34+
return nil
35+
}
36+
3237
// StartTimer starts the healthcheck timer unit.
3338
func StartTimer(ctx context.Context, container containerd.Container, cfg *config.Config) error {
3439
return nil

pkg/healthcheck/healthcheck_manager_freebsd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ func StartTimer(ctx context.Context, container containerd.Container, cfg *config
3434
return nil
3535
}
3636

37+
// CreateAndStartTimer sets up the transient systemd timer and service for healthchecks.
38+
func CreateAndStartTimer(ctx context.Context, container containerd.Container, cfg *config.Config) error {
39+
return nil
40+
}
41+
3742
// RemoveTransientHealthCheckFiles stops and cleans up the transient timer and service.
3843
func RemoveTransientHealthCheckFiles(ctx context.Context, container containerd.Container) error {
3944
return nil

0 commit comments

Comments
 (0)