From 04f5dc4004063ad5c8a9281a0f96f02abe48049a Mon Sep 17 00:00:00 2001 From: Nicholas Blaskey Date: Mon, 6 Nov 2023 09:42:48 -0500 Subject: [PATCH 1/3] chore: enable more Go linters --- agent/internal/container/container.go | 3 +- .../internal/container/container_api_test.go | 16 +-- agent/internal/containers/manager.go | 8 +- master/.golangci.yml | 115 ++++++++---------- master/internal/api_checkpoint.go | 4 +- master/internal/api_experiment.go | 12 +- master/internal/api_experiment_intg_test.go | 11 +- master/internal/api_model.go | 2 +- master/internal/api_project.go | 2 +- master/internal/api_tasks.go | 4 +- master/internal/api_user.go | 2 +- master/internal/audit_test.go | 1 + master/internal/checkpoint_gc_test.go | 2 +- master/internal/command/command.go | 2 +- .../internal/command/command_job_service.go | 2 +- master/internal/config/config_test.go | 2 +- master/internal/core_checkpoint_intg_test.go | 2 +- .../db/postgres_experiments_intg_test.go | 1 + ...ostgres_rp_workspace_bindings_intg_test.go | 8 -- master/internal/db/postgres_snapshots_test.go | 2 +- master/internal/db/postgres_test_utils.go | 2 +- master/internal/experiment.go | 4 +- master/internal/populate_metrics.go | 12 +- master/internal/prom/det_state_metrics.go | 2 +- master/internal/proxy/proxy.go | 1 - master/internal/proxy/proxy_intg_test.go | 1 + master/internal/restore_test.go | 8 +- master/internal/rm/agentrm/resource_pool.go | 2 +- master/internal/rm/kubernetesrm/pods.go | 2 +- .../internal/rm/kubernetesrm/resource_pool.go | 6 +- master/internal/rm/kubernetesrm/spec_test.go | 2 +- master/internal/rm/rmerrors/errors.go | 6 +- master/internal/rm/rmevents/rmevents.go | 1 - master/internal/sproto/resources.go | 24 ++-- master/internal/sproto/task.go | 2 +- master/internal/task/allocation.go | 18 +-- master/internal/task/allocation_intg_test.go | 8 +- master/internal/task/allocation_service.go | 1 + .../internal/task/allocation_service_test.go | 4 +- master/internal/task/errors.go | 54 ++++---- master/internal/task/rendezvous.go | 4 +- master/internal/telemetry/telemetry_test.go | 1 + .../internal/templates/service_intg_test.go | 1 + master/internal/trial_intg_test.go | 2 +- .../trials/postgres_trials_intg_test.go | 4 +- master/internal/user/postgres_users.go | 2 +- master/internal/usergroup/group_intg_test.go | 4 +- master/internal/webhooks/shipper.go | 4 +- master/internal/webhooks/shipper_test.go | 1 + master/pkg/actor/context.go | 1 + master/pkg/actor/errors.go | 6 +- master/pkg/actor/errors_test.go | 2 +- master/pkg/actor/ref.go | 2 +- master/pkg/actor/response_test.go | 4 +- master/pkg/aproto/exit.go | 22 ++-- master/pkg/aproto/master_message.go | 4 +- master/pkg/checkpoints/s3/s3checkpoints.go | 2 +- master/pkg/model/task_container_defaults.go | 4 +- .../pkg/model/task_container_defaults_test.go | 2 +- master/pkg/model/test_utils.go | 2 +- .../schemas/expconf/experiment_config_test.go | 2 +- master/pkg/schemas/expconf/legacy.go | 2 +- master/pkg/schemas/expconf/legacy_test.go | 2 +- master/pkg/schemas/expconf/schema_test.go | 2 +- master/pkg/searcher/adaptive_asha_test.go | 2 +- master/pkg/searcher/asha_stopping_test.go | 2 +- master/pkg/searcher/asha_test.go | 2 +- master/pkg/searcher/custom_search_test.go | 2 +- master/pkg/searcher/grid_test.go | 2 +- master/pkg/searcher/random_test.go | 2 +- master/pkg/searcher/tournament_test.go | 2 +- master/pkg/syncx/errgroupx/errgroupx.go | 1 + master/pkg/tasks/task_command.go | 9 +- master/pkg/tasks/task_gc.go | 2 +- master/pkg/tasks/task_trial.go | 9 +- 75 files changed, 225 insertions(+), 253 deletions(-) diff --git a/agent/internal/container/container.go b/agent/internal/container/container.go index ed3b947b2ef..7784ee99719 100644 --- a/agent/internal/container/container.go +++ b/agent/internal/container/container.go @@ -336,7 +336,7 @@ func (c *Container) finalize(ctx context.Context, err error) { switch err := err.(type) { case nil: stop = aproto.ContainerStopped{Failure: nil} - case *aproto.ContainerFailure: + case *aproto.ContainerFailureError: stop = aproto.ContainerStopped{Failure: err} default: stop = aproto.ContainerError(aproto.TaskError, err) @@ -345,7 +345,6 @@ func (c *Container) finalize(ctx context.Context, err error) { if err := c.terminated(ctx, stop); err != nil { c.log.WithError(err).Error("finalizing container") } - return } func (c *Container) summary() cproto.Container { diff --git a/agent/internal/container/container_api_test.go b/agent/internal/container/container_api_test.go index fab7a858a3e..55978dad3cf 100644 --- a/agent/internal/container/container_api_test.go +++ b/agent/internal/container/container_api_test.go @@ -50,7 +50,7 @@ func TestContainer(t *testing.T) { signalAtState cproto.State signal syscall.Signal - failure *aproto.ContainerFailure + failure *aproto.ContainerFailureError }{ { name: "successful command", @@ -62,7 +62,7 @@ func TestContainer(t *testing.T) { name: "non-existent image", image: "lieblos/notanimageipushed", entrypoint: []string{"echo", "hello"}, - failure: &aproto.ContainerFailure{ + failure: &aproto.ContainerFailureError{ FailureType: aproto.TaskError, ErrMsg: "repository does not exist or may require 'docker login'", }, @@ -71,7 +71,7 @@ func TestContainer(t *testing.T) { name: "non-existent command", image: "python:3.8.16", entrypoint: []string{"badcommandthatdoesntexit"}, - failure: &aproto.ContainerFailure{ + failure: &aproto.ContainerFailureError{ FailureType: aproto.TaskError, ErrMsg: "executable file not found in $PATH", }, @@ -80,7 +80,7 @@ func TestContainer(t *testing.T) { name: "failed command", image: "python:3.8.16", entrypoint: []string{"ls", "badfile"}, - failure: &aproto.ContainerFailure{ + failure: &aproto.ContainerFailureError{ FailureType: aproto.ContainerFailed, ErrMsg: "container failed with non-zero exit code", ExitCode: (*aproto.ExitCode)(ptrs.Ptr(2)), @@ -91,7 +91,7 @@ func TestContainer(t *testing.T) { image: "pytorch/pytorch", entrypoint: []string{"echo", "hello"}, detachAtState: cproto.Pulling, - failure: &aproto.ContainerFailure{ + failure: &aproto.ContainerFailureError{ FailureType: aproto.ContainerMissing, ErrMsg: "container is gone on reattachment", }, @@ -108,7 +108,7 @@ func TestContainer(t *testing.T) { entrypoint: []string{"echo", "hello"}, signalAtState: cproto.Pulling, signal: syscall.SIGKILL, - failure: &aproto.ContainerFailure{ + failure: &aproto.ContainerFailureError{ FailureType: aproto.ContainerAborted, ErrMsg: "killed before run", }, @@ -119,7 +119,7 @@ func TestContainer(t *testing.T) { entrypoint: []string{"sleep", "60"}, signalAtState: cproto.Running, signal: syscall.SIGKILL, - failure: &aproto.ContainerFailure{ + failure: &aproto.ContainerFailureError{ FailureType: aproto.ContainerFailed, ErrMsg: "137", ExitCode: (*aproto.ExitCode)(ptrs.Ptr(137)), @@ -229,7 +229,7 @@ func TestContainerStatus(t *testing.T) { dockerEventAction := "create" timeoutDuration := 10 * time.Second signalToSend := syscall.SIGKILL - expectedFailure := &aproto.ContainerFailure{ + expectedFailure := &aproto.ContainerFailureError{ FailureType: aproto.ContainerAborted, ErrMsg: "killed before run", } diff --git a/agent/internal/containers/manager.go b/agent/internal/containers/manager.go index 1aa5d2580ad..1a444471e3b 100644 --- a/agent/internal/containers/manager.go +++ b/agent/internal/containers/manager.go @@ -97,7 +97,7 @@ func (m *Manager) ReattachContainers( m.log.Tracef("container is gone on reattachment %s", cID) ack = aproto.ContainerReattachAck{ Container: cproto.Container{ID: cID}, - Failure: &aproto.ContainerFailure{ + Failure: &aproto.ContainerFailureError{ FailureType: aproto.RestoreError, ErrMsg: "container is gone on reattachment", }, @@ -110,7 +110,7 @@ func (m *Manager) ReattachContainers( m.log.WithError(err).Tracef("failed to reattach container %s", cID) ack = aproto.ContainerReattachAck{ Container: cproto.Container{ID: cID}, - Failure: &aproto.ContainerFailure{ + Failure: &aproto.ContainerFailureError{ FailureType: aproto.RestoreError, ErrMsg: err.Error(), }, @@ -182,7 +182,7 @@ func (m *Manager) RevalidateContainers( // Else fallback to a missing message. result = append(result, aproto.ContainerReattachAck{ Container: cproto.Container{ID: cid}, - Failure: &aproto.ContainerFailure{ + Failure: &aproto.ContainerFailureError{ FailureType: aproto.RestoreError, ErrMsg: "failed to restore container on master blip", }, @@ -325,7 +325,7 @@ func (m *Manager) reattachContainer( func (m *Manager) recentExit( cID cproto.ID, - fallback *aproto.ContainerFailure, + fallback *aproto.ContainerFailureError, ) *aproto.ContainerStateChanged { var stop *aproto.ContainerStateChanged m.recentExits.Do(func(v any) { diff --git a/master/.golangci.yml b/master/.golangci.yml index 29767e067f3..29ed96c88f5 100644 --- a/master/.golangci.yml +++ b/master/.golangci.yml @@ -84,79 +84,66 @@ linters-settings: linters: enable-all: true disable: - - deadcode - - exhaustive - - exhaustivestruct - - funlen - - gochecknoglobals - - gochecknoinits - - gocognit - - gocyclo - - godox - - goerr113 - - gofumpt - - golint - - gomnd - - maligned - - nestif - - noctx - - scopelint - - testpackage - - unparam - - wsl - - varcheck - + # Linters that need triaging. Put all linters here if you upgrade. # Below here are new linters from upgrading to 1.43.0. Since we enable all and disable # selectively, when we upgrade we get a ton of new linters. For convenience next upgrade, # golangci-lint can tell you which linters are enabled: # golangci-lint linters | sed -n '/Enabled/,/Disabled/p' # To maintain the same set us linters, disable those in the new set that are not in the old: # comm -13 <(cut -d : -f 1 0 { if _, err := tx.NewUpdate().Model(&model.Trial{}). @@ -1795,7 +1795,7 @@ func (a *apiServer) ExpMetricNames(req *apiv1.ExpMetricNamesRequest, var timeSinceLastAuth time.Time for { var response apiv1.ExpMetricNamesResponse - if time.Now().Sub(timeSinceLastAuth) >= recheckAuthPeriod { + if time.Since(timeSinceLastAuth) >= recheckAuthPeriod { for _, expID := range req.Ids { exp, _, err := a.getExperimentAndCheckCanDoActions(resp.Context(), int(expID), experiment.AuthZProvider.Get().CanGetExperimentArtifacts) @@ -1895,7 +1895,7 @@ func (a *apiServer) MetricBatches(req *apiv1.MetricBatchesRequest, seenBatches := make(map[int32]bool) var startTime time.Time for { - if time.Now().Sub(timeSinceLastAuth) >= recheckAuthPeriod { + if time.Since(timeSinceLastAuth) >= recheckAuthPeriod { if _, _, err := a.getExperimentAndCheckCanDoActions(resp.Context(), experimentID, experiment.AuthZProvider.Get().CanGetExperimentArtifacts); err != nil { return err @@ -1996,7 +1996,7 @@ func (a *apiServer) TrialsSnapshot(req *apiv1.TrialsSnapshotRequest, var timeSinceLastAuth time.Time var startTime time.Time for { - if time.Now().Sub(timeSinceLastAuth) >= recheckAuthPeriod { + if time.Since(timeSinceLastAuth) >= recheckAuthPeriod { if _, _, err := a.getExperimentAndCheckCanDoActions(resp.Context(), experimentID, experiment.AuthZProvider.Get().CanGetExperimentArtifacts); err != nil { return err @@ -2184,7 +2184,7 @@ func (a *apiServer) TrialsSample(req *apiv1.TrialsSampleRequest, trialCursors := make(map[int32]time.Time) currentTrials := make(map[int32]bool) for { - if time.Now().Sub(timeSinceLastAuth) >= recheckAuthPeriod { + if time.Since(timeSinceLastAuth) >= recheckAuthPeriod { exp, _, err := a.getExperimentAndCheckCanDoActions(resp.Context(), experimentID, experiment.AuthZProvider.Get().CanGetExperimentArtifacts) if err != nil { diff --git a/master/internal/api_experiment_intg_test.go b/master/internal/api_experiment_intg_test.go index 841f5c0a832..394708b62d6 100644 --- a/master/internal/api_experiment_intg_test.go +++ b/master/internal/api_experiment_intg_test.go @@ -53,6 +53,7 @@ import ( "github.com/determined-ai/determined/proto/pkg/workspacev1" ) +//nolint:containedctx type mockStream[T any] struct { mu sync.Mutex ctx context.Context @@ -123,7 +124,7 @@ func minExpConfToYaml(t *testing.T) string { return string(bytes) } -// nolint: exhaustivestruct +// nolint: exhaustruct var minExpConfig = expconf.ExperimentConfig{ RawResources: &expconf.ResourcesConfig{ RawResourcePool: ptrs.Ptr("kubernetes"), @@ -337,7 +338,7 @@ searcher: "override config is provided and experiment is not single searcher, got 'random' instead") } -// nolint: exhaustivestruct +// nolint: exhaustruct func TestCreateExperimentCheckpointStorage(t *testing.T) { api, _, ctx := setupAPITest(t, nil) api.m.config.CheckpointStorage = expconf.CheckpointStorageConfig{} @@ -437,7 +438,7 @@ checkpoint_storage: require.Equal(t, expected, resp.Config.AsMap()["checkpoint_storage"]) } -// nolint: exhaustivestruct +// nolint: exhaustruct func TestGetExperiments(t *testing.T) { // Setup. api, _, ctx := setupAPITest(t, nil) @@ -863,7 +864,7 @@ func TestLegacyExperiments(t *testing.T) { var res *apiv1.GetExperimentsResponse // Avoid compiler optimizing res out. -// nolint: exhaustivestruct +// nolint: exhaustruct func benchmarkGetExperiments(b *testing.B, n int) { // This should be fine as long as no error happens. For some // reason passing nil gives an error. In addition this @@ -942,7 +943,7 @@ func BenchmarkGetExeriments500(b *testing.B) { benchmarkGetExperiments(b, 500) } func BenchmarkGetExeriments2500(b *testing.B) { benchmarkGetExperiments(b, 2500) } -// nolint: exhaustivestruct +// nolint: exhaustruct func createTestExpWithProjectID( t *testing.T, api *apiServer, curUser model.User, projectID int, labels ...string, ) *model.Experiment { diff --git a/master/internal/api_model.go b/master/internal/api_model.go index bedd6f82255..14746a86184 100644 --- a/master/internal/api_model.go +++ b/master/internal/api_model.go @@ -365,7 +365,7 @@ func (a *apiServer) PatchModel( if req.Model.Labels != nil { // avoid duplicate keys reqLabelSet := make(map[string]struct{}, len(req.Model.Labels.Values)) - reqLabelList := make([]string, len(reqLabelSet)) + reqLabelList := make([]string, 0, len(reqLabelSet)) for _, el := range req.Model.Labels.Values { if _, ok := el.GetKind().(*structpb.Value_StringValue); !ok { // Invalid label. diff --git a/master/internal/api_project.go b/master/internal/api_project.go index 0817ed10341..58991849bfa 100644 --- a/master/internal/api_project.go +++ b/master/internal/api_project.go @@ -275,7 +275,7 @@ func (a *apiServer) getProjectColumnsByID( flatHparam := expconf.FlattenHPs(hparam.Hyperparameters) // ensure we're iterating in order - paramKeys := make([]string, len(flatHparam)) + paramKeys := make([]string, 0, len(flatHparam)) for key := range flatHparam { paramKeys = append(paramKeys, key) } diff --git a/master/internal/api_tasks.go b/master/internal/api_tasks.go index 0b8e518dcf8..813add08e00 100644 --- a/master/internal/api_tasks.go +++ b/master/internal/api_tasks.go @@ -560,7 +560,7 @@ func (a *apiServer) taskLogs( var followState interface{} var timeSinceLastAuth time.Time fetch := func(r api.BatchRequest) (api.Batch, error) { - if time.Now().Sub(timeSinceLastAuth) >= recheckAuthPeriod { + if time.Since(timeSinceLastAuth) >= recheckAuthPeriod { if err = a.canDoActionsOnTask(ctx, taskID, expauth.AuthZProvider.Get().CanGetExperimentArtifacts); err != nil { return nil, err @@ -683,7 +683,7 @@ func (a *apiServer) TaskLogsFields( var timeSinceLastAuth time.Time fetch := func(lr api.BatchRequest) (api.Batch, error) { - if time.Now().Sub(timeSinceLastAuth) >= recheckAuthPeriod { + if time.Since(timeSinceLastAuth) >= recheckAuthPeriod { if err := a.canDoActionsOnTask(resp.Context(), taskID, expauth.AuthZProvider.Get().CanGetExperimentArtifacts); err != nil { return nil, err diff --git a/master/internal/api_user.go b/master/internal/api_user.go index 99ed0946eb0..3731b984b8d 100644 --- a/master/internal/api_user.go +++ b/master/internal/api_user.go @@ -33,7 +33,7 @@ const determinedName = "determined" var ( errExternalSessions = status.Error(codes.PermissionDenied, "not enabled with external sessions") - latinText = regexp.MustCompile("[^[:graph:]\\s]") + latinText = regexp.MustCompile(`[^[:graph:]\s]`) ) func clearUsername(targetUser model.User, name string, minLength int) (*string, error) { diff --git a/master/internal/audit_test.go b/master/internal/audit_test.go index 0f8fd91b74a..0642ceade21 100644 --- a/master/internal/audit_test.go +++ b/master/internal/audit_test.go @@ -28,6 +28,7 @@ func (l *logStore) Levels() []logrus.Level { return logrus.AllLevels } +// nolint: noctx func TestAuditLogMiddleware(t *testing.T) { // Given an echo server with our middleware, where we can introspect logs, and with a valid // DetContext. diff --git a/master/internal/checkpoint_gc_test.go b/master/internal/checkpoint_gc_test.go index 509fdb0c86f..d289f43d5eb 100644 --- a/master/internal/checkpoint_gc_test.go +++ b/master/internal/checkpoint_gc_test.go @@ -145,7 +145,7 @@ func TestRunCheckpointGCTask(t *testing.T) { time.Now(), tasks.TaskSpec{}, 0, - expconf.LegacyConfig{}, //nolint:exhaustivestruct + expconf.LegacyConfig{}, //nolint:exhaustruct tt.args.toDeleteCheckpoints, tt.args.checkpointGlobs, tt.args.deleteTensorboards, diff --git a/master/internal/command/command.go b/master/internal/command/command.go index d83f55cb1d4..1a49e17b73d 100644 --- a/master/internal/command/command.go +++ b/master/internal/command/command.go @@ -498,7 +498,7 @@ func (c *command) setPriority(priority int, forward bool) error { JobID: c.jobID, }).(type) { case nil: - case rmerrors.ErrUnsupported: + case rmerrors.UnsupportedError: c.syslog.WithError(err).Debug("ignoring unsupported call to set group priority") default: return fmt.Errorf("setting group priority for command: %w", err) diff --git a/master/internal/command/command_job_service.go b/master/internal/command/command_job_service.go index ae876343d5c..c32eab38697 100644 --- a/master/internal/command/command_job_service.go +++ b/master/internal/command/command_job_service.go @@ -65,7 +65,7 @@ func (c *command) SetWeight(weight float64) error { JobID: c.jobID, }).(type) { case nil: - case rmerrors.ErrUnsupported: + case rmerrors.UnsupportedError: c.syslog.WithError(err).Debug("ignoring unsupported call to set group weight") default: return fmt.Errorf("setting group weight for command: %w", err) diff --git a/master/internal/config/config_test.go b/master/internal/config/config_test.go index 097b8ab6582..341886453be 100644 --- a/master/internal/config/config_test.go +++ b/master/internal/config/config_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package config import ( diff --git a/master/internal/core_checkpoint_intg_test.go b/master/internal/core_checkpoint_intg_test.go index 4913d7ca9e4..5bd1af6d5aa 100644 --- a/master/internal/core_checkpoint_intg_test.go +++ b/master/internal/core_checkpoint_intg_test.go @@ -343,7 +343,7 @@ func TestAuthZCheckpointsEcho(t *testing.T) { require.Equal(t, expectedErr, api.m.getCheckpoint(ctx)) } -// nolint: exhaustivestruct +// nolint: exhaustruct func mockExperimentS3( t *testing.T, pgDB *db.PgDB, user model.User, folderPath string, ) *model.Experiment { diff --git a/master/internal/db/postgres_experiments_intg_test.go b/master/internal/db/postgres_experiments_intg_test.go index 724f487656d..8a2e9196249 100644 --- a/master/internal/db/postgres_experiments_intg_test.go +++ b/master/internal/db/postgres_experiments_intg_test.go @@ -648,6 +648,7 @@ func TestDeleteExperiments(t *testing.T) { } // Create experiment snapshot + //nolint:exhaustruct config := expconf.SearcherConfig{ RawCustomConfig: &expconf.CustomConfig{}, } diff --git a/master/internal/db/postgres_rp_workspace_bindings_intg_test.go b/master/internal/db/postgres_rp_workspace_bindings_intg_test.go index 6179ee4ef4d..f8bf33b17dd 100644 --- a/master/internal/db/postgres_rp_workspace_bindings_intg_test.go +++ b/master/internal/db/postgres_rp_workspace_bindings_intg_test.go @@ -119,8 +119,6 @@ func TestBindingFail(t *testing.T) { err = AddRPWorkspaceBindings(ctx, []int32{workspaceIDs[2]}, "NonexistentPool", poolConfigs) require.Errorf(t, err, "expected error adding binding for workspaces %d on non-existent pool", workspaceIDs[2], workspaceIDs[1]) - - return } func TestListWorkspacesBindingRP(t *testing.T) { @@ -176,7 +174,6 @@ func TestListWorkspacesBindingRP(t *testing.T) { require.NoError(t, err, "failed to get all bindings") require.Equal(t, 2, len(bindings), "expected length of bindings to be 0 but got %d", len(bindings)) - return } func TestListRPsAvailableToWorkspace(t *testing.T) { @@ -309,7 +306,6 @@ func TestListRPsAvailableToWorkspace(t *testing.T) { err = CleanupMockWorkspace(workspaceIDs) require.NoError(t, err) - return } func TestOverwriteBindings(t *testing.T) { @@ -375,8 +371,6 @@ func TestOverwriteBindings(t *testing.T) { ) require.Equal(t, testPool2Name, bindings[0].PoolName, "expected bound pool to be %s, but was %s", testPool2Name, bindings[0].PoolName) - - return } func TestOverwriteFail(t *testing.T) { @@ -394,7 +388,6 @@ func TestOverwriteFail(t *testing.T) { nonExistentPoolName := "poolNameDoesntExist" err = OverwriteRPWorkspaceBindings(ctx, workspaceIDs, nonExistentPoolName, existingPools) require.ErrorContains(t, err, "doesn't exist") - return } func TestRemoveInvalidBinding(t *testing.T) { @@ -409,5 +402,4 @@ func TestRemoveInvalidBinding(t *testing.T) { workspaceIDs = []int32{1, 2, 3} err = RemoveRPWorkspaceBindings(ctx, workspaceIDs, testPoolName) require.ErrorContains(t, err, " binding doesn't exist") - return } diff --git a/master/internal/db/postgres_snapshots_test.go b/master/internal/db/postgres_snapshots_test.go index 5502b50ee9e..0081577b2d7 100644 --- a/master/internal/db/postgres_snapshots_test.go +++ b/master/internal/db/postgres_snapshots_test.go @@ -25,7 +25,7 @@ func TestCustomSearcherSnapshot(t *testing.T) { user := RequireMockUser(t, db) exp := RequireMockExperiment(t, db, user) - //nolint:exhaustivestruct + //nolint:exhaustruct config := expconf.SearcherConfig{ RawCustomConfig: &expconf.CustomConfig{}, } diff --git a/master/internal/db/postgres_test_utils.go b/master/internal/db/postgres_test_utils.go index 8424d9e05b7..1eabef57620 100644 --- a/master/internal/db/postgres_test_utils.go +++ b/master/internal/db/postgres_test_utils.go @@ -216,7 +216,7 @@ func RequireMockUser(t *testing.T, db *PgDB) model.User { } // RequireMockExperiment returns a mock experiment. -// nolint: exhaustivestruct +// nolint: exhaustruct func RequireMockExperiment(t *testing.T, db *PgDB, user model.User) *model.Experiment { cfg := schemas.WithDefaults(expconf.ExperimentConfigV0{ RawCheckpointStorage: &expconf.CheckpointStorageConfigV0{ diff --git a/master/internal/experiment.go b/master/internal/experiment.go index c8755f4d937..a6a1ac4fb43 100644 --- a/master/internal/experiment.go +++ b/master/internal/experiment.go @@ -1033,7 +1033,7 @@ func (e *internalExperiment) setPriority(priority *int, forward bool) (err error JobID: e.JobID, }).(type) { case nil: - case rmerrors.ErrUnsupported: + case rmerrors.UnsupportedError: e.syslog.WithError(err).Debug("ignoring unsupported call to set group priority") default: return errors.Wrapf(err, "setting experiment %d priority", e.ID) @@ -1059,7 +1059,7 @@ func (e *internalExperiment) setWeight(weight float64) error { JobID: e.JobID, }).(type) { case nil: - case rmerrors.ErrUnsupported: + case rmerrors.UnsupportedError: e.syslog.WithError(err).Debug("ignoring unsupported call to set group weight") default: resources.SetWeight(oldWeight) diff --git a/master/internal/populate_metrics.go b/master/internal/populate_metrics.go index ad415669f15..123aa6045ac 100644 --- a/master/internal/populate_metrics.go +++ b/master/internal/populate_metrics.go @@ -222,22 +222,22 @@ func PopulateExpTrialsMetrics(pgdb *db.PgDB, masterConfig *config.Config, trivia // create exp and config maxLength := expconf.NewLengthInBatches(100) maxRestarts := 0 - activeConfig := expconf.ExperimentConfig{ //nolint:exhaustivestruct - RawSearcher: &expconf.SearcherConfig{ //nolint:exhaustivestruct + activeConfig := expconf.ExperimentConfig{ //nolint:exhaustruct + RawSearcher: &expconf.SearcherConfig{ //nolint:exhaustruct RawMetric: ptrs.Ptr("loss"), - RawSingleConfig: &expconf.SingleConfig{ //nolint:exhaustivestruct + RawSingleConfig: &expconf.SingleConfig{ //nolint:exhaustruct RawMaxLength: &maxLength, }, }, RawEntrypoint: &expconf.Entrypoint{RawEntrypoint: "model_def:SomeTrialClass"}, RawHyperparameters: expconf.Hyperparameters{}, - RawCheckpointStorage: &expconf.CheckpointStorageConfig{ //nolint:exhaustivestruct - RawSharedFSConfig: &expconf.SharedFSConfig{ //nolint:exhaustivestruct + RawCheckpointStorage: &expconf.CheckpointStorageConfig{ //nolint:exhaustruct + RawSharedFSConfig: &expconf.SharedFSConfig{ //nolint:exhaustruct RawHostPath: ptrs.Ptr("/"), }, }, RawMaxRestarts: &maxRestarts, - } //nolint:exhaustivestruct + } //nolint:exhaustruct activeConfig = schemas.WithDefaults(activeConfig) model.DefaultTaskContainerDefaults().MergeIntoExpConfig(&activeConfig) diff --git a/master/internal/prom/det_state_metrics.go b/master/internal/prom/det_state_metrics.go index a5fc8b0f70c..2d7742e6115 100644 --- a/master/internal/prom/det_state_metrics.go +++ b/master/internal/prom/det_state_metrics.go @@ -116,7 +116,7 @@ func AssociateJobExperiment(jID model.JobID, eID string, labels expconf.Labels) // DisassociateJobExperiment disassociates a job ID with experiment info. func DisassociateJobExperiment(jID model.JobID, eID string, labels expconf.Labels) { jobIDToExperimentID.WithLabelValues(jID.String(), eID).Dec() - expLabels := make([]string, len(labels)) + expLabels := make([]string, 0, len(labels)) for l := range labels { expLabels = append(expLabels, l) diff --git a/master/internal/proxy/proxy.go b/master/internal/proxy/proxy.go index e1ff939d5dd..0f26d526a1b 100644 --- a/master/internal/proxy/proxy.go +++ b/master/internal/proxy/proxy.go @@ -88,7 +88,6 @@ func (p *Proxy) Register(serviceID string, url *url.URL, proxyTCP bool, unauth b ProxyTCP: proxyTCP, AllowUnauthenticated: unauth, } - return } // Unregister removes the service from the proxy. All future requests until the service name is diff --git a/master/internal/proxy/proxy_intg_test.go b/master/internal/proxy/proxy_intg_test.go index 8ee6e4d8971..7da31b2e98f 100644 --- a/master/internal/proxy/proxy_intg_test.go +++ b/master/internal/proxy/proxy_intg_test.go @@ -63,6 +63,7 @@ func waitForCondition(timeout time.Duration, condition func() bool) bool { } func conditionServerUp() bool { + //nolint: noctx resp, err := http.Get("http://" + u.Path + "/proxy") if err == nil { resp.Body.Close() //nolint:errcheck diff --git a/master/internal/restore_test.go b/master/internal/restore_test.go index d6493cc5c02..af14e869288 100644 --- a/master/internal/restore_test.go +++ b/master/internal/restore_test.go @@ -33,9 +33,9 @@ func TestDeserExperimentSnapshotIntoCurrent(t *testing.T) { name: "single", experiment: func() *internalExperiment { e := &internalExperiment{} - //nolint:exhaustivestruct + //nolint:exhaustruct single := expconf.SearcherConfig{ - //nolint:exhaustivestruct + //nolint:exhaustruct RawSingleConfig: &expconf.SingleConfig{ RawMaxLength: &expconf.Length{ Unit: expconf.Batches, @@ -54,9 +54,9 @@ func TestDeserExperimentSnapshotIntoCurrent(t *testing.T) { name: "asha", experiment: func() *internalExperiment { e := &internalExperiment{} - //nolint:exhaustivestruct + //nolint:exhaustruct asha := expconf.SearcherConfig{ - //nolint:exhaustivestruct + //nolint:exhaustruct RawAsyncHalvingConfig: &expconf.AsyncHalvingConfig{ RawNumRungs: ptrs.Ptr(4), RawStopOnce: ptrs.Ptr(false), diff --git a/master/internal/rm/agentrm/resource_pool.go b/master/internal/rm/agentrm/resource_pool.go index 73d84d95bd3..0fb92d1cd32 100644 --- a/master/internal/rm/agentrm/resource_pool.go +++ b/master/internal/rm/agentrm/resource_pool.go @@ -140,7 +140,7 @@ func (rp *resourcePool) allocateRequest(ctx *actor.Context, msg sproto.AllocateR log.WithError(err).Error("error restoring resources") // Clear out the state / close and terminate the allocation. - rmevents.Publish(msg.AllocationID, &sproto.ResourcesFailure{ + rmevents.Publish(msg.AllocationID, &sproto.ResourcesFailureError{ FailureType: sproto.RestoreError, ErrMsg: err.Error(), ExitCode: nil, diff --git a/master/internal/rm/kubernetesrm/pods.go b/master/internal/rm/kubernetesrm/pods.go index b029adce65a..a45915aa13c 100644 --- a/master/internal/rm/kubernetesrm/pods.go +++ b/master/internal/rm/kubernetesrm/pods.go @@ -1026,7 +1026,7 @@ func (p *pods) disableNode( func (p *pods) releaseAllocationsOnDisabledNode(nodeName string) error { listOptions := metaV1.ListOptions{ - LabelSelector: fmt.Sprintf("%s", determinedLabel), + LabelSelector: determinedLabel, FieldSelector: fmt.Sprintf("spec.nodeName=%s", nodeName), } pods, err := p.listPodsInAllNamespaces(context.TODO(), listOptions) diff --git a/master/internal/rm/kubernetesrm/resource_pool.go b/master/internal/rm/kubernetesrm/resource_pool.go index 26a046b0207..12e7a5e2c8c 100644 --- a/master/internal/rm/kubernetesrm/resource_pool.go +++ b/master/internal/rm/kubernetesrm/resource_pool.go @@ -175,7 +175,7 @@ func (k *kubernetesResourcePool) SetGroupWeight(msg sproto.SetGroupWeight) error defer k.mu.Unlock() k.reschedule = true - return rmerrors.ErrUnsupported("set group weight is unsupported in k8s") + return rmerrors.UnsupportedError("set group weight is unsupported in k8s") } func (k *kubernetesResourcePool) SetGroupPriority(msg sproto.SetGroupPriority) error { @@ -189,7 +189,7 @@ func (k *kubernetesResourcePool) SetGroupPriority(msg sproto.SetGroupPriority) e for it := k.reqList.Iterator(); it.Next(); { if it.Value().JobID == msg.JobID { if req := it.Value(); !req.Preemptible { - return rmerrors.ErrUnsupported(fmt.Sprintf( + return rmerrors.UnsupportedError(fmt.Sprintf( "priority is immutable for %s in k8s because it may be destructive", req.Name, )) @@ -517,7 +517,7 @@ func (k *kubernetesResourcePool) assignResources( WithField("allocation-id", req.AllocationID). WithError(err).Error("unable to restore allocation") unknownExit := sproto.ExitCode(-1) - rmevents.Publish(req.AllocationID, &sproto.ResourcesFailure{ + rmevents.Publish(req.AllocationID, &sproto.ResourcesFailureError{ FailureType: sproto.ResourcesMissing, ErrMsg: errors.Wrap(err, "unable to restore allocation").Error(), ExitCode: &unknownExit, diff --git a/master/internal/rm/kubernetesrm/spec_test.go b/master/internal/rm/kubernetesrm/spec_test.go index 101d9ffc182..95de75229fb 100644 --- a/master/internal/rm/kubernetesrm/spec_test.go +++ b/master/internal/rm/kubernetesrm/spec_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package kubernetesrm import ( diff --git a/master/internal/rm/rmerrors/errors.go b/master/internal/rm/rmerrors/errors.go index c74b5abcc04..737d6d1dfff 100644 --- a/master/internal/rm/rmerrors/errors.go +++ b/master/internal/rm/rmerrors/errors.go @@ -2,10 +2,10 @@ package rmerrors import "github.com/pkg/errors" -// ErrUnsupported is returned when an unsupported feature of a resource manager is used. -type ErrUnsupported string +// UnsupportedError is returned when an unsupported feature of a resource manager is used. +type UnsupportedError string -func (e ErrUnsupported) Error() string { +func (e UnsupportedError) Error() string { return string(e) } diff --git a/master/internal/rm/rmevents/rmevents.go b/master/internal/rm/rmevents/rmevents.go index aa1865fe831..12fce7dd6ea 100644 --- a/master/internal/rm/rmevents/rmevents.go +++ b/master/internal/rm/rmevents/rmevents.go @@ -118,5 +118,4 @@ func unsub( if len(subsByTopicByID[msg.topic]) == 0 { delete(subsByTopicByID, msg.topic) } - return } diff --git a/master/internal/sproto/resources.go b/master/internal/sproto/resources.go index 8ef46694bb0..9037511575b 100644 --- a/master/internal/sproto/resources.go +++ b/master/internal/sproto/resources.go @@ -108,7 +108,7 @@ func FromContainerStarted(cs *aproto.ContainerStarted) *ResourcesStarted { // ResourcesStopped contains the information needed by tasks from container stopped. type ResourcesStopped struct { - Failure *ResourcesFailure + Failure *ResourcesFailureError } // Proto returns the proto representation of ResourcesStopped. @@ -129,7 +129,7 @@ func FromContainerStopped(cs *aproto.ContainerStopped) *ResourcesStopped { rs := &ResourcesStopped{} if f := cs.Failure; f != nil { - rs.Failure = &ResourcesFailure{ + rs.Failure = &ResourcesFailureError{ FailureType: FromContainerFailureType(f.FailureType), ErrMsg: f.ErrMsg, ExitCode: FromContainerExitCode(f.ExitCode), @@ -143,14 +143,14 @@ func FromContainerStopped(cs *aproto.ContainerStopped) *ResourcesStopped { func ResourcesError(failureType FailureType, err error) ResourcesStopped { if err == nil { return ResourcesStopped{ - Failure: &ResourcesFailure{ + Failure: &ResourcesFailureError{ FailureType: failureType, ErrMsg: errors.WithStack(errors.Errorf("unknown error occurred")).Error(), }, } } return ResourcesStopped{ - Failure: &ResourcesFailure{ + Failure: &ResourcesFailureError{ FailureType: failureType, ErrMsg: err.Error(), }, @@ -164,15 +164,15 @@ func (r ResourcesStopped) String() string { return r.Failure.Error() } -// ResourcesFailure contains information about restored resources' failure. -type ResourcesFailure struct { +// ResourcesFailureError contains information about restored resources' failure. +type ResourcesFailureError struct { FailureType FailureType ErrMsg string ExitCode *ExitCode } // Proto returns the proto representation of ResourcesFailure. -func (f *ResourcesFailure) Proto() *taskv1.ResourcesFailure { +func (f *ResourcesFailureError) Proto() *taskv1.ResourcesFailure { if f == nil { return nil } @@ -193,20 +193,20 @@ func (f *ResourcesFailure) Proto() *taskv1.ResourcesFailure { // NewResourcesFailure returns a resources failure message wrapping the type, msg and exit code. func NewResourcesFailure( failureType FailureType, msg string, code *ExitCode, -) *ResourcesFailure { - return &ResourcesFailure{ +) *ResourcesFailureError { + return &ResourcesFailureError{ FailureType: failureType, ErrMsg: msg, ExitCode: code, } } -func (f ResourcesFailure) Error() string { +func (f ResourcesFailureError) Error() string { if f.ExitCode == nil { if len(f.ErrMsg) > 0 { return fmt.Sprintf("%s: %s", f.FailureType, f.ErrMsg) } - return fmt.Sprintf("%s", f.FailureType) + return string(f.FailureType) } return fmt.Sprintf("%s: %s (exit code %d)", f.FailureType, f.ErrMsg, *f.ExitCode) } @@ -336,7 +336,7 @@ func IsUnrecoverableSystemError(err error) bool { // shouldn't count against `max_restarts`. func IsTransientSystemError(err error) bool { switch err := err.(type) { - case ResourcesFailure: + case ResourcesFailureError: switch err.FailureType { case ResourcesFailed, TaskError: return false diff --git a/master/internal/sproto/task.go b/master/internal/sproto/task.go index 2334087478c..a9dcddcd8c9 100644 --- a/master/internal/sproto/task.go +++ b/master/internal/sproto/task.go @@ -136,7 +136,7 @@ func (*ReleaseResources) ResourcesEvent() {} func (*ResourcesStateChanged) ResourcesEvent() {} // ResourcesEvent implements ResourcesEvent. -func (*ResourcesFailure) ResourcesEvent() {} +func (*ResourcesFailureError) ResourcesEvent() {} // ResourcesEvent implements ResourcesEvent. func (*ContainerLog) ResourcesEvent() {} diff --git a/master/internal/task/allocation.go b/master/internal/task/allocation.go index 3d1130dfab4..2a8a1006a02 100644 --- a/master/internal/task/allocation.go +++ b/master/internal/task/allocation.go @@ -232,7 +232,7 @@ func (a *allocation) HandleRMEvent(msg sproto.ResourcesEvent) { } case *sproto.ResourcesStateChanged: a.resourcesStateChanged(msg) - case *sproto.ResourcesFailure: + case *sproto.ResourcesFailureError: a.restoreResourceFailure(msg) case *sproto.ReleaseResources: a.releaseResources(msg) @@ -359,7 +359,7 @@ func (a *allocation) SetResourcesAsDaemon(_ context.Context, rID sproto.Resource defer a.mu.Unlock() if _, ok := a.resources[rID]; !ok { - return ErrStaleResources{ID: rID} + return StaleResourcesError{ID: rID} } else if len(a.resources) <= 1 { // Ignoring request to daemonize resources within an allocation for an allocation // with only one manageable set of resources, because this would just kill it. This is @@ -434,14 +434,14 @@ func (a *allocation) validateRendezvous() error { } if len(a.resources) == 0 { - return ErrAllocationUnfulfilled{Action: "rendezvous"} + return AllocationUnfulfilledError{Action: "rendezvous"} } switch a.resources.first().Summary().ResourcesType { case sproto.ResourcesTypeDockerContainer, sproto.ResourcesTypeK8sPod: break default: - return ErrBehaviorUnsupported{Behavior: "rendezvous"} + return BehaviorUnsupportedError{Behavior: "rendezvous"} } return nil @@ -540,7 +540,7 @@ func (a *allocation) resourcesAllocated(msg *sproto.ResourcesAllocated) error { if a.getModelState() != model.AllocationStatePending { // If we have moved on from the pending state, these must be stale (and we must have // already released them, just the scheduler hasn't gotten word yet). - return ErrStaleResourcesReceived{} + return StaleResourcesReceivedError{} } a.setModelState(model.AllocationStateAssigned) } else { @@ -663,7 +663,7 @@ func (a *allocation) resourcesStateChanged(msg *sproto.ResourcesStateChanged) { if _, ok := a.resources[msg.ResourcesID]; !ok { a.syslog. WithField("container", msg.Container). - WithError(ErrStaleResources{ID: msg.ResourcesID}).Warnf("old state change") + WithError(StaleResourcesError{ID: msg.ResourcesID}).Warnf("old state change") return } @@ -788,7 +788,7 @@ func (a *allocation) resourcesStateChanged(msg *sproto.ResourcesStateChanged) { } // restoreResourceFailure handles the restored resource failures. -func (a *allocation) restoreResourceFailure(msg *sproto.ResourcesFailure) { +func (a *allocation) restoreResourceFailure(msg *sproto.ResourcesFailureError) { a.syslog.Debugf("allocation resource failure") a.setMostProgressedModelState(model.AllocationStateTerminating) @@ -967,7 +967,7 @@ func (a *allocation) exitedWithoutErr() bool { func (a *allocation) SetExitStatus(exitReason string, exitErr error, statusCode *int32) { switch err := exitErr.(type) { - case sproto.ResourcesFailure: + case sproto.ResourcesFailureError: a.model.ExitErr = ptrs.Ptr(err.Error()) if err.ExitCode != nil { a.model.StatusCode = ptrs.Ptr(int32(*err.ExitCode)) @@ -1097,7 +1097,7 @@ func (a *allocation) calculateExitStatus(reason string) ( return fmt.Sprintf("allocation stopped early after %s", reason), true, logrus.InfoLevel, nil case a.exitErr != nil: switch err := a.exitErr.(type) { - case sproto.ResourcesFailure: + case sproto.ResourcesFailureError: switch err.FailureType { case sproto.ResourcesFailed, sproto.TaskError: if a.killedDaemonsGracefully { diff --git a/master/internal/task/allocation_intg_test.go b/master/internal/task/allocation_intg_test.go index 6dae753b307..895ede5f914 100644 --- a/master/internal/task/allocation_intg_test.go +++ b/master/internal/task/allocation_intg_test.go @@ -38,7 +38,7 @@ func (m mockTaskSpecifier) ToTaskSpec() (t tasks.TaskSpec) { func TestAllocation(t *testing.T) { cases := []struct { name string - err *sproto.ResourcesFailure + err *sproto.ResourcesFailureError acked bool exit *AllocationExited }{ @@ -55,13 +55,13 @@ func TestAllocation(t *testing.T) { { name: "container failed", acked: false, - err: &sproto.ResourcesFailure{FailureType: sproto.ResourcesFailed}, - exit: &AllocationExited{Err: sproto.ResourcesFailure{FailureType: sproto.ResourcesFailed}}, + err: &sproto.ResourcesFailureError{FailureType: sproto.ResourcesFailed}, + exit: &AllocationExited{Err: sproto.ResourcesFailureError{FailureType: sproto.ResourcesFailed}}, }, { name: "container failed, but acked preemption", acked: true, - err: &sproto.ResourcesFailure{FailureType: sproto.ResourcesFailed}, + err: &sproto.ResourcesFailureError{FailureType: sproto.ResourcesFailed}, exit: &AllocationExited{}, }, } diff --git a/master/internal/task/allocation_service.go b/master/internal/task/allocation_service.go index 1f225019be9..9382b5f2399 100644 --- a/master/internal/task/allocation_service.go +++ b/master/internal/task/allocation_service.go @@ -276,6 +276,7 @@ func (as *allocationService) WatchPreemption( _, err := as.waitForRestore(context.TODO(), id) if err != nil { // HACK: Swallow the error since contexts with an instant timeout still expect a status. + //nolint: nilerr return false, nil } diff --git a/master/internal/task/allocation_service_test.go b/master/internal/task/allocation_service_test.go index fe5dd17d539..6c8da404ccc 100644 --- a/master/internal/task/allocation_service_test.go +++ b/master/internal/task/allocation_service_test.go @@ -39,7 +39,7 @@ func TestRestoreFailed(t *testing.T) { db, _, id, q, exitFuture := requireStarted(t) defer requireKilled(t, db, id, q, exitFuture) - q.Put(&sproto.ResourcesFailure{ + q.Put(&sproto.ResourcesFailureError{ FailureType: sproto.RestoreError, ErrMsg: "things weren't there", }) @@ -538,7 +538,7 @@ func requireAssignedMany( ResourcesID: rID, ResourcesState: sproto.Terminated, ResourcesStopped: &sproto.ResourcesStopped{ - Failure: &sproto.ResourcesFailure{ + Failure: &sproto.ResourcesFailureError{ FailureType: sproto.TaskError, ErrMsg: "exit code 137", ExitCode: ptrs.Ptr(sproto.ExitCode(137)), diff --git a/master/internal/task/errors.go b/master/internal/task/errors.go index e2b39aead9e..3f9c580c6cd 100644 --- a/master/internal/task/errors.go +++ b/master/internal/task/errors.go @@ -7,81 +7,81 @@ import ( "github.com/determined-ai/determined/master/pkg/cproto" ) -// ErrTimeoutExceeded is return, with a bit of detail, when a timeout is exceeded. -type ErrTimeoutExceeded struct { +// TimeoutExceededError is return, with a bit of detail, when a timeout is exceeded. +type TimeoutExceededError struct { Message string } -func (e ErrTimeoutExceeded) Error() string { +func (e TimeoutExceededError) Error() string { return fmt.Sprintf("timeout exceeded: %s", e.Message) } -// ErrNoAllocation is returned an operation is tried without a requested allocation. -type ErrNoAllocation struct { +// NoAllocationError is returned an operation is tried without a requested allocation. +type NoAllocationError struct { Action string } -func (e ErrNoAllocation) Error() string { +func (e NoAllocationError) Error() string { return fmt.Sprintf("%s not valid without requested allocation", e.Action) } -// ErrAllocationUnfulfilled is returned an operation is tried without an active allocation. -type ErrAllocationUnfulfilled struct { +// AllocationUnfulfilledError is returned an operation is tried without an active allocation. +type AllocationUnfulfilledError struct { Action string } -func (e ErrAllocationUnfulfilled) Error() string { +func (e AllocationUnfulfilledError) Error() string { return fmt.Sprintf("%s not valid without active allocation", e.Action) } -// ErrStaleResourcesReceived is returned the scheduler gives an allocation resources between +// StaleResourcesReceivedError is returned the scheduler gives an allocation resources between // when it requests them and it deciding, for some reason or another, they are not needed. -type ErrStaleResourcesReceived struct{} +type StaleResourcesReceivedError struct{} -func (e ErrStaleResourcesReceived) Error() string { +func (e StaleResourcesReceivedError) Error() string { return "allocation no longer needs these resources" } -// ErrStaleContainer is returned when an operation was attempted by a stale container. -type ErrStaleContainer struct { +// StaleContainerError is returned when an operation was attempted by a stale container. +type StaleContainerError struct { ID cproto.ID } -func (e ErrStaleContainer) Error() string { +func (e StaleContainerError) Error() string { return fmt.Sprintf("stale container %s", e.ID) } -// ErrStaleResources is returned when an operation was attempted by a stale resources. -type ErrStaleResources struct { +// StaleResourcesError is returned when an operation was attempted by a stale resources. +type StaleResourcesError struct { ID sproto.ResourcesID } -func (e ErrStaleResources) Error() string { +func (e StaleResourcesError) Error() string { return fmt.Sprintf("stale resources %s", e.ID) } -// ErrBehaviorDisabled is returned an operation is tried without the behavior being enabled. -type ErrBehaviorDisabled struct { +// BehaviorDisabledError is returned an operation is tried without the behavior being enabled. +type BehaviorDisabledError struct { Behavior string } -func (e ErrBehaviorDisabled) Error() string { +func (e BehaviorDisabledError) Error() string { return fmt.Sprintf("%s not enabled for this allocation", e.Behavior) } -// ErrBehaviorUnsupported is returned an operation is tried without the behavior being supported. -type ErrBehaviorUnsupported struct { +// BehaviorUnsupportedError is returned an operation is tried without the behavior being supported. +type BehaviorUnsupportedError struct { Behavior string } -func (e ErrBehaviorUnsupported) Error() string { +func (e BehaviorUnsupportedError) Error() string { return fmt.Sprintf("%s not supported for this allocation or resource manager", e.Behavior) } -// ErrAlreadyCancelled is returned to the allocation when it tries to take an action but has an +// AlreadyCancelledError is returned to the allocation when it tries to take an action but has an // unread cancellation in its inbox. -type ErrAlreadyCancelled struct{} +type AlreadyCancelledError struct{} -func (e ErrAlreadyCancelled) Error() string { +func (e AlreadyCancelledError) Error() string { return "the allocation was canceled while this message was waiting" } diff --git a/master/internal/task/rendezvous.go b/master/internal/task/rendezvous.go index 471d9b1345c..575a5726070 100644 --- a/master/internal/task/rendezvous.go +++ b/master/internal/task/rendezvous.go @@ -68,7 +68,7 @@ func newRendezvous( func (r *rendezvous) watch(rID sproto.ResourcesID) (RendezvousWatcher, error) { if _, ok := r.resources[rID]; !ok { - err := ErrStaleResources{ID: rID} + err := StaleResourcesError{ID: rID} return RendezvousWatcher{}, apiutils.AsValidationError(err.Error()) } else if _, ok := r.watchers[rID]; ok { return RendezvousWatcher{}, apiutils.AsValidationError("resources already rendezvoused: %s", rID) @@ -153,7 +153,7 @@ func (r *rendezvous) checkTimeout() error { exceededTimeout := time.Now().After(r.lastWatchTime.Add(r.timeout)) if exceededTimeout { - return ErrTimeoutExceeded{ + return TimeoutExceededError{ Message: "some containers are taking a long time to " + "connect to master; when running on kubernetes this may happen " + "because only some of the pods have been scheduled; it is possible " + diff --git a/master/internal/telemetry/telemetry_test.go b/master/internal/telemetry/telemetry_test.go index 443f60d5649..af7d73e7380 100644 --- a/master/internal/telemetry/telemetry_test.go +++ b/master/internal/telemetry/telemetry_test.go @@ -112,6 +112,7 @@ func initMockedTelemetry(t *testing.T) (*mockClient, *mocks.ResourceManager, *mo // Helper function for ReportExperimentCreated. func createExpConfig() expconf.ExperimentConfig { maxLength := expconf.NewLengthInBatches(100) + //nolint:exhaustruct activeConfig := expconf.ExperimentConfig{ RawSearcher: &expconf.SearcherConfig{ RawMetric: ptrs.Ptr("loss"), diff --git a/master/internal/templates/service_intg_test.go b/master/internal/templates/service_intg_test.go index 049f76af977..20d67cae165 100644 --- a/master/internal/templates/service_intg_test.go +++ b/master/internal/templates/service_intg_test.go @@ -52,6 +52,7 @@ func TestUnmarshalTemplateConfig(t *testing.T) { require.NoError(t, err) requireToJSONEq(t, input, resp.Template) + //nolint:exhaustruct fakeConfig := schemas.WithDefaults(expconf.ExperimentConfigV0{ RawCheckpointStorage: &expconf.CheckpointStorageConfigV0{ RawSharedFSConfig: &expconf.SharedFSConfigV0{ diff --git a/master/internal/trial_intg_test.go b/master/internal/trial_intg_test.go index 5f5f634e570..d0d32ab4ab8 100644 --- a/master/internal/trial_intg_test.go +++ b/master/internal/trial_intg_test.go @@ -1,7 +1,7 @@ //go:build integration // +build integration -//nolint:exhaustivestruct +//nolint:exhaustruct package internal import ( diff --git a/master/internal/trials/postgres_trials_intg_test.go b/master/internal/trials/postgres_trials_intg_test.go index ae94b3676b1..bd42faa9c57 100644 --- a/master/internal/trials/postgres_trials_intg_test.go +++ b/master/internal/trials/postgres_trials_intg_test.go @@ -95,9 +95,7 @@ func TestMarkLostTrials(t *testing.T) { trialIds := []int{} for _, trs := range trials { - for _, trialID := range trs { - trialIds = append(trialIds, trialID) - } + trialIds = append(trialIds, trs...) } _, err := db.Bun().NewDelete().Model((*Trial)(nil)). diff --git a/master/internal/user/postgres_users.go b/master/internal/user/postgres_users.go index cb378c33223..8eee8c746c9 100644 --- a/master/internal/user/postgres_users.go +++ b/master/internal/user/postgres_users.go @@ -141,7 +141,7 @@ func DeleteSessionByToken(ctx context.Context, token string) error { var session model.UserSession // verification will fail when using external token (Jwt instead of Paseto) if err := v2.Verify(token, db.GetTokenKeys().PublicKey, &session, nil); err != nil { - return nil + return nil //nolint: nilerr } return DeleteSessionByID(ctx, session.ID) } diff --git a/master/internal/usergroup/group_intg_test.go b/master/internal/usergroup/group_intg_test.go index 1fc68afd6a7..74d6485c0ef 100644 --- a/master/internal/usergroup/group_intg_test.go +++ b/master/internal/usergroup/group_intg_test.go @@ -264,13 +264,13 @@ func TestUserGroups(t *testing.T) { t.Run("update groups and memberships", func(t *testing.T) { updateTestUser1 := model.User{ ID: 9861724, - Username: fmt.Sprintf("IntegrationTest#{9861724}"), + Username: "IntegrationTest#{9861724}", Admin: false, Active: false, } updateTestUser2 := model.User{ ID: 16780345, - Username: fmt.Sprintf("IntegrationTest#{16780345}"), + Username: "IntegrationTest#{16780345}", Admin: false, Active: false, } diff --git a/master/internal/webhooks/shipper.go b/master/internal/webhooks/shipper.go index df5d8f528e1..82102cc8f14 100644 --- a/master/internal/webhooks/shipper.go +++ b/master/internal/webhooks/shipper.go @@ -197,9 +197,9 @@ func (w *worker) deliver(ctx context.Context, e Event) error { }() switch { - case resp.StatusCode >= 500: + case resp.StatusCode >= 500: //nolint: usestdlibvars return fmt.Errorf("request returned %v: %w", resp.StatusCode, err) - case resp.StatusCode >= 400: + case resp.StatusCode >= 400: //nolint: usestdlibvars return back.Permanent(fmt.Errorf("request returned %v: %w", resp.StatusCode, err)) default: return nil diff --git a/master/internal/webhooks/shipper_test.go b/master/internal/webhooks/shipper_test.go index f5283327ef8..3e021f6428f 100644 --- a/master/internal/webhooks/shipper_test.go +++ b/master/internal/webhooks/shipper_test.go @@ -50,6 +50,7 @@ func TestShipper(t *testing.T) { ProjectName: "project", } b, _ := json.Marshal(e) + //nolint: noctx req, _ := http.NewRequest(http.MethodPost, url, bytes.NewBuffer(b)) key := []byte("testsigningkey") signedPayload := generateSignedPayload(req, ts, key) diff --git a/master/pkg/actor/context.go b/master/pkg/actor/context.go index 4b689edd877..00cda9e6036 100644 --- a/master/pkg/actor/context.go +++ b/master/pkg/actor/context.go @@ -9,6 +9,7 @@ import ( ) // Context holds contextual information for the context's recipient and the current message. +// nolint: containedctx type Context struct { inner context.Context message Message diff --git a/master/pkg/actor/errors.go b/master/pkg/actor/errors.go index 93873fe2f15..7488a2ca7f6 100644 --- a/master/pkg/actor/errors.go +++ b/master/pkg/actor/errors.go @@ -11,11 +11,11 @@ import ( // has no response. var errNoResponse = errors.New("no response from actor") -type errUnexpectedMessage struct { +type unexpectedMessageError struct { ctx *Context } -func (e errUnexpectedMessage) Error() string { +func (e unexpectedMessageError) Error() string { var msg interface{} = e.ctx.Message() if v := reflect.ValueOf(e.ctx.Message()); v.Kind() == reflect.Ptr { msg = v.Elem().Interface() @@ -39,5 +39,5 @@ func (e errUnexpectedMessage) Error() string { // ErrUnexpectedMessage is returned by an actor in response to a message that it was not expecting // to receive. func ErrUnexpectedMessage(ctx *Context) error { - return errUnexpectedMessage{ctx: ctx} + return unexpectedMessageError{ctx: ctx} } diff --git a/master/pkg/actor/errors_test.go b/master/pkg/actor/errors_test.go index 45ccd7a94e6..a8bcad1eefe 100644 --- a/master/pkg/actor/errors_test.go +++ b/master/pkg/actor/errors_test.go @@ -52,7 +52,7 @@ func Test_errUnexpectedMessage_Error(t *testing.T) { } runTestCase := func(t *testing.T, tc testCase) { t.Run(tc.name, func(t *testing.T) { - e := errUnexpectedMessage{ + e := unexpectedMessageError{ ctx: tc.fields.ctx, } if got := e.Error(); got != tc.want { diff --git a/master/pkg/actor/ref.go b/master/pkg/actor/ref.go index 0b6492f4c4e..58103a4e9d2 100644 --- a/master/pkg/actor/ref.go +++ b/master/pkg/actor/ref.go @@ -154,7 +154,7 @@ func (r *Ref) sendInternalMessage(message Message) error { ctx := &Context{recipient: r, message: message} err := r.actor.Receive(ctx) // `errUnexpectedMessage` is ignored; other errors cause the actor to shut down. - if _, ok := err.(errUnexpectedMessage); err != nil && !ok { + if _, ok := err.(unexpectedMessageError); err != nil && !ok { return err } return nil diff --git a/master/pkg/actor/response_test.go b/master/pkg/actor/response_test.go index 81b4689ae7e..5ed65d83b21 100644 --- a/master/pkg/actor/response_test.go +++ b/master/pkg/actor/response_test.go @@ -19,7 +19,7 @@ func TestResponseTimeout(t *testing.T) { })) start := time.Now() result, ok := system.Ask(ref, "").GetOrElseTimeout(true, 1*time.Millisecond) - duration := time.Now().Sub(start) + duration := time.Since(start) assert.Assert(t, duration < sleepDuration, "test duration: %d ms", duration.Milliseconds()) assert.Assert(t, result.(bool)) assert.Assert(t, !ok) @@ -36,7 +36,7 @@ func TestResponseTimeoutOk(t *testing.T) { start := time.Now() timeoutDuration := 1 * time.Second result, ok := system.Ask(ref, "").GetOrElseTimeout(true, timeoutDuration) - duration := time.Now().Sub(start) + duration := time.Since(start) assert.Assert(t, duration < timeoutDuration, "test duration: %d ms", duration.Milliseconds()) assert.Assert(t, result.(bool) == false) assert.Assert(t, ok) diff --git a/master/pkg/aproto/exit.go b/master/pkg/aproto/exit.go index accb5423eac..412006c34e1 100644 --- a/master/pkg/aproto/exit.go +++ b/master/pkg/aproto/exit.go @@ -6,14 +6,14 @@ import ( "github.com/pkg/errors" ) -// ContainerFailure holds the reason why a container did not complete successfully. -type ContainerFailure struct { +// ContainerFailureError holds the reason why a container did not complete successfully. +type ContainerFailureError struct { FailureType FailureType ErrMsg string ExitCode *ExitCode } -func (c ContainerFailure) Error() string { +func (c ContainerFailureError) Error() string { if c.ExitCode == nil { return fmt.Sprintf("%s: %s", c.FailureType, c.ErrMsg) } @@ -33,14 +33,14 @@ const ( func ContainerError(failureType FailureType, err error) ContainerStopped { if err == nil { return ContainerStopped{ - Failure: &ContainerFailure{ + Failure: &ContainerFailureError{ FailureType: failureType, ErrMsg: errors.WithStack(errors.Errorf("unknown error occurred")).Error(), }, } } return ContainerStopped{ - Failure: &ContainerFailure{ + Failure: &ContainerFailureError{ FailureType: failureType, ErrMsg: err.Error(), }, @@ -49,14 +49,14 @@ func ContainerError(failureType FailureType, err error) ContainerStopped { // NewContainerFailure returns a container failure wrapping the provided error. If the error is nil, // a stack trace is provided instead. -func NewContainerFailure(failureType FailureType, err error) *ContainerFailure { +func NewContainerFailure(failureType FailureType, err error) *ContainerFailureError { if err == nil { - return &ContainerFailure{ + return &ContainerFailureError{ FailureType: failureType, ErrMsg: errors.WithStack(errors.Errorf("unknown error occurred")).Error(), } } - return &ContainerFailure{ + return &ContainerFailureError{ FailureType: failureType, ErrMsg: err.Error(), } @@ -64,11 +64,11 @@ func NewContainerFailure(failureType FailureType, err error) *ContainerFailure { // NewContainerExit returns a container failure with the encoded exit code. If the exit code is a // the zero value, no failure is returned. -func NewContainerExit(code ExitCode) *ContainerFailure { +func NewContainerExit(code ExitCode) *ContainerFailureError { if code == SuccessExitCode { return nil } - return &ContainerFailure{ + return &ContainerFailureError{ FailureType: ContainerFailed, ErrMsg: errors.Errorf("%s: %d", ContainerFailed, code).Error(), ExitCode: &code, @@ -82,7 +82,7 @@ func ContainerExited(code ExitCode) ContainerStopped { return ContainerStopped{} } return ContainerStopped{ - &ContainerFailure{ + &ContainerFailureError{ FailureType: ContainerFailed, ErrMsg: errors.Errorf("%s: %d", ContainerFailed, code).Error(), ExitCode: &code, diff --git a/master/pkg/aproto/master_message.go b/master/pkg/aproto/master_message.go index 17ed32a4750..1aad3bdee2d 100644 --- a/master/pkg/aproto/master_message.go +++ b/master/pkg/aproto/master_message.go @@ -50,7 +50,7 @@ type ContainerReattach struct { // ContainerReattachAck is a struct describing containers reattachment success. type ContainerReattachAck struct { Container cproto.Container - Failure *ContainerFailure + Failure *ContainerFailureError } // FromContainerStateChanged forms a container reattach ack from a state change message. @@ -160,7 +160,7 @@ func (c ContainerStarted) Addresses() []cproto.Address { // ContainerStopped notifies the master that a container was stopped on the agent. type ContainerStopped struct { - Failure *ContainerFailure + Failure *ContainerFailureError } func (c ContainerStopped) String() string { diff --git a/master/pkg/checkpoints/s3/s3checkpoints.go b/master/pkg/checkpoints/s3/s3checkpoints.go index 4a63d296aba..18f89e08f7b 100644 --- a/master/pkg/checkpoints/s3/s3checkpoints.go +++ b/master/pkg/checkpoints/s3/s3checkpoints.go @@ -39,7 +39,7 @@ func GetS3BucketRegion(ctx context.Context, bucket string) (string, error) { Region: aws.String("us-west-2"), }) if err != nil { - return "", nil + return "", err } out, err := s3.New(sess).GetBucketLocationWithContext(ctx, &s3.GetBucketLocationInput{ diff --git a/master/pkg/model/task_container_defaults.go b/master/pkg/model/task_container_defaults.go index 09b59c730cc..bff10e5a9e6 100644 --- a/master/pkg/model/task_container_defaults.go +++ b/master/pkg/model/task_container_defaults.go @@ -106,7 +106,7 @@ func (c *TaskContainerDefaultsConfig) MergeIntoExpConfig(config *expconf.Experim } // Merge Resources-related settings into the config. - //nolint:exhaustivestruct // Devices are the only thing relevant from TaskContainerDefaults. + //nolint:exhaustruct // Devices are the only thing relevant from TaskContainerDefaults. resources := expconf.ResourcesConfig{ RawDevices: c.Devices.ToExpconf(), } @@ -131,7 +131,7 @@ func (c *TaskContainerDefaultsConfig) MergeIntoExpConfig(config *expconf.Experim podSpec = c.GPUPodSpec } - //nolint:exhaustivestruct // RawPorts is not in TaskContainerDefaults. + //nolint:exhaustruct // RawPorts is not in TaskContainerDefaults. env := expconf.EnvironmentConfig{ RawAddCapabilities: c.AddCapabilities, RawDropCapabilities: c.DropCapabilities, diff --git a/master/pkg/model/task_container_defaults_test.go b/master/pkg/model/task_container_defaults_test.go index f5f5d340877..b495d6bebd5 100644 --- a/master/pkg/model/task_container_defaults_test.go +++ b/master/pkg/model/task_container_defaults_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package model import ( diff --git a/master/pkg/model/test_utils.go b/master/pkg/model/test_utils.go index 0241e8b480d..80f3eb1015d 100644 --- a/master/pkg/model/test_utils.go +++ b/master/pkg/model/test_utils.go @@ -26,7 +26,7 @@ func (f ExperimentModelOptionFunc) apply(experiment *Experiment) { } // ExperimentModel returns a new experiment with the specified options. -// nolint: exhaustivestruct +// nolint: exhaustruct func ExperimentModel(opts ...ExperimentModelOption) (*Experiment, expconf.ExperimentConfig) { maxLength := expconf.NewLengthInBatches(100) activeConfig := expconf.ExperimentConfig{ diff --git a/master/pkg/schemas/expconf/experiment_config_test.go b/master/pkg/schemas/expconf/experiment_config_test.go index 31535879f8f..a69ff5adc0c 100644 --- a/master/pkg/schemas/expconf/experiment_config_test.go +++ b/master/pkg/schemas/expconf/experiment_config_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package expconf import ( diff --git a/master/pkg/schemas/expconf/legacy.go b/master/pkg/schemas/expconf/legacy.go index 8d385abc044..0c661c68af0 100644 --- a/master/pkg/schemas/expconf/legacy.go +++ b/master/pkg/schemas/expconf/legacy.go @@ -56,7 +56,7 @@ func getCheckpointStorage(raw map[string]interface{}) (CheckpointStorageConfig, saveTrialLatest = ptrs.Ptr(int(i)) } - // nolint: exhaustivestruct + // nolint: exhaustruct dummyHDFSSharedFS := schemas.WithDefaults(CheckpointStorageConfig{ RawSharedFSConfig: &SharedFSConfig{ RawHostPath: ptrs.Ptr("/legacy-hdfs-checkpoint-path"), diff --git a/master/pkg/schemas/expconf/legacy_test.go b/master/pkg/schemas/expconf/legacy_test.go index 819c676f388..5bd904245f9 100644 --- a/master/pkg/schemas/expconf/legacy_test.go +++ b/master/pkg/schemas/expconf/legacy_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package expconf import ( diff --git a/master/pkg/schemas/expconf/schema_test.go b/master/pkg/schemas/expconf/schema_test.go index 0b006fbb900..2b86a2dd6c5 100644 --- a/master/pkg/schemas/expconf/schema_test.go +++ b/master/pkg/schemas/expconf/schema_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package expconf import ( diff --git a/master/pkg/searcher/adaptive_asha_test.go b/master/pkg/searcher/adaptive_asha_test.go index 9585756f7ae..901668bd083 100644 --- a/master/pkg/searcher/adaptive_asha_test.go +++ b/master/pkg/searcher/adaptive_asha_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package searcher import ( diff --git a/master/pkg/searcher/asha_stopping_test.go b/master/pkg/searcher/asha_stopping_test.go index f7d7b6f9322..0228351d9bb 100644 --- a/master/pkg/searcher/asha_stopping_test.go +++ b/master/pkg/searcher/asha_stopping_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package searcher import ( diff --git a/master/pkg/searcher/asha_test.go b/master/pkg/searcher/asha_test.go index 071ed8513e4..393dc214a2a 100644 --- a/master/pkg/searcher/asha_test.go +++ b/master/pkg/searcher/asha_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package searcher import ( diff --git a/master/pkg/searcher/custom_search_test.go b/master/pkg/searcher/custom_search_test.go index 9019082fe85..7e119f9cfaa 100644 --- a/master/pkg/searcher/custom_search_test.go +++ b/master/pkg/searcher/custom_search_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package searcher import ( diff --git a/master/pkg/searcher/grid_test.go b/master/pkg/searcher/grid_test.go index 22ecef5e641..98be2970860 100644 --- a/master/pkg/searcher/grid_test.go +++ b/master/pkg/searcher/grid_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package searcher import ( diff --git a/master/pkg/searcher/random_test.go b/master/pkg/searcher/random_test.go index bc470acf973..2fdf6fb199e 100644 --- a/master/pkg/searcher/random_test.go +++ b/master/pkg/searcher/random_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package searcher import ( diff --git a/master/pkg/searcher/tournament_test.go b/master/pkg/searcher/tournament_test.go index 135a65eff64..ae51010aca1 100644 --- a/master/pkg/searcher/tournament_test.go +++ b/master/pkg/searcher/tournament_test.go @@ -1,4 +1,4 @@ -//nolint:exhaustivestruct +//nolint:exhaustruct package searcher import ( diff --git a/master/pkg/syncx/errgroupx/errgroupx.go b/master/pkg/syncx/errgroupx/errgroupx.go index e258ae3d498..2d38d1d4299 100644 --- a/master/pkg/syncx/errgroupx/errgroupx.go +++ b/master/pkg/syncx/errgroupx/errgroupx.go @@ -8,6 +8,7 @@ import ( // Group is a thin wrapper around golang.org/x/sync/errgroup.Group that helps not leak its context // past the lifetime of the group. +// nolint: containedctx type Group struct { inner *errgroup.Group ctx context.Context diff --git a/master/pkg/tasks/task_command.go b/master/pkg/tasks/task_command.go index 01db7fdb02a..28b954c585d 100644 --- a/master/pkg/tasks/task_command.go +++ b/master/pkg/tasks/task_command.go @@ -148,13 +148,8 @@ func (s *GenericCommandSpec) ProxyPorts() expconf.ProxyPortsConfig { epp := schemas.WithDefaults(s.Base.ExtraProxyPorts) out := make(expconf.ProxyPortsConfig, 0, len(epp)+len(env.ProxyPorts())) - for _, pp := range epp { - out = append(out, pp) - } - - for _, pp := range env.ProxyPorts() { - out = append(out, pp) - } + out = append(out, epp...) + out = append(out, env.ProxyPorts()...) return out } diff --git a/master/pkg/tasks/task_gc.go b/master/pkg/tasks/task_gc.go index 45b045eedbc..ee0e54a65e2 100644 --- a/master/pkg/tasks/task_gc.go +++ b/master/pkg/tasks/task_gc.go @@ -37,7 +37,7 @@ func (g GCCkptSpec) ToTaskSpec() TaskSpec { // Set Environment. // Keep only the EnvironmentVariables provided by the experiment's config. envVars := g.LegacyConfig.Environment.EnvironmentVariables() - //nolint:exhaustivestruct // This has caused an issue before, but is valid as a partial struct. + //nolint:exhaustruct // This has caused an issue before, but is valid as a partial struct. env := expconf.EnvironmentConfig{ RawEnvironmentVariables: &envVars, RawPodSpec: g.LegacyConfig.Environment.PodSpec(), diff --git a/master/pkg/tasks/task_trial.go b/master/pkg/tasks/task_trial.go index b3ec6bb6e81..7b6b5d3d5d2 100644 --- a/master/pkg/tasks/task_trial.go +++ b/master/pkg/tasks/task_trial.go @@ -181,13 +181,8 @@ func TrialSpecProxyPorts( epp := schemas.WithDefaults(taskSpec.ExtraProxyPorts) out := make(expconf.ProxyPortsConfig, 0, len(epp)+len(env.ProxyPorts())) - for _, pp := range epp { - out = append(out, pp) - } - - for _, pp := range env.ProxyPorts() { - out = append(out, pp) - } + out = append(out, epp...) + out = append(out, env.ProxyPorts()...) return out } From c40a8502914cd3321f188a5fc5e95d57cab5d4f3 Mon Sep 17 00:00:00 2001 From: Nicholas Blaskey Date: Wed, 8 Nov 2023 09:29:55 -0500 Subject: [PATCH 2/3] filled in tickets --- master/.golangci.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/master/.golangci.yml b/master/.golangci.yml index 29ed96c88f5..a1c80d0d6a2 100644 --- a/master/.golangci.yml +++ b/master/.golangci.yml @@ -93,15 +93,15 @@ linters: # comm -13 <(cut -d : -f 1 Date: Wed, 8 Nov 2023 09:31:38 -0500 Subject: [PATCH 3/3] fix rebase by adding wrap --- master/internal/rm/rmerrors/errors.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/master/internal/rm/rmerrors/errors.go b/master/internal/rm/rmerrors/errors.go index 737d6d1dfff..7cb2a980673 100644 --- a/master/internal/rm/rmerrors/errors.go +++ b/master/internal/rm/rmerrors/errors.go @@ -5,6 +5,10 @@ import "github.com/pkg/errors" // UnsupportedError is returned when an unsupported feature of a resource manager is used. type UnsupportedError string +func (e UnsupportedError) Unwrap() error { + return ErrNotSupported +} + func (e UnsupportedError) Error() string { return string(e) }