mirror of
https://github.com/containers/podman.git
synced 2025-07-02 08:47:43 +08:00
Merge pull request #22914 from Luap99/start-stopped
libpod: do not reuse networking on start
This commit is contained in:
@ -71,6 +71,14 @@ func (c *Container) prepare() error {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
if c.state.State == define.ContainerStateStopped {
|
||||||
|
// networking should not be reused after a stop
|
||||||
|
if err := c.cleanupNetwork(); err != nil {
|
||||||
|
createNetNSErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set up network namespace if not already set up
|
// Set up network namespace if not already set up
|
||||||
noNetNS := c.state.NetNS == ""
|
noNetNS := c.state.NetNS == ""
|
||||||
if c.config.CreateNetNS && noNetNS && !c.config.PostConfigureNetNS {
|
if c.config.CreateNetNS && noNetNS && !c.config.PostConfigureNetNS {
|
||||||
|
@ -193,12 +193,13 @@ var _ = Describe("Podman restart", func() {
|
|||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
|
|
||||||
testCmd := []string{"exec", "host-restart-test", "sh", "-c", "wc -l < /etc/hosts"}
|
testCmd := []string{"exec", "host-restart-test", "cat", "/etc/hosts"}
|
||||||
|
|
||||||
// before restart
|
// before restart
|
||||||
beforeRestart := podmanTest.Podman(testCmd)
|
beforeRestart := podmanTest.Podman(testCmd)
|
||||||
beforeRestart.WaitWithDefaultTimeout()
|
beforeRestart.WaitWithDefaultTimeout()
|
||||||
Expect(beforeRestart).Should(ExitCleanly())
|
Expect(beforeRestart).Should(ExitCleanly())
|
||||||
|
nHostLines := len(beforeRestart.OutputToStringArray())
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"restart", "host-restart-test"})
|
session = podmanTest.Podman([]string{"restart", "host-restart-test"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
@ -209,7 +210,8 @@ var _ = Describe("Podman restart", func() {
|
|||||||
Expect(afterRestart).Should(ExitCleanly())
|
Expect(afterRestart).Should(ExitCleanly())
|
||||||
|
|
||||||
// line count should be equal
|
// line count should be equal
|
||||||
Expect(beforeRestart.OutputToString()).To(Equal(afterRestart.OutputToString()))
|
Expect(afterRestart.OutputToStringArray()).To(HaveLen(nHostLines),
|
||||||
|
"number of host lines post-restart == number of lines pre-restart")
|
||||||
})
|
})
|
||||||
|
|
||||||
It("podman restart all stopped containers with --all", func() {
|
It("podman restart all stopped containers with --all", func() {
|
||||||
|
@ -58,6 +58,9 @@ load helpers
|
|||||||
is "$output" ".*$c1_id.*" "--filter finds container 1"
|
is "$output" ".*$c1_id.*" "--filter finds container 1"
|
||||||
is "$output" ".*$c3_id.*" "--filter finds container 3"
|
is "$output" ".*$c3_id.*" "--filter finds container 3"
|
||||||
|
|
||||||
|
# start again, before this fix it could panic
|
||||||
|
run_podman start --filter restart-policy=always
|
||||||
|
|
||||||
# Start via filtered names
|
# Start via filtered names
|
||||||
run_podman start --filter restart-policy=on-failure $c2 $c3
|
run_podman start --filter restart-policy=on-failure $c2 $c3
|
||||||
is "$output" "$c2" "--filter finds container 2"
|
is "$output" "$c2" "--filter finds container 2"
|
||||||
|
Reference in New Issue
Block a user