Allow bypassing Unauthorized error when deleting runner
This change allows users to bypass GitHub Unauthorized errors when removing github runners. This means that removing runners will now be possible even if the pool manager is stopped. There is a new flag added to the runner rm command and to the API that tells GARM to bypass pool being stopped and any 401 error returned by GitHub. This means you will be able to remove the runners from garm and your provider, but will mean that the runner will still exist in github as "offline" if the credentials are not updated or the runner manually removed. Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
df72c4917e
commit
9a6770c3a3
19 changed files with 730 additions and 123 deletions
|
|
@ -941,17 +941,10 @@ func (r *Runner) getPoolManagerFromInstance(ctx context.Context, instance params
|
|||
return poolMgr, nil
|
||||
}
|
||||
|
||||
// ForceDeleteRunner will attempt to remove a runner from a pool.
|
||||
//
|
||||
// Deprecated: FunctionName is deprecated. Use DeleteRunner instead.
|
||||
func (r *Runner) ForceDeleteRunner(ctx context.Context, instanceName string) error {
|
||||
return r.DeleteRunner(ctx, instanceName, true)
|
||||
}
|
||||
|
||||
// DeleteRunner removes a runner from a pool. If forceDelete is true, GARM will ignore any provider errors
|
||||
// that may occur, and attempt to remove the runner from GitHub and then the database, regardless of provider
|
||||
// errors.
|
||||
func (r *Runner) DeleteRunner(ctx context.Context, instanceName string, forceDelete bool) error {
|
||||
func (r *Runner) DeleteRunner(ctx context.Context, instanceName string, forceDelete, bypassGithubUnauthorized bool) error {
|
||||
if !auth.IsAdmin(ctx) {
|
||||
return runnerErrors.ErrUnauthorized
|
||||
}
|
||||
|
|
@ -979,7 +972,7 @@ func (r *Runner) DeleteRunner(ctx context.Context, instanceName string, forceDel
|
|||
return errors.Wrap(err, "fetching pool manager for instance")
|
||||
}
|
||||
|
||||
if err := poolMgr.DeleteRunner(instance, forceDelete); err != nil {
|
||||
if err := poolMgr.DeleteRunner(instance, forceDelete, bypassGithubUnauthorized); err != nil {
|
||||
return errors.Wrap(err, "removing runner")
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue