summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-14 10:49:13 -0400
committerGitHub <noreply@github.com>2021-09-14 10:49:13 -0400
commit27ebae9e90d1d3e5a980a786c3ad525c14ebf0d9 (patch)
treedee80dc71b9a8d92e2ed5a40326f822c12b7793d /pkg
parent2b21f1f0464fb06e944c6daf4a482ab2f948d117 (diff)
parentd3f0f09ad94af1d67b4f7baa83036dc851edee18 (diff)
downloadpodman-27ebae9e90d1d3e5a980a786c3ad525c14ebf0d9.tar.gz
podman-27ebae9e90d1d3e5a980a786c3ad525c14ebf0d9.tar.bz2
podman-27ebae9e90d1d3e5a980a786c3ad525c14ebf0d9.zip
Merge pull request #11551 from Luap99/rootlessport-restart
fix restart always with rootlessport
Diffstat (limited to 'pkg')
-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)
}