summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-10-01 10:21:13 -0400
committerGitHub <noreply@github.com>2021-10-01 10:21:13 -0400
commit324871d4515de698c97119c2c5d43a26222f48c5 (patch)
tree9565c9ec68a6589d7c5132d38fb02d03ecac8289
parentfedd9cc120cae6cc2df19d49ed916f35fc5f5d71 (diff)
parent642d6829982e299ff5e9b764a5494b9c6668ac5e (diff)
downloadpodman-324871d4515de698c97119c2c5d43a26222f48c5.tar.gz
podman-324871d4515de698c97119c2c5d43a26222f48c5.tar.bz2
podman-324871d4515de698c97119c2c5d43a26222f48c5.zip
Merge pull request #11802 from flouthoc/podman-machine-rm-cleanup
machine: silently cleanup dangling sockets before `rm` if possible
-rw-r--r--pkg/machine/qemu/machine.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go
index c4e6aa611..727b3cda4 100644
--- a/pkg/machine/qemu/machine.go
+++ b/pkg/machine/qemu/machine.go
@@ -465,6 +465,22 @@ func (v *MachineVM) Remove(name string, opts machine.RemoveOptions) (string, fun
for _, msg := range files {
confirmationMessage += msg + "\n"
}
+
+ // Get path to socket and pidFile before we do any cleanups
+ qemuSocketFile, pidFile, errSocketFile := v.getSocketandPid()
+ //silently try to delete socket and pid file
+ //remove socket and pid file if any: warn at low priority if things fail
+ if errSocketFile == nil {
+ // Remove the pidfile
+ if err := os.Remove(pidFile); err != nil && !errors.Is(err, os.ErrNotExist) {
+ logrus.Debugf("Error while removing pidfile: %v", err)
+ }
+ // Remove socket
+ if err := os.Remove(qemuSocketFile); err != nil && !errors.Is(err, os.ErrNotExist) {
+ logrus.Debugf("Error while removing podman-machine-socket: %v", err)
+ }
+ }
+
confirmationMessage += "\n"
return confirmationMessage, func() error {
for _, f := range files {