Skip to content

Commit

Permalink
allow ip change name in migration (#4133)
Browse files Browse the repository at this point in the history
* allow ip change name in migration
---------

Signed-off-by: bobz965 <[email protected]>
Co-authored-by: 张祖建 <[email protected]>
  • Loading branch information
bobz965 and zhangzujian committed Jun 7, 2024
1 parent d6b4194 commit 7220a5e
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 10 deletions.
3 changes: 0 additions & 3 deletions pkg/controller/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ func (c *Controller) enqueueUpdateIP(oldObj, newObj interface{}) {
if oldIP.Spec.MacAddress != "" && newIP.Spec.MacAddress != oldIP.Spec.MacAddress {
klog.Errorf("ip %s macAddress can not change", newIP.Name)
}
if oldIP.Spec.NodeName != "" && newIP.Spec.NodeName != oldIP.Spec.NodeName {
klog.Errorf("ip %s nodeName can not change", newIP.Name)
}
if oldIP.Spec.V4IPAddress != "" && newIP.Spec.V4IPAddress != oldIP.Spec.V4IPAddress {
klog.Errorf("ip %s v4IPAddress can not change", newIP.Name)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ func (c *Controller) handleDeleteNode(key string) error {
return err
}
}

klog.Infof("delete node ip %s", portName)
if err = c.config.KubeOvnClient.KubeovnV1().IPs().Delete(context.Background(), portName, metav1.DeleteOptions{}); err != nil && !k8serrors.IsNotFound(err) {
return err
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/controller/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -1259,11 +1259,10 @@ func (c *Controller) syncKubeOvnNet(cachedPod, pod *v1.Pod, podNets []*kubeovnNe
}

for _, portNeedDel := range portsNeedToDel {

klog.Infof("release port %s for pod %s", portNeedDel, podName)
if subnet, ok := c.ipam.Subnets[subnetUsedByPort[portNeedDel]]; ok {
subnet.ReleaseAddressWithNicName(podName, portNeedDel)
}

if err := c.OVNNbClient.DeleteLogicalSwitchPort(portNeedDel); err != nil {
klog.Errorf("failed to delete lsp %s, %v", portNeedDel, err)
return nil, err
Expand Down
4 changes: 0 additions & 4 deletions pkg/webhook/ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ func (v *ValidatingHook) IPUpdateHook(ctx context.Context, req admission.Request
err := fmt.Errorf("ip %s macAddress can not change", ipNew.Name)
return ctrlwebhook.Errored(http.StatusBadRequest, err)
}
if ipOld.Spec.NodeName != "" && ipNew.Spec.NodeName != ipOld.Spec.NodeName {
err := fmt.Errorf("ip %s nodeName can not change", ipNew.Name)
return ctrlwebhook.Errored(http.StatusBadRequest, err)
}
return ctrlwebhook.Allowed("by pass")
}

Expand Down

0 comments on commit 7220a5e

Please sign in to comment.