Skip to content

Commit

Permalink
fix: init node with wrong ipamkey and lead conflict
Browse files Browse the repository at this point in the history
```
E0926 09:50:20.371312       1 init.go:347] failed to init node kube-ovn-worker. address 100.64.0.3: AddressConflict
E0926 09:50:20.377591       1 init.go:347] failed to init node kube-ovn-control-plane. address 100.64.0.2: AddressConflict

```
  • Loading branch information
oilbeater committed Sep 26, 2021
1 parent fa17c3d commit fa66c5f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/controller/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,12 @@ func (c *Controller) InitIPAM() error {
return err
}
for _, ip := range ips {
ipamKey := fmt.Sprintf("%s/%s", ip.Spec.Namespace, ip.Spec.PodName)
var ipamKey string
if ip.Spec.Namespace != "" {
ipamKey = fmt.Sprintf("%s/%s", ip.Spec.Namespace, ip.Spec.PodName)
} else {
ipamKey = fmt.Sprintf("node-%s", ip.Spec.PodName)
}
if _, _, _, err = c.ipam.GetStaticAddress(ipamKey, ip.Spec.IPAddress, ip.Spec.MacAddress, ip.Spec.Subnet); err != nil {
klog.Errorf("failed to init IPAM from IP CR %s: %v", ip.Name, err)
}
Expand Down

0 comments on commit fa66c5f

Please sign in to comment.