summaryrefslogtreecommitdiff
path: root/pkg/rootlessport
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2021-09-13 16:25:05 +0200
committerPaul Holzinger <pholzing@redhat.com>2021-09-13 16:45:55 +0200
commit32424d9a9be09be3887fec903d960c87f5aedf28 (patch)
treeb7dd25346a1b5494b7bd06dff82eb1f43ca26b28 /pkg/rootlessport
parent0f3d3bd21da0b67542c44c832f0e1642c5f639cf (diff)
downloadpodman-32424d9a9be09be3887fec903d960c87f5aedf28.tar.gz
podman-32424d9a9be09be3887fec903d960c87f5aedf28.tar.bz2
podman-32424d9a9be09be3887fec903d960c87f5aedf28.zip
remove rootlessport socket to prevent EADDRINUSE
When we restart a container via podman restart or restart policy the rootlessport process fails with `address already in use` because the socketfile still exists. This is a regression and was introduced in commit abdedc31a25e. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'pkg/rootlessport')
-rw-r--r--pkg/rootlessport/rootlessport_linux.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/pkg/rootlessport/rootlessport_linux.go b/pkg/rootlessport/rootlessport_linux.go
index 730d91aa2..10d135e0b 100644
--- a/pkg/rootlessport/rootlessport_linux.go
+++ b/pkg/rootlessport/rootlessport_linux.go
@@ -218,6 +218,9 @@ outer:
// we only need to have a socket to reload ports when we run under rootless cni
if cfg.RootlessCNI {
+ socketfile := filepath.Join(socketDir, cfg.ContainerID)
+ // make sure to remove the file if it exists to prevent EADDRINUSE
+ _ = os.Remove(socketfile)
// 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)
@@ -229,6 +232,8 @@ outer:
return err
}
err = unix.Close(fd)
+ // remove the socket file on exit
+ defer os.Remove(socketfile)
if err != nil {
logrus.Warnf("failed to close the socketDir fd: %v", err)
}