diff --git a/pkg/ovn_ic_controller/ovn_ic_controller.go b/pkg/ovn_ic_controller/ovn_ic_controller.go index 291fec149e0..0c4027f1d16 100644 --- a/pkg/ovn_ic_controller/ovn_ic_controller.go +++ b/pkg/ovn_ic_controller/ovn_ic_controller.go @@ -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) @@ -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) } @@ -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) } diff --git a/pkg/ovs/ovn-ic-sbctl.go b/pkg/ovs/ovn-ic-sbctl.go index 92e60b71161..a864d57c391 100644 --- a/pkg/ovs/ovn-ic-sbctl.go +++ b/pkg/ovs/ovn-ic-sbctl.go @@ -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