diff --git a/pkg/controller/subnet.go b/pkg/controller/subnet.go index 60c6fa76d2a..45fb75c7bfb 100644 --- a/pkg/controller/subnet.go +++ b/pkg/controller/subnet.go @@ -83,13 +83,18 @@ func (c *Controller) enqueueUpdateSubnet(oldObj, newObj interface{}) { } if oldSubnet.Spec.Vpc != newSubnet.Spec.Vpc && - !(oldSubnet.Spec.Vpc == "" && newSubnet.Spec.Vpc == c.config.ClusterRouter || - oldSubnet.Spec.Vpc == c.config.ClusterRouter && newSubnet.Spec.Vpc == "") { + !(oldSubnet.Spec.Vpc == "" && newSubnet.Spec.Vpc == c.config.ClusterRouter || oldSubnet.Spec.Vpc == c.config.ClusterRouter && newSubnet.Spec.Vpc == "") { + + if newSubnet.Annotations == nil { + newSubnet.Annotations = make(map[string]string) + } + if oldSubnet.Spec.Vpc == "" { newSubnet.Annotations[util.VpcLastName] = c.config.ClusterRouter } else { newSubnet.Annotations[util.VpcLastName] = oldSubnet.Spec.Vpc } + c.updateVpcStatusQueue.Add(oldSubnet.Spec.Vpc) }