mirror of
https://github.com/containers/podman.git
synced 2025-06-20 00:51:16 +08:00
Merge pull request #11802 from flouthoc/podman-machine-rm-cleanup
machine: silently cleanup dangling sockets before `rm` if possible
This commit is contained in:
@ -465,6 +465,22 @@ func (v *MachineVM) Remove(name string, opts machine.RemoveOptions) (string, fun
|
|||||||
for _, msg := range files {
|
for _, msg := range files {
|
||||||
confirmationMessage += msg + "\n"
|
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"
|
confirmationMessage += "\n"
|
||||||
return confirmationMessage, func() error {
|
return confirmationMessage, func() error {
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
|
Reference in New Issue
Block a user