Skip to content

Commit 572a2e8

Browse files
committed
fix deleting old sb chassis for a re-added node (#2989)
1 parent abda156 commit 572a2e8

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

pkg/controller/node.go

+2-5
Original file line numberDiff line numberDiff line change
@@ -581,11 +581,8 @@ func (c *Controller) handleUpdateNode(key string) error {
581581
return err
582582
}
583583

584-
if node.Annotations[util.ChassisAnnotation] != "" {
585-
if err = c.ovnLegacyClient.InitChassisNodeTag(node.Annotations[util.ChassisAnnotation], node.Name); err != nil {
586-
klog.Errorf("failed to set chassis nodeTag for node '%s', %v", node.Name, err)
587-
return err
588-
}
584+
if err := c.validateChassis(node); err != nil {
585+
return err
589586
}
590587
if err := c.retryDelDupChassis(util.ChasRetryTime, util.ChasRetryIntev+2, c.checkChassisDupl, node); err != nil {
591588
return err

pkg/ovs/ovn-sbctl.go

+7-11
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,15 @@ func (c LegacyClient) ovnSbCommand(cmdArgs ...string) (string, error) {
5252
}
5353

5454
func (c LegacyClient) DeleteChassisByNode(node string) error {
55-
output, err := c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("external_ids:node=%s", node))
55+
chassis, err := c.GetChassis(node)
5656
if err != nil {
5757
return fmt.Errorf("failed to get node chassis %s, %v", node, err)
5858
}
59-
for _, chassis := range strings.Split(output, "\n") {
60-
chassis = strings.TrimSpace(chassis)
61-
if len(chassis) > 0 {
62-
if err := c.DeleteChassisByName(chassis); err != nil {
63-
return err
64-
}
65-
}
59+
if chassis == "" {
60+
return nil
6661
}
67-
return nil
62+
63+
return c.DeleteChassisByName(chassis)
6864
}
6965

7066
func (c LegacyClient) DeleteChassisByName(chassisName string) error {
@@ -84,12 +80,12 @@ func (c LegacyClient) DeleteChassisByName(chassisName string) error {
8480
}
8581

8682
func (c LegacyClient) GetChassis(node string) (string, error) {
87-
output, err := c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("hostname=%s", node))
83+
output, err := c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("external_ids:node=%s", node))
8884
if err != nil {
8985
return "", fmt.Errorf("failed to find node chassis %s, %v", node, err)
9086
}
9187
if len(output) == 0 {
92-
output, err = c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("external_ids:node=%s", node))
88+
output, err = c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("hostname=%s", node))
9389
if err != nil {
9490
return "", fmt.Errorf("failed to find node chassis %s, %v", node, err)
9591
}

0 commit comments

Comments
 (0)