Add force delete runner
This branch adds the ability to forcefully remove a runner from GARM. When the operator wishes to manually remove a runner, the workflow is as follows: * Check that the runner exists in GitHub. If it does, attempt to remove it. An error here indicates that the runner may be processing a job. In this case, we don't continue and the operator gets immediate feedback from the API. * Mark the runner in the database as pending_delete * Allow the consolidate loop to reap it from the provider and remove it from the database. Removing the instance from the provider is async. If the provider errs out, GARM will keep trying to remove it in perpetuity until the provider succedes. In situations where the provider is misconfigured, this will never happen, leaving the instance in a permanent state of pending_delete. A provider may fail for various reasons. Either credentials have expired, the API endpoint has changed, the provider is misconfigured or the operator may just have removed it from the config before cleaning up the runners. While some cases are recoverable, some are not. We cannot have a situation in which we cannot clean resources in garm because of a misconfiguration. This change adds the pending_force_delete instance status. Instances marked with this status, will be removed from GARM even if the provider reports an error. The GARM cli has been modified to give new meaning to the --force-remove-runner option. This option in the CLI is no longer mandatory. Instead, setting it will mark the runner with the new pending_force_delete status. Omitting it will mark the runner with the old status of pending_delete. Fixes: #160 Signed-off-by: Gabriel Adrian Samfira <gsamfira@cloudbasesolutions.com>
This commit is contained in:
parent
7f4f4bd7e1
commit
d09f12dfd8
19 changed files with 221 additions and 88 deletions
|
|
@ -14,6 +14,7 @@ import (
|
|||
"github.com/go-openapi/runtime"
|
||||
cr "github.com/go-openapi/runtime/client"
|
||||
"github.com/go-openapi/strfmt"
|
||||
"github.com/go-openapi/swag"
|
||||
)
|
||||
|
||||
// NewDeleteInstanceParams creates a new DeleteInstanceParams object,
|
||||
|
|
@ -61,6 +62,12 @@ DeleteInstanceParams contains all the parameters to send to the API endpoint
|
|||
*/
|
||||
type DeleteInstanceParams struct {
|
||||
|
||||
/* ForceRemove.
|
||||
|
||||
If true GARM will ignore any provider error when removing the runner and will continue to remove the runner from github and the GARM database.
|
||||
*/
|
||||
ForceRemove *bool
|
||||
|
||||
/* InstanceName.
|
||||
|
||||
Runner instance name.
|
||||
|
|
@ -120,6 +127,17 @@ func (o *DeleteInstanceParams) SetHTTPClient(client *http.Client) {
|
|||
o.HTTPClient = client
|
||||
}
|
||||
|
||||
// WithForceRemove adds the forceRemove to the delete instance params
|
||||
func (o *DeleteInstanceParams) WithForceRemove(forceRemove *bool) *DeleteInstanceParams {
|
||||
o.SetForceRemove(forceRemove)
|
||||
return o
|
||||
}
|
||||
|
||||
// SetForceRemove adds the forceRemove to the delete instance params
|
||||
func (o *DeleteInstanceParams) SetForceRemove(forceRemove *bool) {
|
||||
o.ForceRemove = forceRemove
|
||||
}
|
||||
|
||||
// WithInstanceName adds the instanceName to the delete instance params
|
||||
func (o *DeleteInstanceParams) WithInstanceName(instanceName string) *DeleteInstanceParams {
|
||||
o.SetInstanceName(instanceName)
|
||||
|
|
@ -139,6 +157,23 @@ func (o *DeleteInstanceParams) WriteToRequest(r runtime.ClientRequest, reg strfm
|
|||
}
|
||||
var res []error
|
||||
|
||||
if o.ForceRemove != nil {
|
||||
|
||||
// query param forceRemove
|
||||
var qrForceRemove bool
|
||||
|
||||
if o.ForceRemove != nil {
|
||||
qrForceRemove = *o.ForceRemove
|
||||
}
|
||||
qForceRemove := swag.FormatBool(qrForceRemove)
|
||||
if qForceRemove != "" {
|
||||
|
||||
if err := r.SetQueryParam("forceRemove", qForceRemove); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// path param instanceName
|
||||
if err := r.SetPathParam("instanceName", o.InstanceName); err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue