Skip to content

Commit

Permalink
1. fix some delete logical
Browse files Browse the repository at this point in the history
2. refactor function name

Signed-off-by: Changlu Yi <[email protected]>
  • Loading branch information
changluyi committed Jan 29, 2024
1 parent 5420fce commit 7e91429
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
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 @@ -303,7 +303,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)
chassis, err := c.OVNSbClient.GetChassisByHost(gw)
Expand Down Expand Up @@ -561,9 +561,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 @@ -674,7 +683,7 @@ func (c *Controller) listRemoteLogicalSwitchPortAddress() (*strset.Set, error) {
return existAddress, nil
}

func moveElements(arr []string, order int) []string {
func generateNewOrdergwNodes(arr []string, order int) []string {
if order >= len(arr) {
order %= len(arr)
}
Expand Down
19 changes: 9 additions & 10 deletions pkg/ovs/ovn-ic-sbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,36 +105,35 @@ 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 {
if err := c.DestroyTableWithUUID(uuid, "availability_zone"); err != nil {
klog.Error(err)
return fmt.Errorf("failed to delete chassis %v: %v", uuid, err)
}
return nil
Expand Down

0 comments on commit 7e91429

Please sign in to comment.