mirror of
https://github.com/containers/podman.git
synced 2026-10-24 10:49:10 -04:00
CNI: fix network create --ip-range
The --ip-range option did not work correctly. The endIP was accidentally assigned to the start IP. New tests are added to make sure it works. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
3 files changed
+23
-3
No files matched your search
@@ -182,7 +182,7 @@ func newIPAMLocalHostRange(subnet types.IPNet, leaseRange *types.LeaseRange, gw
|
||||
hostRange.RangeStart = leaseRange.StartIP.String()
|
||||
}
|
||||
if leaseRange.EndIP != nil {
|
||||
hostRange.RangeStart = leaseRange.EndIP.String()
|
||||
hostRange.RangeEnd = leaseRange.EndIP.String()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -621,7 +621,7 @@ var _ = Describe("Config", func() {
|
||||
err = libpodNet.NetworkRemove(network1.Name)
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
endIP := "10.0.0.10"
|
||||
endIP := "10.0.0.30"
|
||||
network = types.Network{
|
||||
Driver: "bridge",
|
||||
Subnets: []types.Subnet{
|
||||
@@ -665,6 +665,22 @@ var _ = Describe("Config", func() {
|
||||
Expect(network1.Subnets[0].Gateway.String()).To(Equal("10.0.0.1"))
|
||||
Expect(network1.Subnets[0].LeaseRange.StartIP.String()).To(Equal(startIP))
|
||||
Expect(network1.Subnets[0].LeaseRange.EndIP.String()).To(Equal(endIP))
|
||||
|
||||
// create a new interface to force a config load from disk
|
||||
libpodNet, err = getNetworkInterface(cniConfDir, false)
|
||||
Expect(err).To(BeNil())
|
||||
|
||||
network1, err = libpodNet.NetworkInspect(network1.Name)
|
||||
Expect(err).To(BeNil())
|
||||
Expect(network1.Name).ToNot(BeEmpty())
|
||||
Expect(network1.ID).ToNot(BeEmpty())
|
||||
Expect(network1.NetworkInterface).ToNot(BeEmpty())
|
||||
Expect(network1.Driver).To(Equal("bridge"))
|
||||
Expect(network1.Subnets).To(HaveLen(1))
|
||||
Expect(network1.Subnets[0].Subnet.String()).To(Equal(subnet))
|
||||
Expect(network1.Subnets[0].Gateway.String()).To(Equal("10.0.0.1"))
|
||||
Expect(network1.Subnets[0].LeaseRange.StartIP.String()).To(Equal(startIP))
|
||||
Expect(network1.Subnets[0].LeaseRange.EndIP.String()).To(Equal(endIP))
|
||||
})
|
||||
|
||||
It("create bridge with subnet and invalid lease range", func() {
|
||||
|
||||
@@ -43,7 +43,7 @@ var _ = Describe("Podman network create", func() {
|
||||
|
||||
It("podman network create with name and subnet", func() {
|
||||
netName := "subnet-" + stringid.GenerateNonCryptoID()
|
||||
nc := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.12.0/24", netName})
|
||||
nc := podmanTest.Podman([]string{"network", "create", "--subnet", "10.11.12.0/24", "--ip-range", "10.11.12.0/26", netName})
|
||||
nc.WaitWithDefaultTimeout()
|
||||
defer podmanTest.removeCNINetwork(netName)
|
||||
Expect(nc).Should(Exit(0))
|
||||
@@ -61,7 +61,11 @@ var _ = Describe("Podman network create", func() {
|
||||
result := results[0]
|
||||
Expect(result.Name).To(Equal(netName))
|
||||
Expect(result.Subnets).To(HaveLen(1))
|
||||
Expect(result.Subnets[0].Subnet.String()).To(Equal("10.11.12.0/24"))
|
||||
Expect(result.Subnets[0].Gateway.String()).To(Equal("10.11.12.1"))
|
||||
Expect(result.Subnets[0].LeaseRange).ToNot(BeNil())
|
||||
Expect(result.Subnets[0].LeaseRange.StartIP.String()).To(Equal("10.11.12.1"))
|
||||
Expect(result.Subnets[0].LeaseRange.EndIP.String()).To(Equal("10.11.12.63"))
|
||||
|
||||
// Once a container executes a new network, the nic will be created. We should clean those up
|
||||
// best we can
|
||||
|
||||
Reference in new issue
Block a user