Skip to content

Commit

Permalink
update ns annotation when subnet cidr changed (#1921)
Browse files Browse the repository at this point in the history
  • Loading branch information
hongzhen-ma committed Sep 20, 2022
1 parent 3e00aa5 commit efa8f60
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion pkg/controller/namespace.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ func (c *Controller) handleAddNamespace(key string) error {
if namespace.Annotations == nil || len(namespace.Annotations) == 0 {
namespace.Annotations = map[string]string{}
} else {
if namespace.Annotations[util.LogicalSwitchAnnotation] == strings.Join(lss, ",") {
if namespace.Annotations[util.LogicalSwitchAnnotation] == strings.Join(lss, ",") &&
namespace.Annotations[util.CidrAnnotation] == strings.Join(cidrs, ";") &&
namespace.Annotations[util.ExcludeIpsAnnotation] == strings.Join(excludeIps, ";") {
return nil
}
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,8 @@ func (c *Controller) reconcileNamespaces(subnet *kubeovnv1.Subnet) error {
}

for _, ns := range namespaces {
if ns.Annotations != nil && !util.ContainsString(subnet.Spec.Namespaces, ns.Name) && util.ContainsString(strings.Split(ns.Annotations[util.LogicalSwitchAnnotation], ","), subnet.Name) {
// when subnet cidr changed, the ns annotation with the subnet should be updated
if ns.Annotations != nil && util.ContainsString(strings.Split(ns.Annotations[util.LogicalSwitchAnnotation], ","), subnet.Name) {
c.addNamespaceQueue.Add(ns.Name)
}
}
Expand Down

0 comments on commit efa8f60

Please sign in to comment.