Skip to content

Commit a8cd943

Browse files
fix(register): handle nil response (#217)
1 parent 78fc934 commit a8cd943

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cmd/vela-worker/register.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,16 @@ func (w *Worker) checkIn(config *library.Worker) error {
1818
logrus.Infof("retrieving worker %s from the server", config.GetHostname())
1919
_, resp, err := w.VelaClient.Worker.Get(config.GetHostname())
2020
if err != nil {
21+
respErr := fmt.Errorf("unable to retrieve worker %s from the server: %v", config.GetHostname(), err)
22+
if resp == nil {
23+
return respErr
24+
}
2125
// if we receive a 404 the worker needs to be registered
2226
if resp.StatusCode == http.StatusNotFound {
2327
return w.register(config)
2428
}
2529

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

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

0 commit comments

Comments
 (0)