Allow deletion of a runner in error state

Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
Gabriel Adrian Samfira 2022-07-16 13:41:26 +00:00
parent ecd476af02
commit dede5cc465
2 changed files with 10 additions and 5 deletions

View file

@ -845,14 +845,17 @@ func (r *basePool) ForceDeleteRunner(runner params.Instance) error {
if resp != nil {
switch resp.StatusCode {
case http.StatusUnprocessableEntity:
return errors.Wrapf(runnerErrors.ErrUnprocessable, "removing runner: %q", err)
return errors.Wrapf(runnerErrors.ErrBadRequest, "removing runner: %q", err)
case http.StatusNotFound:
return errors.Wrapf(runnerErrors.ErrNotFound, "removing runner: %q", err)
// Runner may have been deleted by a finished job, or manually by the user.
log.Printf("runner with agent id %d was not found in github", runner.AgentID)
default:
return errors.Wrap(err, "removing runner")
}
} else {
// We got a nil response. Assume we are in error.
return errors.Wrap(err, "removing runner")
}
return errors.Wrap(err, "removing runner")
}
}

View file

@ -520,8 +520,10 @@ func (r *Runner) ForceDeleteRunner(ctx context.Context, instanceName string) err
return errors.Wrap(err, "fetching instance")
}
if instance.Status != providerCommon.InstanceRunning {
return runnerErrors.NewBadRequestError("runner must be in %q state", providerCommon.InstanceRunning)
switch instance.Status {
case providerCommon.InstanceRunning, providerCommon.InstanceError:
default:
return runnerErrors.NewBadRequestError("runner must be in %q or %q state", providerCommon.InstanceRunning, providerCommon.InstanceError)
}
pool, err := r.store.GetPoolByID(ctx, instance.PoolID)