Skip to content

Commit

Permalink
fix: run bootstrap sequence in a loop continuously
Browse files Browse the repository at this point in the history
Signed-off-by: Bhoopesh <[email protected]>
  • Loading branch information
bhoopesh369 committed Jun 25, 2024
1 parent 1bb6e2c commit d376715
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
13 changes: 13 additions & 0 deletions sztp-agent/pkg/secureagent/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ const (

// RunCommandDaemon runs the command in the background
func (a *Agent) RunCommandDaemon() error {
for {
err := a.performBootstrapSequence()
if err != nil {
log.Println("[ERROR] Failed to perform the bootstrap sequence: ", err.Error())
log.Println("[INFO] Retrying in 5 seconds")
time.Sleep(5 * time.Second)
continue
}
return nil
}
}

func (a *Agent) performBootstrapSequence() error {
var err error
if a.GetBootstrapURL() == "" {
err = a.getBootstrapURL()
Expand Down
8 changes: 7 additions & 1 deletion sztp-agent/pkg/secureagent/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ import "log"

// RunCommand runs the command in the background
func (a *Agent) RunCommand() error {
log.Println("runCommand")
log.Println("runCommand started")
err := a.performBootstrapSequence()
if err != nil {
log.Println("Error in performBootstrapSequence inside runCommand: ", err)
return err
}
log.Println("runCommand finished")
return nil
}

Expand Down

0 comments on commit d376715

Please sign in to comment.