Skip to content

Commit

Permalink
fix: ovnic del old AZ after establish the new as name (#2229)
Browse files Browse the repository at this point in the history
  • Loading branch information
lut777 committed Jan 11, 2023
1 parent b0c17af commit 3f5bd39
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -236,8 +236,8 @@ kind-init-ipv4: kind-clean
@$(MAKE) kind-create

.PHONY: kind-init-ovn-ic
kind-init-ovn-ic: kind-clean-ovn-ic kind-init-single
@single=true $(MAKE) kind-generate-config
kind-init-ovn-ic: kind-clean-ovn-ic kind-init-ha
@ha=true $(MAKE) kind-generate-config
$(call kind_create_cluster,yamls/kind.yaml,kube-ovn1)

.PHONY: kind-init-iptables
Expand Down
13 changes: 7 additions & 6 deletions pkg/controller/ovn-ic.go
Expand Up @@ -106,16 +106,17 @@ func (c *Controller) resyncInterConnection() {
}
c.ovnLegacyClient.OvnICSbAddress = genHostAddress(cm.Data["ic-db-host"], cm.Data["ic-sb-port"])

if err := c.RemoveOldChassisInSbDB(); err != nil {
klog.Errorf("failed to remove remote chassis: %v", err)
}

c.ovnLegacyClient.OvnICNbAddress = genHostAddress(cm.Data["ic-db-host"], cm.Data["ic-nb-port"])
klog.Info("start to reestablish ovn-ic")
if err := c.establishInterConnection(cm.Data); err != nil {
klog.Errorf("failed to reestablish ovn-ic, %v", err)
return
}

if err := c.RemoveOldChassisInSbDB(lastIcCm["az-name"]); err != nil {
klog.Errorf("failed to remove remote chassis: %v", err)
}

icEnabled = "true"
lastIcCm = cm.Data
klog.Info("finish reestablishing ovn-ic")
Expand Down Expand Up @@ -400,8 +401,8 @@ func (c *Controller) SynRouteToPolicy() {
c.syncOneRouteToPolicy(util.OvnICKey, util.OvnICStatic)
}

func (c *Controller) RemoveOldChassisInSbDB() error {
azUUID, err := c.ovnLegacyClient.GetAzUUID(lastIcCm["az-name"])
func (c *Controller) RemoveOldChassisInSbDB(azName string) error {
azUUID, err := c.ovnLegacyClient.GetAzUUID(azName)
if err != nil {
klog.Errorf("failed to get UUID of AZ %s: %v", lastIcCm["az-name"], err)
}
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/ovn-ic/e2e_test.go
Expand Up @@ -194,6 +194,14 @@ var _ = framework.OrderedDescribe("[group:ovn-ic]", func() {
ginkgo.By("Waiting for new az names to be applied")
time.Sleep(10 * time.Second)

pods, err := clientSets[0].CoreV1().Pods("kube-system").List(context.TODO(), metav1.ListOptions{LabelSelector: "app=ovs"})
framework.ExpectNoError(err, "failed to get ovs-ovn pods")
cmd := "ovn-appctl -t ovn-controller inc-engine/recompute"
for _, pod := range pods.Items {
execPodOrDie(frameworks[0].KubeContext, "kube-system", pod.Name, cmd)
}
time.Sleep(2 * time.Second)

ginkgo.By("Ensuring logical switch ts exists in cluster " + clusters[0])
output := execOrDie(frameworks[0].KubeContext, "ko nbctl show ts")
for _, az := range azNames {
Expand Down

0 comments on commit 3f5bd39

Please sign in to comment.