mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
Merge pull request #23271 from giuseppe/drop-unmount-for-overlay-storage
test: podman system service doesn't leak mount on termination
This commit is contained in:
@ -16,6 +16,7 @@ import (
|
||||
"github.com/containers/podman/v5/cmd/podman/registry"
|
||||
"github.com/containers/podman/v5/cmd/podman/validate"
|
||||
"github.com/containers/podman/v5/libpod/define"
|
||||
"github.com/containers/podman/v5/libpod/shutdown"
|
||||
"github.com/containers/podman/v5/pkg/bindings"
|
||||
"github.com/containers/podman/v5/pkg/checkpoint/crutils"
|
||||
"github.com/containers/podman/v5/pkg/domain/entities"
|
||||
@ -124,9 +125,11 @@ func Execute() {
|
||||
fmt.Fprintln(os.Stderr, formatError(err))
|
||||
}
|
||||
|
||||
_ = shutdown.Stop()
|
||||
|
||||
if requireCleanup {
|
||||
// The cobra post-run is not being executed in case of
|
||||
// a previous error , so make sure that the engine(s)
|
||||
// a previous error, so make sure that the engine(s)
|
||||
// are correctly shutdown.
|
||||
//
|
||||
// See https://github.com/spf13/cobra/issues/914
|
||||
|
@ -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
|
||||
|
@ -91,6 +91,11 @@ func Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// if the signal handler is running, wait that it terminates
|
||||
handlerLock.Lock()
|
||||
defer handlerLock.Unlock()
|
||||
// it doesn't need to be in the critical section, but staticcheck complains if
|
||||
// the critical section is empty.
|
||||
cancelChan <- true
|
||||
|
||||
return nil
|
||||
|
@ -33,7 +33,6 @@ import (
|
||||
. "github.com/onsi/gomega"
|
||||
. "github.com/onsi/gomega/gexec"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -1057,16 +1056,6 @@ func rmAll(podmanBin string, path string) {
|
||||
GinkgoWriter.Printf("%v\n", err)
|
||||
}
|
||||
} else {
|
||||
// When using overlay as root, podman leaves a stray mount behind.
|
||||
// This leak causes remote tests to take a loooooong time, which
|
||||
// then causes Cirrus to time out. Unmount that stray.
|
||||
overlayPath := path + "/root/overlay"
|
||||
if _, err := os.Stat(overlayPath); err == nil {
|
||||
if err = unix.Unmount(overlayPath, unix.MNT_DETACH); err != nil {
|
||||
GinkgoWriter.Printf("Error unmounting %s: %v\n", overlayPath, err)
|
||||
}
|
||||
}
|
||||
|
||||
if err = os.RemoveAll(path); err != nil {
|
||||
GinkgoWriter.Printf("%q\n", err)
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ func (p *PodmanTestIntegration) StartRemoteService() {
|
||||
}
|
||||
|
||||
func (p *PodmanTestIntegration) StopRemoteService() {
|
||||
if err := p.RemoteSession.Kill(); err != nil {
|
||||
if err := p.RemoteSession.Signal(syscall.SIGTERM); err != nil {
|
||||
GinkgoWriter.Printf("unable to clean up service %d, %v\n", p.RemoteSession.Pid, err)
|
||||
}
|
||||
if _, err := p.RemoteSession.Wait(); err != nil {
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user