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>
389 lines
11 KiB
Go
389 lines
11 KiB
Go
// Code generated by mockery v2.28.1. DO NOT EDIT.
|
|
|
|
package mocks
|
|
|
|
import (
|
|
context "context"
|
|
|
|
common "github.com/cloudbase/garm/runner/common"
|
|
|
|
databasecommon "github.com/cloudbase/garm/database/common"
|
|
|
|
mock "github.com/stretchr/testify/mock"
|
|
|
|
params "github.com/cloudbase/garm/params"
|
|
)
|
|
|
|
// PoolManagerController is an autogenerated mock type for the PoolManagerController type
|
|
type PoolManagerController struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// CreateEnterprisePoolManager provides a mock function with given fields: ctx, enterprise, providers, store
|
|
func (_m *PoolManagerController) CreateEnterprisePoolManager(ctx context.Context, enterprise params.Enterprise, providers map[string]common.Provider, store databasecommon.Store) (common.PoolManager, error) {
|
|
ret := _m.Called(ctx, enterprise, providers, store)
|
|
|
|
var r0 common.PoolManager
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(context.Context, params.Enterprise, map[string]common.Provider, databasecommon.Store) (common.PoolManager, error)); ok {
|
|
return rf(ctx, enterprise, providers, store)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(context.Context, params.Enterprise, map[string]common.Provider, databasecommon.Store) common.PoolManager); ok {
|
|
r0 = rf(ctx, enterprise, providers, store)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(common.PoolManager)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(context.Context, params.Enterprise, map[string]common.Provider, databasecommon.Store) error); ok {
|
|
r1 = rf(ctx, enterprise, providers, store)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// CreateOrgPoolManager provides a mock function with given fields: ctx, org, providers, store
|
|
func (_m *PoolManagerController) CreateOrgPoolManager(ctx context.Context, org params.Organization, providers map[string]common.Provider, store databasecommon.Store) (common.PoolManager, error) {
|
|
ret := _m.Called(ctx, org, providers, store)
|
|
|
|
var r0 common.PoolManager
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(context.Context, params.Organization, map[string]common.Provider, databasecommon.Store) (common.PoolManager, error)); ok {
|
|
return rf(ctx, org, providers, store)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(context.Context, params.Organization, map[string]common.Provider, databasecommon.Store) common.PoolManager); ok {
|
|
r0 = rf(ctx, org, providers, store)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(common.PoolManager)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(context.Context, params.Organization, map[string]common.Provider, databasecommon.Store) error); ok {
|
|
r1 = rf(ctx, org, providers, store)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// CreateRepoPoolManager provides a mock function with given fields: ctx, repo, providers, store
|
|
func (_m *PoolManagerController) CreateRepoPoolManager(ctx context.Context, repo params.Repository, providers map[string]common.Provider, store databasecommon.Store) (common.PoolManager, error) {
|
|
ret := _m.Called(ctx, repo, providers, store)
|
|
|
|
var r0 common.PoolManager
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(context.Context, params.Repository, map[string]common.Provider, databasecommon.Store) (common.PoolManager, error)); ok {
|
|
return rf(ctx, repo, providers, store)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(context.Context, params.Repository, map[string]common.Provider, databasecommon.Store) common.PoolManager); ok {
|
|
r0 = rf(ctx, repo, providers, store)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(common.PoolManager)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(context.Context, params.Repository, map[string]common.Provider, databasecommon.Store) error); ok {
|
|
r1 = rf(ctx, repo, providers, store)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// DeleteEnterprisePoolManager provides a mock function with given fields: enterprise
|
|
func (_m *PoolManagerController) DeleteEnterprisePoolManager(enterprise params.Enterprise) error {
|
|
ret := _m.Called(enterprise)
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(params.Enterprise) error); ok {
|
|
r0 = rf(enterprise)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// DeleteOrgPoolManager provides a mock function with given fields: org
|
|
func (_m *PoolManagerController) DeleteOrgPoolManager(org params.Organization) error {
|
|
ret := _m.Called(org)
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(params.Organization) error); ok {
|
|
r0 = rf(org)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// DeleteRepoPoolManager provides a mock function with given fields: repo
|
|
func (_m *PoolManagerController) DeleteRepoPoolManager(repo params.Repository) error {
|
|
ret := _m.Called(repo)
|
|
|
|
var r0 error
|
|
if rf, ok := ret.Get(0).(func(params.Repository) error); ok {
|
|
r0 = rf(repo)
|
|
} else {
|
|
r0 = ret.Error(0)
|
|
}
|
|
|
|
return r0
|
|
}
|
|
|
|
// GetEnterprisePoolManager provides a mock function with given fields: enterprise
|
|
func (_m *PoolManagerController) GetEnterprisePoolManager(enterprise params.Enterprise) (common.PoolManager, error) {
|
|
ret := _m.Called(enterprise)
|
|
|
|
var r0 common.PoolManager
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(params.Enterprise) (common.PoolManager, error)); ok {
|
|
return rf(enterprise)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(params.Enterprise) common.PoolManager); ok {
|
|
r0 = rf(enterprise)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(common.PoolManager)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(params.Enterprise) error); ok {
|
|
r1 = rf(enterprise)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// GetEnterprisePoolManagers provides a mock function with given fields:
|
|
func (_m *PoolManagerController) GetEnterprisePoolManagers() (map[string]common.PoolManager, error) {
|
|
ret := _m.Called()
|
|
|
|
var r0 map[string]common.PoolManager
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func() (map[string]common.PoolManager, error)); ok {
|
|
return rf()
|
|
}
|
|
if rf, ok := ret.Get(0).(func() map[string]common.PoolManager); ok {
|
|
r0 = rf()
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(map[string]common.PoolManager)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func() error); ok {
|
|
r1 = rf()
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// GetOrgPoolManager provides a mock function with given fields: org
|
|
func (_m *PoolManagerController) GetOrgPoolManager(org params.Organization) (common.PoolManager, error) {
|
|
ret := _m.Called(org)
|
|
|
|
var r0 common.PoolManager
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(params.Organization) (common.PoolManager, error)); ok {
|
|
return rf(org)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(params.Organization) common.PoolManager); ok {
|
|
r0 = rf(org)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(common.PoolManager)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(params.Organization) error); ok {
|
|
r1 = rf(org)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// GetOrgPoolManagers provides a mock function with given fields:
|
|
func (_m *PoolManagerController) GetOrgPoolManagers() (map[string]common.PoolManager, error) {
|
|
ret := _m.Called()
|
|
|
|
var r0 map[string]common.PoolManager
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func() (map[string]common.PoolManager, error)); ok {
|
|
return rf()
|
|
}
|
|
if rf, ok := ret.Get(0).(func() map[string]common.PoolManager); ok {
|
|
r0 = rf()
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(map[string]common.PoolManager)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func() error); ok {
|
|
r1 = rf()
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// GetRepoPoolManager provides a mock function with given fields: repo
|
|
func (_m *PoolManagerController) GetRepoPoolManager(repo params.Repository) (common.PoolManager, error) {
|
|
ret := _m.Called(repo)
|
|
|
|
var r0 common.PoolManager
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(params.Repository) (common.PoolManager, error)); ok {
|
|
return rf(repo)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(params.Repository) common.PoolManager); ok {
|
|
r0 = rf(repo)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(common.PoolManager)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(params.Repository) error); ok {
|
|
r1 = rf(repo)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// GetRepoPoolManagers provides a mock function with given fields:
|
|
func (_m *PoolManagerController) GetRepoPoolManagers() (map[string]common.PoolManager, error) {
|
|
ret := _m.Called()
|
|
|
|
var r0 map[string]common.PoolManager
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func() (map[string]common.PoolManager, error)); ok {
|
|
return rf()
|
|
}
|
|
if rf, ok := ret.Get(0).(func() map[string]common.PoolManager); ok {
|
|
r0 = rf()
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(map[string]common.PoolManager)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func() error); ok {
|
|
r1 = rf()
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// UpdateEnterprisePoolManager provides a mock function with given fields: ctx, enterprise
|
|
func (_m *PoolManagerController) UpdateEnterprisePoolManager(ctx context.Context, enterprise params.Enterprise) (common.PoolManager, error) {
|
|
ret := _m.Called(ctx, enterprise)
|
|
|
|
var r0 common.PoolManager
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(context.Context, params.Enterprise) (common.PoolManager, error)); ok {
|
|
return rf(ctx, enterprise)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(context.Context, params.Enterprise) common.PoolManager); ok {
|
|
r0 = rf(ctx, enterprise)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(common.PoolManager)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(context.Context, params.Enterprise) error); ok {
|
|
r1 = rf(ctx, enterprise)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// UpdateOrgPoolManager provides a mock function with given fields: ctx, org
|
|
func (_m *PoolManagerController) UpdateOrgPoolManager(ctx context.Context, org params.Organization) (common.PoolManager, error) {
|
|
ret := _m.Called(ctx, org)
|
|
|
|
var r0 common.PoolManager
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(context.Context, params.Organization) (common.PoolManager, error)); ok {
|
|
return rf(ctx, org)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(context.Context, params.Organization) common.PoolManager); ok {
|
|
r0 = rf(ctx, org)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(common.PoolManager)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(context.Context, params.Organization) error); ok {
|
|
r1 = rf(ctx, org)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
// UpdateRepoPoolManager provides a mock function with given fields: ctx, repo
|
|
func (_m *PoolManagerController) UpdateRepoPoolManager(ctx context.Context, repo params.Repository) (common.PoolManager, error) {
|
|
ret := _m.Called(ctx, repo)
|
|
|
|
var r0 common.PoolManager
|
|
var r1 error
|
|
if rf, ok := ret.Get(0).(func(context.Context, params.Repository) (common.PoolManager, error)); ok {
|
|
return rf(ctx, repo)
|
|
}
|
|
if rf, ok := ret.Get(0).(func(context.Context, params.Repository) common.PoolManager); ok {
|
|
r0 = rf(ctx, repo)
|
|
} else {
|
|
if ret.Get(0) != nil {
|
|
r0 = ret.Get(0).(common.PoolManager)
|
|
}
|
|
}
|
|
|
|
if rf, ok := ret.Get(1).(func(context.Context, params.Repository) error); ok {
|
|
r1 = rf(ctx, repo)
|
|
} else {
|
|
r1 = ret.Error(1)
|
|
}
|
|
|
|
return r0, r1
|
|
}
|
|
|
|
type mockConstructorTestingTNewPoolManagerController interface {
|
|
mock.TestingT
|
|
Cleanup(func())
|
|
}
|
|
|
|
// NewPoolManagerController creates a new instance of PoolManagerController. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
|
func NewPoolManagerController(t mockConstructorTestingTNewPoolManagerController) *PoolManagerController {
|
|
mock := &PoolManagerController{}
|
|
mock.Mock.Test(t)
|
|
|
|
t.Cleanup(func() { mock.AssertExpectations(t) })
|
|
|
|
return mock
|
|
}
|