mirror of
https://github.com/containers/podman.git
synced 2025-06-06 23:08:04 +08:00
Improve error when starting multiple machines
Instead of ErrVMAlreadyRunning use a more appropriate error. Also improve the message a little bit. Fixes: https://github.com/containers/podman/issues/23436 Signed-off-by: Nicola Sella <nsella@redhat.com>
This commit is contained in:
@ -210,10 +210,10 @@ var _ = Describe("podman machine start", func() {
|
|||||||
Expect(startSession1).To(Or(Exit(0), Exit(125)), "start command should succeed or fail with 125")
|
Expect(startSession1).To(Or(Exit(0), Exit(125)), "start command should succeed or fail with 125")
|
||||||
if startSession1.ExitCode() == 0 {
|
if startSession1.ExitCode() == 0 {
|
||||||
Expect(startSession2).To(Exit(125), "first start worked, second start must fail")
|
Expect(startSession2).To(Exit(125), "first start worked, second start must fail")
|
||||||
Expect(startSession2.errorToString()).To(ContainSubstring("machine %s: VM already running or starting", machine1))
|
Expect(startSession2.errorToString()).To(ContainSubstring("machine %s is already running: only one VM can be active at a time", machine1))
|
||||||
} else {
|
} else {
|
||||||
Expect(startSession2).To(Exit(0), "first start failed, second start succeed")
|
Expect(startSession2).To(Exit(0), "first start failed, second start succeed")
|
||||||
Expect(startSession1.errorToString()).To(ContainSubstring("machine %s: VM already running or starting", machine2))
|
Expect(startSession1.errorToString()).To(ContainSubstring("machine %s is already running: only one VM can be active at a time", machine2))
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -283,8 +283,11 @@ func checkExclusiveActiveVM(provider vmconfigs.VMProvider, mc *vmconfigs.Machine
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if state == machineDefine.Running || state == machineDefine.Starting {
|
if state == machineDefine.Running || state == machineDefine.Starting {
|
||||||
|
if mc.Name == name {
|
||||||
return fmt.Errorf("unable to start %q: machine %s: %w", mc.Name, name, machineDefine.ErrVMAlreadyRunning)
|
return fmt.Errorf("unable to start %q: machine %s: %w", mc.Name, name, machineDefine.ErrVMAlreadyRunning)
|
||||||
}
|
}
|
||||||
|
return fmt.Errorf("unable to start %q: machine %s is already running: %w", mc.Name, name, machineDefine.ErrMultipleActiveVM)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user