Merge pull request #21517 from jakecorrenti/fix-qemu-todos
machine: Address some QEMU TODOs
This commit is contained in:
commit
36d8e27601
|
|
@ -67,10 +67,6 @@ func inspect(cmd *cobra.Command, args []string) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
ignFile, err := mc.IgnitionFile()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
podmanSocket, podmanPipe, err := mc.ConnectionInfo(provider.VMType())
|
podmanSocket, podmanPipe, err := mc.ConnectionInfo(provider.VMType())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -83,13 +79,7 @@ func inspect(cmd *cobra.Command, args []string) error {
|
||||||
PodmanSocket: podmanSocket,
|
PodmanSocket: podmanSocket,
|
||||||
PodmanPipe: podmanPipe,
|
PodmanPipe: podmanPipe,
|
||||||
},
|
},
|
||||||
Created: mc.Created,
|
Created: mc.Created,
|
||||||
// TODO This is no longer applicable; we dont care about the provenance
|
|
||||||
// of the image
|
|
||||||
Image: machine.ImageConfig{
|
|
||||||
IgnitionFile: *ignFile,
|
|
||||||
ImagePath: *mc.ImagePath,
|
|
||||||
},
|
|
||||||
LastUp: mc.LastUp,
|
LastUp: mc.LastUp,
|
||||||
Name: mc.Name,
|
Name: mc.Name,
|
||||||
Resources: mc.Resources,
|
Resources: mc.Resources,
|
||||||
|
|
|
||||||
|
|
@ -120,14 +120,12 @@ func rm(_ *cobra.Command, args []string) error {
|
||||||
// All actual removal of files and vms should occur after this
|
// All actual removal of files and vms should occur after this
|
||||||
//
|
//
|
||||||
|
|
||||||
// TODO Should this be a hard error?
|
|
||||||
if err := providerRm(); err != nil {
|
if err := providerRm(); err != nil {
|
||||||
logrus.Errorf("failed to remove virtual machine from provider for %q", vmName)
|
logrus.Errorf("failed to remove virtual machine from provider for %q: %v", vmName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Should this be a hard error?
|
|
||||||
if err := genericRm(); err != nil {
|
if err := genericRm(); err != nil {
|
||||||
logrus.Error("failed to remove machines files")
|
return fmt.Errorf("failed to remove machines files: %v", err)
|
||||||
}
|
}
|
||||||
newMachineEvent(events.Remove, events.Event{Name: vmName})
|
newMachineEvent(events.Remove, events.Event{Name: vmName})
|
||||||
return nil
|
return nil
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ Print results with a Go template.
|
||||||
| .ConfigDir ... | Machine configuration directory location |
|
| .ConfigDir ... | Machine configuration directory location |
|
||||||
| .ConnectionInfo ... | Machine connection information |
|
| .ConnectionInfo ... | Machine connection information |
|
||||||
| .Created ... | Machine creation time (string, ISO3601) |
|
| .Created ... | Machine creation time (string, ISO3601) |
|
||||||
| .Image ... | Machine image config |
|
|
||||||
| .LastUp ... | Time when machine was last booted |
|
| .LastUp ... | Time when machine was last booted |
|
||||||
| .Name | Name of the machine |
|
| .Name | Name of the machine |
|
||||||
| .Resources ... | Resources used by the machine |
|
| .Resources ... | Resources used by the machine |
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,6 @@ type InspectInfo struct {
|
||||||
ConfigDir define.VMFile
|
ConfigDir define.VMFile
|
||||||
ConnectionInfo ConnectionConfig
|
ConnectionInfo ConnectionConfig
|
||||||
Created time.Time
|
Created time.Time
|
||||||
Image ImageConfig
|
|
||||||
LastUp time.Time
|
LastUp time.Time
|
||||||
Name string
|
Name string
|
||||||
Resources vmconfigs.ResourceConfig
|
Resources vmconfigs.ResourceConfig
|
||||||
|
|
|
||||||
|
|
@ -287,16 +287,6 @@ var _ = Describe("podman machine init", func() {
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
cfgpth := filepath.Join(inspectSession.outputToString(), fmt.Sprintf("%s.json", name))
|
cfgpth := filepath.Join(inspectSession.outputToString(), fmt.Sprintf("%s.json", name))
|
||||||
|
|
||||||
inspect = inspect.withFormat("{{.Image.IgnitionFile.Path}}")
|
|
||||||
inspectSession, err = mb.setCmd(inspect).run()
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
ign := inspectSession.outputToString()
|
|
||||||
|
|
||||||
inspect = inspect.withFormat("{{.Image.ImagePath.Path}}")
|
|
||||||
inspectSession, err = mb.setCmd(inspect).run()
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
img := inspectSession.outputToString()
|
|
||||||
|
|
||||||
rm := rmMachine{}
|
rm := rmMachine{}
|
||||||
removeSession, err := mb.setCmd(rm.withForce()).run()
|
removeSession, err := mb.setCmd(rm.withForce()).run()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
@ -317,13 +307,17 @@ var _ = Describe("podman machine init", func() {
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
Expect(session).To(Exit(125))
|
Expect(session).To(Exit(125))
|
||||||
|
|
||||||
// ensure files created by init are cleaned up on init failure
|
imageSuffix := mb.imagePath[strings.LastIndex(mb.imagePath, "/")+1:]
|
||||||
_, err = os.Stat(img)
|
imgPath := filepath.Join(testDir, ".local", "share", "containers", "podman", "machine", "qemu", mb.name+"_"+imageSuffix)
|
||||||
|
_, err = os.Stat(imgPath)
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
|
|
||||||
|
cfgDir := filepath.Join(testDir, ".config", "containers", "podman", "machine", testProvider.VMType().String())
|
||||||
_, err = os.Stat(cfgpth)
|
_, err = os.Stat(cfgpth)
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
|
|
||||||
_, err = os.Stat(ign)
|
ignPath := filepath.Join(cfgDir, mb.name+".ign")
|
||||||
|
_, err = os.Stat(ignPath)
|
||||||
Expect(err).To(HaveOccurred())
|
Expect(err).To(HaveOccurred())
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -94,16 +94,6 @@ var _ = Describe("podman machine rm", func() {
|
||||||
key := inspectSession.outputToString()
|
key := inspectSession.outputToString()
|
||||||
pubkey := key + ".pub"
|
pubkey := key + ".pub"
|
||||||
|
|
||||||
inspect = inspect.withFormat("{{.Image.IgnitionFile.Path}}")
|
|
||||||
inspectSession, err = mb.setCmd(inspect).run()
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
ign := inspectSession.outputToString()
|
|
||||||
|
|
||||||
inspect = inspect.withFormat("{{.Image.ImagePath.Path}}")
|
|
||||||
inspectSession, err = mb.setCmd(inspect).run()
|
|
||||||
Expect(err).ToNot(HaveOccurred())
|
|
||||||
img := inspectSession.outputToString()
|
|
||||||
|
|
||||||
rm := rmMachine{}
|
rm := rmMachine{}
|
||||||
removeSession, err := mb.setCmd(rm.withForce().withSaveIgnition().withSaveImage()).run()
|
removeSession, err := mb.setCmd(rm.withForce().withSaveIgnition().withSaveImage()).run()
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
|
|
@ -122,10 +112,11 @@ var _ = Describe("podman machine rm", func() {
|
||||||
|
|
||||||
// WSL does not use ignition
|
// WSL does not use ignition
|
||||||
if testProvider.VMType() != define.WSLVirt {
|
if testProvider.VMType() != define.WSLVirt {
|
||||||
_, err = os.Stat(ign)
|
ignPath := filepath.Join(testDir, ".config", "containers", "podman", "machine", testProvider.VMType().String(), mb.name+".ign")
|
||||||
|
_, err = os.Stat(ignPath)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
}
|
}
|
||||||
_, err = os.Stat(img)
|
_, err = os.Stat(mb.imagePath)
|
||||||
Expect(err).ToNot(HaveOccurred())
|
Expect(err).ToNot(HaveOccurred())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/config"
|
"github.com/containers/common/pkg/config"
|
||||||
|
"github.com/containers/podman/v5/pkg/errorhandling"
|
||||||
"github.com/containers/podman/v5/pkg/machine/define"
|
"github.com/containers/podman/v5/pkg/machine/define"
|
||||||
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
|
"github.com/containers/podman/v5/pkg/machine/vmconfigs"
|
||||||
"github.com/digitalocean/go-qemu/qmp"
|
"github.com/digitalocean/go-qemu/qmp"
|
||||||
|
|
@ -237,7 +238,15 @@ func (q *QEMUStubber) Remove(mc *vmconfigs.MachineConfig) ([]string, func() erro
|
||||||
}
|
}
|
||||||
|
|
||||||
return qemuRmFiles, func() error {
|
return qemuRmFiles, func() error {
|
||||||
return nil
|
var errs []error
|
||||||
|
if err := mc.QEMUHypervisor.QEMUPidPath.Delete(); err != nil {
|
||||||
|
errs = append(errs, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := mc.QEMUHypervisor.QMPMonitor.Address.Delete(); err != nil {
|
||||||
|
errs = append(errs, err)
|
||||||
|
}
|
||||||
|
return errorhandling.JoinErrors(errs)
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
define2 "github.com/containers/podman/v5/libpod/define"
|
define2 "github.com/containers/podman/v5/libpod/define"
|
||||||
|
"github.com/containers/podman/v5/pkg/errorhandling"
|
||||||
"github.com/containers/podman/v5/pkg/machine/connection"
|
"github.com/containers/podman/v5/pkg/machine/connection"
|
||||||
"github.com/containers/podman/v5/pkg/machine/define"
|
"github.com/containers/podman/v5/pkg/machine/define"
|
||||||
"github.com/containers/podman/v5/pkg/machine/lock"
|
"github.com/containers/podman/v5/pkg/machine/lock"
|
||||||
|
|
@ -184,28 +185,32 @@ func (mc *MachineConfig) Remove(saveIgnition, saveImage bool) ([]string, func()
|
||||||
}
|
}
|
||||||
|
|
||||||
mcRemove := func() error {
|
mcRemove := func() error {
|
||||||
|
var errs []error
|
||||||
|
if err := connection.RemoveConnections(mc.Name, mc.Name+"-root"); err != nil {
|
||||||
|
errs = append(errs, err)
|
||||||
|
}
|
||||||
|
|
||||||
if !saveIgnition {
|
if !saveIgnition {
|
||||||
if err := ignitionFile.Delete(); err != nil {
|
if err := ignitionFile.Delete(); err != nil {
|
||||||
logrus.Error(err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !saveImage {
|
if !saveImage {
|
||||||
if err := mc.ImagePath.Delete(); err != nil {
|
if err := mc.ImagePath.Delete(); err != nil {
|
||||||
logrus.Error(err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := mc.configPath.Delete(); err != nil {
|
|
||||||
logrus.Error(err)
|
|
||||||
}
|
|
||||||
if err := readySocket.Delete(); err != nil {
|
if err := readySocket.Delete(); err != nil {
|
||||||
logrus.Error()
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
if err := logPath.Delete(); err != nil {
|
if err := logPath.Delete(); err != nil {
|
||||||
logrus.Error(err)
|
errs = append(errs, err)
|
||||||
}
|
}
|
||||||
// TODO This should be bumped up into delete and called out in the text given then
|
|
||||||
// are not technically files per'se
|
if err := mc.configPath.Delete(); err != nil {
|
||||||
return connection.RemoveConnections(mc.Name, mc.Name+"-root")
|
errs = append(errs, err)
|
||||||
|
}
|
||||||
|
return errorhandling.JoinErrors(errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
return rmFiles, mcRemove, nil
|
return rmFiles, mcRemove, nil
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue