Skip to content

Commit

Permalink
update check conditions of vpc names
Browse files Browse the repository at this point in the history
Signed-off-by: 夜微澜 <[email protected]>
  • Loading branch information
qiutingjun committed Sep 25, 2023
1 parent b5b89b6 commit 0df7c72
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ func (c *Controller) enqueueUpdateSubnet(oldObj, newObj interface{}) {
return
}

if oldSubnet.Spec.Vpc != newSubnet.Spec.Vpc {
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 == "") {
if oldSubnet.Spec.Vpc == "" {
newSubnet.Annotations[util.VpcLastName] = c.config.ClusterRouter
} else {
Expand Down Expand Up @@ -562,7 +564,8 @@ func (c *Controller) validateVpcBySubnet(subnet *kubeovnv1.Subnet) (*kubeovnv1.V
return vpc, err
}
for _, vpc := range vpcs {
if (subnet.Annotations[util.VpcLastName] == "" && subnet.Spec.Vpc != vpc.Name || subnet.Annotations[util.VpcLastName] != "" && subnet.Annotations[util.VpcLastName] != vpc.Name) &&
if (subnet.Annotations[util.VpcLastName] == "" && subnet.Spec.Vpc != vpc.Name ||
subnet.Annotations[util.VpcLastName] != "" && subnet.Annotations[util.VpcLastName] != vpc.Name) &&
!vpc.Status.Default && util.IsStringsOverlap(vpc.Spec.Namespaces, subnet.Spec.Namespaces) {
err = fmt.Errorf("namespaces %v are overlap with vpc '%s'", subnet.Spec.Namespaces, vpc.Name)
klog.Error(err)
Expand Down

0 comments on commit 0df7c72

Please sign in to comment.