Skip to content

Commit

Permalink
fix cni deepcopy
Browse files Browse the repository at this point in the history
  • Loading branch information
lut777 authored and zhangzujian committed Mar 1, 2022
1 parent 85d8626 commit fe9532d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pkg/daemon/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func (csh cniServerHandler) handleAdd(req *restful.Request, resp *restful.Respon
func (csh cniServerHandler) createOrUpdateIPCr(podRequest request.CniRequest, subnet, ip, macAddr string) error {
v4IP, v6IP := util.SplitStringIP(ip)
ipCrName := ovs.PodNameToPortName(podRequest.PodName, podRequest.PodNamespace, podRequest.Provider)
ipCr, err := csh.KubeOvnClient.KubeovnV1().IPs().Get(context.Background(), ipCrName, metav1.GetOptions{})
oriIpCr, err := csh.KubeOvnClient.KubeovnV1().IPs().Get(context.Background(), ipCrName, metav1.GetOptions{})
if err != nil {
if k8serrors.IsNotFound(err) {
_, err := csh.KubeOvnClient.KubeovnV1().IPs().Create(context.Background(), &kubeovnv1.IP{
Expand Down Expand Up @@ -260,6 +260,7 @@ func (csh cniServerHandler) createOrUpdateIPCr(podRequest request.CniRequest, su
return errMsg
}
} else {
ipCr := oriIpCr.DeepCopy()
ipCr.Spec.AttachIPs = append(ipCr.Spec.AttachIPs, ip)
ipCr.Labels[subnet] = ""
ipCr.Spec.AttachSubnets = append(ipCr.Spec.AttachSubnets, subnet)
Expand Down

0 comments on commit fe9532d

Please sign in to comment.