mirror of
https://github.com/containers/podman.git
synced 2025-10-19 20:23:08 +08:00
Prevent two podman machines running on darwin
As issue #25112 points out, it was possible to start a machine on one of the darwin providers and then switch providers and start another one with a different name. This PR firstly prevents that use which is a forbidden use case. Secondarily, performed some minor cleanup on the error messages being used so that the error would be specific to this condition. This bug fix is for darwin only. In the case of Windows, we probably need to answer the question I raised in #24067 first, which is whether we want to stop allowing WSL to run multiple machines. Fixes #25112 Signed-off-by: Brent Baude <bbaude@redhat.com>
This commit is contained in:
@ -61,8 +61,10 @@ var _ = Describe("podman machine start", func() {
|
||||
})
|
||||
|
||||
It("start machine already started", func() {
|
||||
name := randomString()
|
||||
i := new(initMachine)
|
||||
session, err := mb.setCmd(i.withImage(mb.imagePath)).run()
|
||||
machineTestBuilderInit := mb.setName(name).setCmd(i.withImage(mb.imagePath))
|
||||
session, err := machineTestBuilderInit.run()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(session).To(Exit(0))
|
||||
s := new(startMachine)
|
||||
@ -78,7 +80,7 @@ var _ = Describe("podman machine start", func() {
|
||||
startSession, err = mb.setCmd(s).run()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(startSession).To(Exit(125))
|
||||
Expect(startSession.errorToString()).To(ContainSubstring("VM already running or starting"))
|
||||
Expect(startSession.errorToString()).To(ContainSubstring(fmt.Sprintf("Error: unable to start %q: already running", machineTestBuilderInit.name)))
|
||||
})
|
||||
|
||||
It("start machine with conflict on SSH port", func() {
|
||||
@ -210,10 +212,10 @@ var _ = Describe("podman machine start", func() {
|
||||
Expect(startSession1).To(Or(Exit(0), Exit(125)), "start command should succeed or fail with 125")
|
||||
if startSession1.ExitCode() == 0 {
|
||||
Expect(startSession2).To(Exit(125), "first start worked, second start must fail")
|
||||
Expect(startSession2.errorToString()).To(ContainSubstring("machine %s is already running: only one VM can be active at a time", machine1))
|
||||
Expect(startSession2.errorToString()).To(ContainSubstring("%s already starting or running: only one VM can be active at a time", machine1))
|
||||
} else {
|
||||
Expect(startSession2).To(Exit(0), "first start failed, second start succeed")
|
||||
Expect(startSession1.errorToString()).To(ContainSubstring("machine %s is already running: only one VM can be active at a time", machine2))
|
||||
Expect(startSession1.errorToString()).To(ContainSubstring("%s already starting or running: only one VM can be active at a time", machine2))
|
||||
}
|
||||
})
|
||||
})
|
||||
|
Reference in New Issue
Block a user