diff --git a/dist/images/start-ic-db.sh b/dist/images/start-ic-db.sh index 9d86c086a8e..031a6e83e97 100755 --- a/dist/images/start-ic-db.sh +++ b/dist/images/start-ic-db.sh @@ -1,10 +1,10 @@ #!/bin/bash set -eo pipefail -TS_NAME=${TS_NAME:-ts} LOCAL_IP=${LOCAL_IP:-$POD_IP} TS_NUM=${TS_NUM:-ts} ENABLE_BIND_LOCAL_IP=${ENABLE_BIND_LOCAL_IP:-true} +ENABLE_OVN_LEADER_CHECK=${ENABLE_OVN_LEADER_CHECK:-true} DB_ADDR=:: if [[ $ENABLE_BIND_LOCAL_IP == "true" ]]; then @@ -211,5 +211,11 @@ else fi fi -chmod 600 /etc/ovn/* -/kube-ovn/kube-ovn-leader-checker --probeInterval=${OVN_LEADER_PROBE_INTERVAL} --isICDBServer=true +if [[ $ENABLE_OVN_LEADER_CHECK == "true" ]]; then + chmod 600 /etc/ovn/* + /kube-ovn/kube-ovn-leader-checker --probeInterval=${OVN_LEADER_PROBE_INTERVAL} --isICDBServer=true +else + + tail --follow=name --retry /var/log/ovn/ovsdb-server-ic-nb.log +fi + diff --git a/pkg/ovn_ic_controller/ovn_ic_controller.go b/pkg/ovn_ic_controller/ovn_ic_controller.go index a8d252813b8..ff9c8ff846e 100644 --- a/pkg/ovn_ic_controller/ovn_ic_controller.go +++ b/pkg/ovn_ic_controller/ovn_ic_controller.go @@ -263,7 +263,7 @@ func (c *Controller) establishInterConnection(config map[string]string) error { chassises := make([]string, len(gwNodes)) for i, tsName := range tsNames { - gwNodesOrdered := moveElements(gwNodes, i) + gwNodesOrdered := generateNewOrdergwNodes(gwNodes, i) for j, gw := range gwNodesOrdered { gw = strings.TrimSpace(gw) chassisID, err := c.ovnLegacyClient.GetChassis(gw) @@ -483,9 +483,18 @@ func (c *Controller) RemoveOldChassisInSbDB(azName string) error { return err } - c.ovnLegacyClient.DestroyPortBindings(portBindings) - c.ovnLegacyClient.DestroyGateways(gateways) - c.ovnLegacyClient.DestroyRoutes(routes) + if err := c.ovnLegacyClient.DestroyPortBindings(portBindings); err != nil { + return err + } + + if err := c.ovnLegacyClient.DestroyGateways(gateways); err != nil { + return err + } + + if err := c.ovnLegacyClient.DestroyRoutes(routes); err != nil { + return err + } + return c.ovnLegacyClient.DestroyChassis(azUUID) } @@ -562,7 +571,7 @@ func (c *Controller) syncOneRouteToPolicy(key, value string) { } } -func moveElements(arr []string, order int) []string { +func generateNewOrdergwNodes(arr []string, order int) []string { if order >= len(arr) { order = order % len(arr) } diff --git a/pkg/ovs/ovn-ic-sbctl.go b/pkg/ovs/ovn-ic-sbctl.go index c0f3dffb3e7..dcf29135d4d 100644 --- a/pkg/ovs/ovn-ic-sbctl.go +++ b/pkg/ovs/ovn-ic-sbctl.go @@ -99,31 +99,31 @@ func (c LegacyClient) GetPortBindingUUIDsInOneAZ(uuid string) ([]string, error) return portBindings, nil } -func (c LegacyClient) DestroyGateways(uuids []string) { +func (c LegacyClient) DestroyGateways(uuids []string) error { for _, uuid := range uuids { if err := c.DestroyTableWithUUID(uuid, "gateway"); err != nil { - klog.Errorf("failed to delete gateway %v: %v", uuid, err) + return fmt.Errorf("failed to delete gateway %v: %v", uuid, err) } - continue } + return nil } -func (c LegacyClient) DestroyRoutes(uuids []string) { +func (c LegacyClient) DestroyRoutes(uuids []string) error { for _, uuid := range uuids { if err := c.DestroyTableWithUUID(uuid, "route"); err != nil { - klog.Errorf("failed to delete route %v: %v", uuid, err) + return fmt.Errorf("failed to delete route %v: %v", uuid, err) } - continue } + return nil } -func (c LegacyClient) DestroyPortBindings(uuids []string) { +func (c LegacyClient) DestroyPortBindings(uuids []string) error { for _, uuid := range uuids { if err := c.DestroyTableWithUUID(uuid, "Port_Binding"); err != nil { - klog.Errorf("failed to delete Port_Binding %v: %v", uuid, err) + return fmt.Errorf("failed to delete Port_Binding %v: %v", uuid, err) } - continue } + return nil } func (c LegacyClient) DestroyChassis(uuid string) error {