mirror of https://github.com/containers/podman.git
Merge pull request #9235 from Luap99/fix-9234
Fix podman network disconnect wrong NetworkStatus number
This commit is contained in:
commit
b1bd126cda
|
@ -1180,7 +1180,7 @@ func (c *Container) NetworkDisconnect(nameOrID, netName string, force bool) erro
|
||||||
// update network status if container is not running
|
// update network status if container is not running
|
||||||
networkStatus := c.state.NetworkStatus
|
networkStatus := c.state.NetworkStatus
|
||||||
// clip out the index of the network
|
// clip out the index of the network
|
||||||
tmpNetworkStatus := make([]*cnitypes.Result, len(networkStatus)-1)
|
tmpNetworkStatus := make([]*cnitypes.Result, 0, len(networkStatus)-1)
|
||||||
for k, v := range networkStatus {
|
for k, v := range networkStatus {
|
||||||
if index != k {
|
if index != k {
|
||||||
tmpNetworkStatus = append(tmpNetworkStatus, v)
|
tmpNetworkStatus = append(tmpNetworkStatus, v)
|
||||||
|
|
|
@ -74,6 +74,11 @@ var _ = Describe("Podman network connect and disconnect", func() {
|
||||||
dis.WaitWithDefaultTimeout()
|
dis.WaitWithDefaultTimeout()
|
||||||
Expect(dis.ExitCode()).To(BeZero())
|
Expect(dis.ExitCode()).To(BeZero())
|
||||||
|
|
||||||
|
inspect := podmanTest.Podman([]string{"container", "inspect", "test", "--format", "{{len .NetworkSettings.Networks}}"})
|
||||||
|
inspect.WaitWithDefaultTimeout()
|
||||||
|
Expect(inspect.ExitCode()).To(BeZero())
|
||||||
|
Expect(inspect.OutputToString()).To(Equal("0"))
|
||||||
|
|
||||||
exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"})
|
exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth0"})
|
||||||
exec.WaitWithDefaultTimeout()
|
exec.WaitWithDefaultTimeout()
|
||||||
Expect(exec.ExitCode()).ToNot(BeZero())
|
Expect(exec.ExitCode()).ToNot(BeZero())
|
||||||
|
@ -146,6 +151,11 @@ var _ = Describe("Podman network connect and disconnect", func() {
|
||||||
connect.WaitWithDefaultTimeout()
|
connect.WaitWithDefaultTimeout()
|
||||||
Expect(connect.ExitCode()).To(BeZero())
|
Expect(connect.ExitCode()).To(BeZero())
|
||||||
|
|
||||||
|
inspect := podmanTest.Podman([]string{"container", "inspect", "test", "--format", "{{len .NetworkSettings.Networks}}"})
|
||||||
|
inspect.WaitWithDefaultTimeout()
|
||||||
|
Expect(inspect.ExitCode()).To(BeZero())
|
||||||
|
Expect(inspect.OutputToString()).To(Equal("2"))
|
||||||
|
|
||||||
exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth1"})
|
exec = podmanTest.Podman([]string{"exec", "-it", "test", "ip", "addr", "show", "eth1"})
|
||||||
exec.WaitWithDefaultTimeout()
|
exec.WaitWithDefaultTimeout()
|
||||||
Expect(exec.ExitCode()).To(BeZero())
|
Expect(exec.ExitCode()).To(BeZero())
|
||||||
|
@ -167,6 +177,11 @@ var _ = Describe("Podman network connect and disconnect", func() {
|
||||||
dis.WaitWithDefaultTimeout()
|
dis.WaitWithDefaultTimeout()
|
||||||
Expect(dis.ExitCode()).To(BeZero())
|
Expect(dis.ExitCode()).To(BeZero())
|
||||||
|
|
||||||
|
inspect := podmanTest.Podman([]string{"container", "inspect", "test", "--format", "{{len .NetworkSettings.Networks}}"})
|
||||||
|
inspect.WaitWithDefaultTimeout()
|
||||||
|
Expect(inspect.ExitCode()).To(BeZero())
|
||||||
|
Expect(inspect.OutputToString()).To(Equal("2"))
|
||||||
|
|
||||||
start := podmanTest.Podman([]string{"start", "test"})
|
start := podmanTest.Podman([]string{"start", "test"})
|
||||||
start.WaitWithDefaultTimeout()
|
start.WaitWithDefaultTimeout()
|
||||||
Expect(start.ExitCode()).To(BeZero())
|
Expect(start.ExitCode()).To(BeZero())
|
||||||
|
@ -202,6 +217,11 @@ var _ = Describe("Podman network connect and disconnect", func() {
|
||||||
dis.WaitWithDefaultTimeout()
|
dis.WaitWithDefaultTimeout()
|
||||||
Expect(dis.ExitCode()).To(BeZero())
|
Expect(dis.ExitCode()).To(BeZero())
|
||||||
|
|
||||||
|
inspect := podmanTest.Podman([]string{"container", "inspect", "test", "--format", "{{len .NetworkSettings.Networks}}"})
|
||||||
|
inspect.WaitWithDefaultTimeout()
|
||||||
|
Expect(inspect.ExitCode()).To(BeZero())
|
||||||
|
Expect(inspect.OutputToString()).To(Equal("1"))
|
||||||
|
|
||||||
start := podmanTest.Podman([]string{"start", "test"})
|
start := podmanTest.Podman([]string{"start", "test"})
|
||||||
start.WaitWithDefaultTimeout()
|
start.WaitWithDefaultTimeout()
|
||||||
Expect(start.ExitCode()).To(BeZero())
|
Expect(start.ExitCode()).To(BeZero())
|
||||||
|
|
Loading…
Reference in New Issue