Skip to content

Commit

Permalink
fix(register): handle nil response (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanSussman authored Oct 21, 2021
1 parent 78fc934 commit a8cd943
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/vela-worker/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ func (w *Worker) checkIn(config *library.Worker) error {
logrus.Infof("retrieving worker %s from the server", config.GetHostname())
_, resp, err := w.VelaClient.Worker.Get(config.GetHostname())
if err != nil {
respErr := fmt.Errorf("unable to retrieve worker %s from the server: %v", config.GetHostname(), err)
if resp == nil {
return respErr
}
// if we receive a 404 the worker needs to be registered
if resp.StatusCode == http.StatusNotFound {
return w.register(config)
}

return fmt.Errorf("unable to retrieve worker %s from the server: %v", config.GetHostname(), err)
return respErr
}

// if we were able to GET the worker, update it
Expand Down

0 comments on commit a8cd943

Please sign in to comment.