Skip to content

Commit

Permalink
Wait for FRR reload to complete, restart if failed
Browse files Browse the repository at this point in the history
  • Loading branch information
chdxD1 committed Oct 10, 2023
1 parent 0d20295 commit 1833b0d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions pkg/frr/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,22 @@ func (*Manager) ReloadFRR() error {
}
defer con.Close()

_, err = con.ReloadUnitContext(context.Background(), frrUnit, "fail", nil)
if err != nil {
jobChan := make(chan string)
if _, err = con.ReloadUnitContext(context.Background(), frrUnit, "fail", jobChan); err != nil {
return fmt.Errorf("error reloading %s context: %w", frrUnit, err)
}
reloadStatus := <-jobChan
if reloadStatus == "done" {
return nil
}

if _, err = con.RestartUnitContext(context.Background(), frrUnit, "fail", jobChan); err != nil {
return fmt.Errorf("error restarting %s context: %w", frrUnit, err)
}
restartStatus := <-jobChan
if restartStatus != "done" {
return fmt.Errorf("error restarting unit after failed reload: %s (reload error: %s)", restartStatus, reloadStatus)
}
return nil
}

Expand Down

0 comments on commit 1833b0d

Please sign in to comment.