diff --git a/runner/common/mocks/Provider.go b/runner/common/mocks/Provider.go index 4c9d5727..7865995b 100644 --- a/runner/common/mocks/Provider.go +++ b/runner/common/mocks/Provider.go @@ -161,12 +161,12 @@ func (_m *Provider) Start(ctx context.Context, instance string) error { } // Stop provides a mock function with given fields: ctx, instance, force -func (_m *Provider) Stop(ctx context.Context, instance string, force bool) error { - ret := _m.Called(ctx, instance, force) +func (_m *Provider) Stop(ctx context.Context, instance string) error { + ret := _m.Called(ctx, instance) var r0 error - if rf, ok := ret.Get(0).(func(context.Context, string, bool) error); ok { - r0 = rf(ctx, instance, force) + if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { + r0 = rf(ctx, instance) } else { r0 = ret.Error(0) } diff --git a/runner/common/provider.go b/runner/common/provider.go index 3a45bba9..8ed98e0c 100644 --- a/runner/common/provider.go +++ b/runner/common/provider.go @@ -34,7 +34,7 @@ type Provider interface { // RemoveAllInstances will remove all instances created by this provider. RemoveAllInstances(ctx context.Context) error // Stop shuts down the instance. - Stop(ctx context.Context, instance string, force bool) error + Stop(ctx context.Context, instance string) error // Start boots up an instance. Start(ctx context.Context, instance string) error // DisableJITConfig tells us if the provider explicitly disables JIT configuration and diff --git a/runner/metrics/health.go b/runner/metrics/health.go index d70adf10..05e1ed9b 100644 --- a/runner/metrics/health.go +++ b/runner/metrics/health.go @@ -1,14 +1,11 @@ package metrics import ( - "context" - "github.com/cloudbase/garm/metrics" "github.com/cloudbase/garm/params" - "github.com/cloudbase/garm/runner" ) -func CollectHealthMetric(ctx context.Context, r *runner.Runner, controllerInfo params.ControllerInfo) error { +func CollectHealthMetric(controllerInfo params.ControllerInfo) error { metrics.GarmHealth.WithLabelValues( controllerInfo.MetadataURL, // label: metadata_url controllerInfo.CallbackURL, // label: callback_url diff --git a/runner/metrics/metrics.go b/runner/metrics/metrics.go index 59fc6bbb..24b01bab 100644 --- a/runner/metrics/metrics.go +++ b/runner/metrics/metrics.go @@ -82,7 +82,7 @@ func collectMetrics(ctx context.Context, r *runner.Runner, controllerInfo params } slog.DebugContext(ctx, "collecting health metrics") - err = CollectHealthMetric(ctx, r, controllerInfo) + err = CollectHealthMetric(controllerInfo) if err != nil { return err } diff --git a/runner/pool/enterprise.go b/runner/pool/enterprise.go index 9019bcde..5aa49608 100644 --- a/runner/pool/enterprise.go +++ b/runner/pool/enterprise.go @@ -77,7 +77,7 @@ type enterprise struct { mux sync.Mutex } -func (r *enterprise) findRunnerGroupByName(ctx context.Context, name string) (*github.EnterpriseRunnerGroup, error) { +func (r *enterprise) findRunnerGroupByName(name string) (*github.EnterpriseRunnerGroup, error) { // TODO(gabriel-samfira): implement caching opts := github.ListEnterpriseRunnerGroupOptions{ ListOptions: github.ListOptions{ @@ -118,7 +118,7 @@ func (r *enterprise) findRunnerGroupByName(ctx context.Context, name string) (*g func (r *enterprise) GetJITConfig(ctx context.Context, instance string, pool params.Pool, labels []string) (jitConfigMap map[string]string, runner *github.Runner, err error) { var rg int64 = 1 if pool.GitHubRunnerGroup != "" { - runnerGroup, err := r.findRunnerGroupByName(ctx, pool.GitHubRunnerGroup) + runnerGroup, err := r.findRunnerGroupByName(pool.GitHubRunnerGroup) if err != nil { return nil, nil, fmt.Errorf("failed to find runner group: %w", err) } @@ -392,14 +392,14 @@ func (r *enterprise) ID() string { return r.id } -func (r *enterprise) InstallHook(ctx context.Context, req *github.Hook) (params.HookInfo, error) { +func (r *enterprise) InstallHook(_ context.Context, _ *github.Hook) (params.HookInfo, error) { return params.HookInfo{}, fmt.Errorf("not implemented") } -func (r *enterprise) UninstallHook(ctx context.Context, url string) error { +func (r *enterprise) UninstallHook(_ context.Context, _ string) error { return fmt.Errorf("not implemented") } -func (r *enterprise) GetHookInfo(ctx context.Context) (params.HookInfo, error) { +func (r *enterprise) GetHookInfo(_ context.Context) (params.HookInfo, error) { return params.HookInfo{}, fmt.Errorf("not implemented") } diff --git a/runner/pool/organization.go b/runner/pool/organization.go index 2e287c94..000a164e 100644 --- a/runner/pool/organization.go +++ b/runner/pool/organization.go @@ -89,7 +89,7 @@ type organization struct { mux sync.Mutex } -func (r *organization) findRunnerGroupByName(ctx context.Context, name string) (*github.RunnerGroup, error) { +func (r *organization) findRunnerGroupByName(name string) (*github.RunnerGroup, error) { // TODO(gabriel-samfira): implement caching opts := github.ListOrgRunnerGroupOptions{ ListOptions: github.ListOptions{ @@ -130,7 +130,7 @@ func (r *organization) findRunnerGroupByName(ctx context.Context, name string) ( func (r *organization) GetJITConfig(ctx context.Context, instance string, pool params.Pool, labels []string) (jitConfigMap map[string]string, runner *github.Runner, err error) { var rg int64 = 1 if pool.GitHubRunnerGroup != "" { - runnerGroup, err := r.findRunnerGroupByName(ctx, pool.GitHubRunnerGroup) + runnerGroup, err := r.findRunnerGroupByName(pool.GitHubRunnerGroup) if err != nil { return nil, nil, fmt.Errorf("failed to find runner group: %w", err) } diff --git a/runner/pool/repository.go b/runner/pool/repository.go index 43273c16..856995ad 100644 --- a/runner/pool/repository.go +++ b/runner/pool/repository.go @@ -91,6 +91,8 @@ type repository struct { mux sync.Mutex } +// nolint:golint,revive +// pool is used in enterprise and organzation func (r *repository) GetJITConfig(ctx context.Context, instance string, pool params.Pool, labels []string) (jitConfigMap map[string]string, runner *github.Runner, err error) { req := github.GenerateJITConfigRequest{ Name: instance, diff --git a/runner/providers/external/external.go b/runner/providers/external/external.go index 9174b2e8..52c672b7 100644 --- a/runner/providers/external/external.go +++ b/runner/providers/external/external.go @@ -50,7 +50,7 @@ type external struct { environmentVariables []string } -func (e *external) validateResult(ctx context.Context, inst commonParams.ProviderInstance) error { +func (e *external) validateResult(inst commonParams.ProviderInstance) error { if inst.ProviderID == "" { return garmErrors.NewProviderError("missing provider ID") } @@ -104,7 +104,7 @@ func (e *external) CreateInstance(ctx context.Context, bootstrapParams commonPar return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err) } - if err := e.validateResult(ctx, param); err != nil { + if err := e.validateResult(param); err != nil { metrics.InstanceOperationFailedCount.WithLabelValues( "CreateInstance", // label: operation e.cfg.Name, // label: provider @@ -181,7 +181,7 @@ func (e *external) GetInstance(ctx context.Context, instance string) (commonPara return commonParams.ProviderInstance{}, garmErrors.NewProviderError("failed to decode response from binary: %s", err) } - if err := e.validateResult(ctx, param); err != nil { + if err := e.validateResult(param); err != nil { metrics.InstanceOperationFailedCount.WithLabelValues( "GetInstance", // label: operation e.cfg.Name, // label: provider @@ -227,7 +227,7 @@ func (e *external) ListInstances(ctx context.Context, poolID string) ([]commonPa ret := make([]commonParams.ProviderInstance, len(param)) for idx, inst := range param { - if err := e.validateResult(ctx, inst); err != nil { + if err := e.validateResult(inst); err != nil { metrics.InstanceOperationFailedCount.WithLabelValues( "ListInstances", // label: operation e.cfg.Name, // label: provider @@ -265,7 +265,7 @@ func (e *external) RemoveAllInstances(ctx context.Context) error { } // Stop shuts down the instance. -func (e *external) Stop(ctx context.Context, instance string, force bool) error { +func (e *external) Stop(ctx context.Context, instance string) error { asEnv := []string{ fmt.Sprintf("GARM_COMMAND=%s", execution.StopInstanceCommand), fmt.Sprintf("GARM_CONTROLLER_ID=%s", e.controllerID),