diff --git a/pkg/controller/init.go b/pkg/controller/init.go index 9de515a6a9c..71bc4f7d6d1 100644 --- a/pkg/controller/init.go +++ b/pkg/controller/init.go @@ -625,15 +625,15 @@ func (c *Controller) syncSubnetCR() error { klog.Error(err) return err } - for _, orisubnet := range subnets { - subnet := orisubnet.DeepCopy() + for _, cachedSubnet := range subnets { + subnet := cachedSubnet.DeepCopy() if util.CheckProtocol(subnet.Spec.CIDRBlock) == kubeovnv1.ProtocolDual { subnet, err = c.calcDualSubnetStatusIP(subnet) } else { subnet, err = c.calcSubnetStatusIP(subnet) } if err != nil { - klog.Errorf("failed to calculate subnet %s used ip: %v", subnet.Name, err) + klog.Errorf("failed to calculate subnet %s used ip: %v", cachedSubnet.Name, err) return err } diff --git a/pkg/controller/subnet.go b/pkg/controller/subnet.go index 96de2e5fce2..32a1e105dbf 100644 --- a/pkg/controller/subnet.go +++ b/pkg/controller/subnet.go @@ -747,7 +747,7 @@ func (c *Controller) handleAddOrUpdateSubnet(key string) error { subnet, err = c.calcSubnetStatusIP(subnet) } if err != nil { - klog.Errorf("calculate subnet %s used ip failed, %v", subnet.Name, err) + klog.Errorf("calculate subnet %s used ip failed, %v", cachedSubnet.Name, err) return err }