summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/domain/infra/abi/containers.go16
-rw-r--r--pkg/rootlessport/rootlessport_linux.go12
-rw-r--r--pkg/systemd/generate/containers.go2
3 files changed, 22 insertions, 8 deletions
diff --git a/pkg/domain/infra/abi/containers.go b/pkg/domain/infra/abi/containers.go
index 8b2a5bfae..ff34ec86b 100644
--- a/pkg/domain/infra/abi/containers.go
+++ b/pkg/domain/infra/abi/containers.go
@@ -173,13 +173,17 @@ func (ic *ContainerEngine) ContainerStop(ctx context.Context, namesOrIds []strin
return err
}
}
- if c.AutoRemove() {
- // Issue #7384: if the container is configured for
- // auto-removal, it might already have been removed at
- // this point.
- return nil
+ err = c.Cleanup(ctx)
+ if err != nil {
+ // Issue #7384 and #11384: If the container is configured for
+ // auto-removal, it might already have been removed at this point.
+ // We still need to to cleanup since we do not know if the other cleanup process is successful
+ if c.AutoRemove() && (errors.Is(err, define.ErrNoSuchCtr) || errors.Is(err, define.ErrCtrRemoved)) {
+ return nil
+ }
+ return err
}
- return c.Cleanup(ctx)
+ return nil
})
if err != nil {
return nil, err
diff --git a/pkg/rootlessport/rootlessport_linux.go b/pkg/rootlessport/rootlessport_linux.go
index 9a2f93f8e..730d91aa2 100644
--- a/pkg/rootlessport/rootlessport_linux.go
+++ b/pkg/rootlessport/rootlessport_linux.go
@@ -218,10 +218,20 @@ outer:
// we only need to have a socket to reload ports when we run under rootless cni
if cfg.RootlessCNI {
- socket, err := net.Listen("unix", filepath.Join(socketDir, cfg.ContainerID))
+ // workaround to bypass the 108 char socket path limit
+ // open the fd and use the path to the fd as bind argument
+ fd, err := unix.Open(socketDir, unix.O_PATH, 0)
if err != nil {
return err
}
+ socket, err := net.ListenUnix("unixpacket", &net.UnixAddr{Name: fmt.Sprintf("/proc/self/fd/%d/%s", fd, cfg.ContainerID), Net: "unixpacket"})
+ if err != nil {
+ return err
+ }
+ err = unix.Close(fd)
+ if err != nil {
+ logrus.Warnf("failed to close the socketDir fd: %v", err)
+ }
defer socket.Close()
go serve(socket, driver)
}
diff --git a/pkg/systemd/generate/containers.go b/pkg/systemd/generate/containers.go
index 931f13972..188926115 100644
--- a/pkg/systemd/generate/containers.go
+++ b/pkg/systemd/generate/containers.go
@@ -155,7 +155,7 @@ func generateContainerInfo(ctr *libpod.Container, options entities.GenerateSyste
if config.CreateCommand != nil {
createCommand = config.CreateCommand
} else if options.New {
- return nil, errors.Errorf("cannot use --new on container %q: no create command found", ctr.ID())
+ return nil, errors.Errorf("cannot use --new on container %q: no create command found: only works on containers created directly with podman but not via REST API", ctr.ID())
}
nameOrID, serviceName := containerServiceName(ctr, options)