fix(runner): error code validation

This commit is contained in:
Denis Gukov 2024-10-14 21:07:24 +00:00
parent 54296bd4bf
commit fd782bc1cb

View File

@ -277,11 +277,14 @@ func (p *JobPool) sendProgress() {
resp, err := client.Do(req)
if err != nil {
logger.ActionError(err, "send request", "the server returned error "+strconv.Itoa(resp.StatusCode))
logger.ActionError(err, "send request", "the server returned error")
return
}
if resp.StatusCode >= 400 {
logger.ActionError(fmt.Errorf("invalid status code"), "send request", "the server returned error "+strconv.Itoa(resp.StatusCode))
}
defer resp.Body.Close()
}
@ -318,8 +321,14 @@ func (p *JobPool) tryRegisterRunner() bool {
}
resp, err := client.Do(req)
if err != nil || resp.StatusCode != 200 {
logger.ActionError(err, "send request", "the server returned error "+strconv.Itoa(resp.StatusCode))
if err != nil {
logger.ActionError(err, "send request", "unexpected error")
return false
}
if resp.StatusCode != 200 {
logger.ActionError(fmt.Errorf("invalid status code"), "send request", "the server returned error "+strconv.Itoa(resp.StatusCode))
return false
}
@ -378,7 +387,7 @@ func (p *JobPool) checkNewJobs() {
resp, err := client.Do(req)
if err != nil {
logger.ActionError(err, "send request", "the server returned an error"+strconv.Itoa(resp.StatusCode))
logger.ActionError(err, "send request", "upexpected error")
return
}