Skip to content

Commit

Permalink
server: ssh: Retry agent status for 30 seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
ish-hcc committed Sep 6, 2024
1 parent 96c3a31 commit 5716e6b
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions server/lib/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,17 +248,24 @@ func (o *SSH) getBenchmarkTypes(types string) []string {
}

func (o *SSH) checkAgentStatus() (string, error) {
output, err := o.RunCmd("curl -o /dev/null -w '%{http_code}' -X GET http://localhost:8082/honeybee-agent/readyz -H 'accept: application/json'")
if err != nil {
logger.Println(logger.ERROR, true, "SSH: Failed to run command: "+
output+" (Error: "+err.Error())
return "failed", err
}
tryCount := 30

if output == "200" {
return "success", nil
for i := 0; i < tryCount; i++ {
output, err := o.RunCmd("curl -o /dev/null -w '%{http_code}' -X GET http://localhost:8082/honeybee-agent/readyz -H 'accept: application/json'")
if err != nil {
time.Sleep(1 * time.Second)
continue
}

if output == "200" {
return "success", nil
}

time.Sleep(1 * time.Second)
continue
}
return "failed", nil

return "failed", errors.New("agent health check failed")
}
func (o *SSH) getAuthMethods(connectionInfo model.ConnectionInfo) []ssh.AuthMethod {
var methods []ssh.AuthMethod
Expand Down

0 comments on commit 5716e6b

Please sign in to comment.