summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2022-05-04 13:20:09 -0400
committerGitHub <noreply@github.com>2022-05-04 13:20:09 -0400
commitad93318370c8201367ef80042a3c91ff50389e16 (patch)
tree2c4301b7d232e5a895d7463a21b8c2b59cc9fb0a /cmd
parent5c8277d943afdfd62f5713672f389abf2ad8b097 (diff)
parent80744c644135899a6dcc9fbe1b421dc08fc79802 (diff)
downloadpodman-ad93318370c8201367ef80042a3c91ff50389e16.tar.gz
podman-ad93318370c8201367ef80042a3c91ff50389e16.tar.bz2
podman-ad93318370c8201367ef80042a3c91ff50389e16.zip
Merge pull request #14066 from ashley-cui/sysres
podman system reset removed machines incorrectly
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/machine/init.go2
-rw-r--r--cmd/podman/machine/inspect.go2
-rw-r--r--cmd/podman/machine/list.go2
-rw-r--r--cmd/podman/machine/machine.go2
-rw-r--r--cmd/podman/machine/platform.go2
-rw-r--r--cmd/podman/machine/platform_windows.go2
-rw-r--r--cmd/podman/machine/rm.go2
-rw-r--r--cmd/podman/machine/set.go2
-rw-r--r--cmd/podman/machine/ssh.go2
-rw-r--r--cmd/podman/machine/start.go2
-rw-r--r--cmd/podman/machine/stop.go2
-rw-r--r--cmd/podman/system/reset.go10
-rw-r--r--cmd/podman/system/reset_machine.go13
-rw-r--r--cmd/podman/system/reset_machine_unsupported.go8
14 files changed, 41 insertions, 12 deletions
diff --git a/cmd/podman/machine/init.go b/cmd/podman/machine/init.go
index 733266b85..6c31f3531 100644
--- a/cmd/podman/machine/init.go
+++ b/cmd/podman/machine/init.go
@@ -118,7 +118,7 @@ func initMachine(cmd *cobra.Command, args []string) error {
vm machine.VM
)
- provider := getSystemDefaultProvider()
+ provider := GetSystemDefaultProvider()
initOpts.Name = defaultMachineName
if len(args) > 0 {
if len(args[0]) > maxMachineNameSize {
diff --git a/cmd/podman/machine/inspect.go b/cmd/podman/machine/inspect.go
index b8de8e4f4..4600a2b6d 100644
--- a/cmd/podman/machine/inspect.go
+++ b/cmd/podman/machine/inspect.go
@@ -51,7 +51,7 @@ func inspect(cmd *cobra.Command, args []string) error {
args = append(args, defaultMachineName)
}
vms := make([]machine.InspectInfo, 0, len(args))
- provider := getSystemDefaultProvider()
+ provider := GetSystemDefaultProvider()
for _, vmName := range args {
vm, err := provider.LoadVMByName(vmName)
if err != nil {
diff --git a/cmd/podman/machine/list.go b/cmd/podman/machine/list.go
index 861feee07..ef26b7886 100644
--- a/cmd/podman/machine/list.go
+++ b/cmd/podman/machine/list.go
@@ -84,7 +84,7 @@ func list(cmd *cobra.Command, args []string) error {
listFlag.format = "{{.Name}}\n"
}
- provider := getSystemDefaultProvider()
+ provider := GetSystemDefaultProvider()
listResponse, err = provider.List(opts)
if err != nil {
return errors.Wrap(err, "error listing vms")
diff --git a/cmd/podman/machine/machine.go b/cmd/podman/machine/machine.go
index cf7542389..553f1ef7a 100644
--- a/cmd/podman/machine/machine.go
+++ b/cmd/podman/machine/machine.go
@@ -64,7 +64,7 @@ func autocompleteMachine(cmd *cobra.Command, args []string, toComplete string) (
func getMachines(toComplete string) ([]string, cobra.ShellCompDirective) {
suggestions := []string{}
- provider := getSystemDefaultProvider()
+ provider := GetSystemDefaultProvider()
machines, err := provider.List(machine.ListOptions{})
if err != nil {
cobra.CompErrorln(err.Error())
diff --git a/cmd/podman/machine/platform.go b/cmd/podman/machine/platform.go
index 77fec083e..5ba649a48 100644
--- a/cmd/podman/machine/platform.go
+++ b/cmd/podman/machine/platform.go
@@ -8,6 +8,6 @@ import (
"github.com/containers/podman/v4/pkg/machine/qemu"
)
-func getSystemDefaultProvider() machine.Provider {
+func GetSystemDefaultProvider() machine.Provider {
return qemu.GetQemuProvider()
}
diff --git a/cmd/podman/machine/platform_windows.go b/cmd/podman/machine/platform_windows.go
index 03978eda1..cdbc52459 100644
--- a/cmd/podman/machine/platform_windows.go
+++ b/cmd/podman/machine/platform_windows.go
@@ -5,6 +5,6 @@ import (
"github.com/containers/podman/v4/pkg/machine/wsl"
)
-func getSystemDefaultProvider() machine.Provider {
+func GetSystemDefaultProvider() machine.Provider {
return wsl.GetWSLProvider()
}
diff --git a/cmd/podman/machine/rm.go b/cmd/podman/machine/rm.go
index e678eb629..a6e66265c 100644
--- a/cmd/podman/machine/rm.go
+++ b/cmd/podman/machine/rm.go
@@ -61,7 +61,7 @@ func rm(_ *cobra.Command, args []string) error {
vmName = args[0]
}
- provider := getSystemDefaultProvider()
+ provider := GetSystemDefaultProvider()
vm, err = provider.LoadVMByName(vmName)
if err != nil {
return err
diff --git a/cmd/podman/machine/set.go b/cmd/podman/machine/set.go
index a994c981b..5777882da 100644
--- a/cmd/podman/machine/set.go
+++ b/cmd/podman/machine/set.go
@@ -83,7 +83,7 @@ func setMachine(cmd *cobra.Command, args []string) error {
if len(args) > 0 && len(args[0]) > 0 {
vmName = args[0]
}
- provider := getSystemDefaultProvider()
+ provider := GetSystemDefaultProvider()
vm, err = provider.LoadVMByName(vmName)
if err != nil {
return err
diff --git a/cmd/podman/machine/ssh.go b/cmd/podman/machine/ssh.go
index e1175d632..4a86da67a 100644
--- a/cmd/podman/machine/ssh.go
+++ b/cmd/podman/machine/ssh.go
@@ -51,7 +51,7 @@ func ssh(cmd *cobra.Command, args []string) error {
// Set the VM to default
vmName := defaultMachineName
- provider := getSystemDefaultProvider()
+ provider := GetSystemDefaultProvider()
// If len is greater than 0, it means we may have been
// provided the VM name. If so, we check. The VM name,
diff --git a/cmd/podman/machine/start.go b/cmd/podman/machine/start.go
index 2b0c8213d..c9b99e63b 100644
--- a/cmd/podman/machine/start.go
+++ b/cmd/podman/machine/start.go
@@ -42,7 +42,7 @@ func start(_ *cobra.Command, args []string) error {
vmName = args[0]
}
- provider := getSystemDefaultProvider()
+ provider := GetSystemDefaultProvider()
vm, err = provider.LoadVMByName(vmName)
if err != nil {
return err
diff --git a/cmd/podman/machine/stop.go b/cmd/podman/machine/stop.go
index dcb124dd4..993662792 100644
--- a/cmd/podman/machine/stop.go
+++ b/cmd/podman/machine/stop.go
@@ -41,7 +41,7 @@ func stop(cmd *cobra.Command, args []string) error {
if len(args) > 0 && len(args[0]) > 0 {
vmName = args[0]
}
- provider := getSystemDefaultProvider()
+ provider := GetSystemDefaultProvider()
vm, err = provider.LoadVMByName(vmName)
if err != nil {
return err
diff --git a/cmd/podman/system/reset.go b/cmd/podman/system/reset.go
index 8f2e73375..176573bf6 100644
--- a/cmd/podman/system/reset.go
+++ b/cmd/podman/system/reset.go
@@ -61,7 +61,9 @@ func reset(cmd *cobra.Command, args []string) {
- all pods
- all images
- all networks
- - all build cache`)
+ - all build cache
+ - all machines`)
+
if len(listCtn) > 0 {
fmt.Println(`WARNING! The following external containers will be purged:`)
// print first 12 characters of ID and first configured name alias
@@ -103,5 +105,11 @@ func reset(cmd *cobra.Command, args []string) {
//nolint:gocritic
os.Exit(define.ExecErrorCodeGeneric)
}
+
+ // Shutdown podman-machine and delete all machine files
+ if err := resetMachine(); err != nil {
+ logrus.Error(err)
+ }
+
os.Exit(0)
}
diff --git a/cmd/podman/system/reset_machine.go b/cmd/podman/system/reset_machine.go
new file mode 100644
index 000000000..a07b4fb83
--- /dev/null
+++ b/cmd/podman/system/reset_machine.go
@@ -0,0 +1,13 @@
+//go:build (amd64 && !remote) || (arm64 && !remote)
+// +build amd64,!remote arm64,!remote
+
+package system
+
+import (
+ cmdMach "github.com/containers/podman/v4/cmd/podman/machine"
+)
+
+func resetMachine() error {
+ provider := cmdMach.GetSystemDefaultProvider()
+ return provider.RemoveAndCleanMachines()
+}
diff --git a/cmd/podman/system/reset_machine_unsupported.go b/cmd/podman/system/reset_machine_unsupported.go
new file mode 100644
index 000000000..e063cd089
--- /dev/null
+++ b/cmd/podman/system/reset_machine_unsupported.go
@@ -0,0 +1,8 @@
+//go:build !amd64 && !arm64
+// +build !amd64,!arm64
+
+package system
+
+func resetMachine() error {
+ return nil
+}