Skip to content

Commit

Permalink
fix: multus macvlan ipvlan use kube-ovn ipam,but ip not inited in ini…
Browse files Browse the repository at this point in the history
…t-ipam (#1843)

* fix: multus subnet ip not recover when init ipam, let sts ip lost can recover from pod

* optimize: remove logic about sts ip in init-ipam
  • Loading branch information
bobz965 committed Aug 24, 2022
1 parent 8ef6c01 commit 51f491f
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions pkg/controller/init.go
Expand Up @@ -328,6 +328,7 @@ func (c *Controller) InitIPAM() error {
ipsMap := make(map[string]*kubeovnv1.IP, len(ips))
for _, ip := range ips {
ipsMap[ip.Name] = ip
// just recover sts ip, old sts ip with empty pod type and other ip recover in later pod loop
if ip.Spec.PodType != "StatefulSet" {
continue
}
Expand Down Expand Up @@ -364,19 +365,8 @@ func (c *Controller) InitIPAM() error {
podName := c.getNameByPod(pod)
key := fmt.Sprintf("%s/%s", pod.Namespace, podName)
for _, podNet := range podNets {
if !isOvnSubnet(podNet.Subnet) {
continue
}
if pod.Annotations[fmt.Sprintf(util.AllocatedAnnotationTemplate, podNet.ProviderName)] == "true" {
portName := ovs.PodNameToPortName(podName, pod.Namespace, podNet.ProviderName)
if !isAlive && isStsPod {
if ipCR := ipsMap[portName]; ipCR != nil && ipCR.Spec.PodType == "" {
if _, _, _, err = c.ipam.GetStaticAddress(key, ipCR.Name, ipCR.Spec.IPAddress, ipCR.Spec.MacAddress, ipCR.Spec.Subnet, true); err != nil {
klog.Errorf("failed to init IPAM from IP CR %s: %v", ipCR.Name, err)
}
}
continue
}
ip := pod.Annotations[fmt.Sprintf(util.IpAddressAnnotationTemplate, podNet.ProviderName)]
mac := pod.Annotations[fmt.Sprintf(util.MacAddressAnnotationTemplate, podNet.ProviderName)]
subnet := pod.Annotations[fmt.Sprintf(util.LogicalSwitchAnnotationTemplate, podNet.ProviderName)]
Expand Down

0 comments on commit 51f491f

Please sign in to comment.