Skip to content

Commit

Permalink
sync master change to 1.11 (#3674)
Browse files Browse the repository at this point in the history
1. refactor delete logical
2. add ENABLE_OVN_LEADER_CHECK for start-ic-db.sh

Signed-off-by: Changlu Yi <clyi@alauda.io>
  • Loading branch information
changluyi committed Jan 29, 2024
1 parent 0e98a62 commit 6f29efd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 17 deletions.
12 changes: 9 additions & 3 deletions dist/images/start-ic-db.sh
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

19 changes: 14 additions & 5 deletions pkg/ovn_ic_controller/ovn_ic_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/ovs/ovn-ic-sbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6f29efd

Please sign in to comment.