From c6be71486d4357cb3cbb380e846e32780fcb37f5 Mon Sep 17 00:00:00 2001 From: Aditya Rajan Date: Thu, 30 Sep 2021 15:45:32 +0530 Subject: machine: silently cleanup dangling sockets before rm if possible Try to cleanup dandling pid and machine socket if possible silently before `rm`. [NO TESTS NEEDED] Signed-off-by: Aditya Rajan --- pkg/machine/qemu/machine.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'pkg/machine') diff --git a/pkg/machine/qemu/machine.go b/pkg/machine/qemu/machine.go index d0f48da5f..03197fef1 100644 --- a/pkg/machine/qemu/machine.go +++ b/pkg/machine/qemu/machine.go @@ -460,6 +460,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 { -- cgit v1.2.3-54-g00ecf From b5dd62f31558caeb3c8cb4b83c0563db9f07cf20 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 14 Oct 2021 10:24:02 -0400 Subject: Don't use docker/pkg/archive, use containers/storage/pkg/archive [NO NEW TESTS NEEDED] Signed-off-by: Daniel J Walsh --- cmd/podman/diff/diff.go | 2 +- libpod/container_copy_linux.go | 2 +- pkg/machine/pull.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'pkg/machine') diff --git a/cmd/podman/diff/diff.go b/cmd/podman/diff/diff.go index 81bbb6c43..fba4ea540 100644 --- a/cmd/podman/diff/diff.go +++ b/cmd/podman/diff/diff.go @@ -8,7 +8,7 @@ import ( "github.com/containers/common/pkg/report" "github.com/containers/podman/v3/cmd/podman/registry" "github.com/containers/podman/v3/pkg/domain/entities" - "github.com/docker/docker/pkg/archive" + "github.com/containers/storage/pkg/archive" "github.com/pkg/errors" "github.com/spf13/cobra" ) diff --git a/libpod/container_copy_linux.go b/libpod/container_copy_linux.go index 7d4dd0d46..954d54a1d 100644 --- a/libpod/container_copy_linux.go +++ b/libpod/container_copy_linux.go @@ -15,8 +15,8 @@ import ( "github.com/containers/buildah/util" "github.com/containers/podman/v3/libpod/define" "github.com/containers/podman/v3/pkg/rootless" + "github.com/containers/storage/pkg/archive" "github.com/containers/storage/pkg/idtools" - "github.com/docker/docker/pkg/archive" "github.com/opencontainers/runtime-spec/specs-go" "github.com/pkg/errors" "github.com/sirupsen/logrus" diff --git a/pkg/machine/pull.go b/pkg/machine/pull.go index f79ac6ec4..3c8422a30 100644 --- a/pkg/machine/pull.go +++ b/pkg/machine/pull.go @@ -15,7 +15,7 @@ import ( "time" "github.com/containers/image/v5/pkg/compression" - "github.com/docker/docker/pkg/archive" + "github.com/containers/storage/pkg/archive" "github.com/sirupsen/logrus" "github.com/vbauerster/mpb/v6" "github.com/vbauerster/mpb/v6/decor" -- cgit v1.2.3-54-g00ecf