Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix deleting old sb chassis for a re-added node #2989

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions pkg/controller/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -612,11 +612,8 @@ func (c *Controller) handleUpdateNode(key string) error {
return err
}

if node.Annotations[util.ChassisAnnotation] != "" {
if err = c.ovnLegacyClient.InitChassisNodeTag(node.Annotations[util.ChassisAnnotation], node.Name); err != nil {
klog.Errorf("failed to set chassis nodeTag for node '%s', %v", node.Name, err)
return err
}
if err := c.validateChassis(node); err != nil {
return err
}
if err := c.retryDelDupChassis(util.ChasRetryTime, util.ChasRetryIntev+2, c.checkChassisDupl, node); err != nil {
return err
Expand Down
18 changes: 7 additions & 11 deletions pkg/ovs/ovn-sbctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,15 @@ func (c LegacyClient) ovnSbCommand(cmdArgs ...string) (string, error) {
}

func (c LegacyClient) DeleteChassisByNode(node string) error {
output, err := c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("external_ids:node=%s", node))
chassis, err := c.GetChassis(node)
if err != nil {
return fmt.Errorf("failed to get node chassis %s, %v", node, err)
}
for _, chassis := range strings.Split(output, "\n") {
chassis = strings.TrimSpace(chassis)
if len(chassis) > 0 {
if err := c.DeleteChassisByName(chassis); err != nil {
return err
}
}
if chassis == "" {
return nil
}
return nil

return c.DeleteChassisByName(chassis)
}

func (c LegacyClient) DeleteChassisByName(chassisName string) error {
Expand All @@ -84,12 +80,12 @@ func (c LegacyClient) DeleteChassisByName(chassisName string) error {
}

func (c LegacyClient) GetChassis(node string) (string, error) {
output, err := c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("hostname=%s", node))
output, err := c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("external_ids:node=%s", node))
if err != nil {
return "", fmt.Errorf("failed to find node chassis %s, %v", node, err)
}
if len(output) == 0 {
output, err = c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("external_ids:node=%s", node))
output, err = c.ovnSbCommand("--format=csv", "--no-heading", "--data=bare", "--columns=name", "find", "chassis", fmt.Sprintf("hostname=%s", node))
if err != nil {
return "", fmt.Errorf("failed to find node chassis %s, %v", node, err)
}
Expand Down