Skip to content

Commit

Permalink
fix: update ipam cidr when subnet changed
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Jan 6, 2021
1 parent 925f90f commit ed0e9ba
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,8 @@ func (c *Controller) acquireAddress(pod *v1.Pod, subnet *kubeovnv1.Subnet) (stri
}
if v4IP, v6IP, mac, err := c.acquireStaticAddress(key, staticIP, macStr, subnet.Name); err == nil {
return v4IP, v6IP, mac, nil
} else {
klog.Errorf("acquire address %s for %s failed, %v", staticIP, key, err)
}
}
} else {
Expand Down
4 changes: 4 additions & 0 deletions pkg/ipam/ipam.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,8 @@ func (ipam *IPAM) AddOrUpdateSubnet(name, cidrStr string, excludeIps []string) e
if subnet, ok := ipam.Subnets[name]; ok {
subnet.Protocol = protocol
if protocol == kubeovnv1.ProtocolDual || protocol == kubeovnv1.ProtocolIPv4 {
_, cidr, _ := net.ParseCIDR(v4cidrStr)
subnet.V4CIDR = cidr
subnet.V4ReservedIPList = convertExcludeIps(v4ExcludeIps)
firstIP, _ := util.FirstSubnetIP(v4cidrStr)
lastIP, _ := util.LastIP(v4cidrStr)
Expand All @@ -159,6 +161,8 @@ func (ipam *IPAM) AddOrUpdateSubnet(name, cidrStr string, excludeIps []string) e
}
}
if protocol == kubeovnv1.ProtocolDual || protocol == kubeovnv1.ProtocolIPv6 {
_, cidr, _ := net.ParseCIDR(v6cidrStr)
subnet.V6CIDR = cidr
subnet.V6ReservedIPList = convertExcludeIps(v6ExcludeIps)
firstIP, _ := util.FirstSubnetIP(v6cidrStr)
lastIP, _ := util.LastIP(v6cidrStr)
Expand Down

0 comments on commit ed0e9ba

Please sign in to comment.