libpod: cleanup store at shutdown

shutdown the containers store so that the home directory mount is not
leaked when "podman system service" exits.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2024-07-14 19:44:18 +02:00
parent 317a88ee4e
commit 6832a35f65
No known key found for this signature in database
GPG Key ID: 67E38F7A8BA21772
2 changed files with 8 additions and 5 deletions

View File

@ -210,7 +210,14 @@ func newRuntimeFromConfig(ctx context.Context, conf *config.Config, options ...R
}
}
if err := makeRuntime(ctx, runtime); err != nil {
return nil, err
}
if err := shutdown.Register("libpod", func(sig os.Signal) error {
if runtime.store != nil {
_, _ = runtime.store.Shutdown(false)
}
// For `systemctl stop podman.service` support, exit code should be 0
if sig == syscall.SIGTERM {
os.Exit(0)
@ -225,10 +232,6 @@ func newRuntimeFromConfig(ctx context.Context, conf *config.Config, options ...R
return nil, fmt.Errorf("starting shutdown signal handler: %w", err)
}
if err := makeRuntime(ctx, runtime); err != nil {
return nil, err
}
runtime.config.CheckCgroupsAndAdjustConfig()
return runtime, nil

View File

@ -277,7 +277,7 @@ run_podman --noout system connection ls
run_podman --log-level=debug run --rm $IMAGE true
is "$output" ".*Shutting down engines.*"
run_podman 125 --log-level=debug run dockah://rien.de/rien:latest
is "${lines[-1]}" ".*Shutting down engines"
is "$output" ".*Shutting down engines.*"
}
# vim: filetype=sh