diff --git a/.golangci.yaml b/.golangci.yaml index 53d5c9aa7f0..028941bbec9 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -10,11 +10,11 @@ linters: - bidichk - bodyclose - containedctx + - copyloopvar - dupword - durationcheck - errcheck - errchkjson - - exportloopref - gocritic - godot - gofmt @@ -51,9 +51,11 @@ linters-settings: allow-leading-space: false require-specific: true revive: - revive: + # make sure error-strings issues actually surface (default confidence is 0.8) + confidence: 0.6 rules: - name: context-keys-type + - name: duplicated-imports - name: error-return - name: error-strings - name: error-naming diff --git a/Makefile b/Makefile index 07be5f53de5..ce8f7eafc6e 100644 --- a/Makefile +++ b/Makefile @@ -55,14 +55,10 @@ OPENSHIFT_GOIMPORTS_BIN := openshift-goimports OPENSHIFT_GOIMPORTS := $(TOOLS_DIR)/$(OPENSHIFT_GOIMPORTS_BIN)-$(OPENSHIFT_GOIMPORTS_VER) export OPENSHIFT_GOIMPORTS # so hack scripts can use it -GOLANGCI_LINT_VER := v1.58.1 +GOLANGCI_LINT_VER := v1.62.2 GOLANGCI_LINT_BIN := golangci-lint GOLANGCI_LINT := $(TOOLS_GOBIN_DIR)/$(GOLANGCI_LINT_BIN)-$(GOLANGCI_LINT_VER) -STATICCHECK_VER := 2023.1.7 -STATICCHECK_BIN := staticcheck -STATICCHECK := $(TOOLS_GOBIN_DIR)/$(STATICCHECK_BIN)-$(STATICCHECK_VER) - GOTESTSUM_VER := v1.8.1 GOTESTSUM_BIN := gotestsum GOTESTSUM := $(abspath $(TOOLS_DIR))/$(GOTESTSUM_BIN)-$(GOTESTSUM_VER) @@ -140,9 +136,6 @@ install: require-jq require-go require-git verify-go-versions ## Install the pro $(GOLANGCI_LINT): GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_VER) -$(STATICCHECK): - GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) honnef.co/go/tools/cmd/staticcheck $(STATICCHECK_BIN) $(STATICCHECK_VER) - $(LOGCHECK): GOBIN=$(TOOLS_GOBIN_DIR) $(GO_INSTALL) sigs.k8s.io/logtools/logcheck $(LOGCHECK_BIN) $(LOGCHECK_VER) @@ -152,9 +145,8 @@ $(CODE_GENERATOR): $(KCP_APIGEN_GEN): pushd . && cd sdk && GOBIN=$(TOOLS_GOBIN_DIR) go install ./cmd/apigen && popd -lint: $(GOLANGCI_LINT) $(STATICCHECK) $(LOGCHECK) ## Verify lint +lint: $(GOLANGCI_LINT) $(LOGCHECK) ## Verify lint $(GOLANGCI_LINT) run --timeout 20m ./... - $(STATICCHECK) -checks ST1019,ST1005 ./... ./hack/verify-contextual-logging.sh .PHONY: lint diff --git a/cmd/virtual-workspaces/options/options.go b/cmd/virtual-workspaces/options/options.go index 418fc94b8d8..ddb401a2c24 100644 --- a/cmd/virtual-workspaces/options/options.go +++ b/cmd/virtual-workspaces/options/options.go @@ -118,6 +118,7 @@ func (o *Options) Validate() error { errs = append(errs, fmt.Errorf("--kubeconfig is required for this command")) } if !strings.HasPrefix(o.RootPathPrefix, "/") { + //nolint:revive errs = append(errs, fmt.Errorf("RootPathPrefix %q must start with /", o.RootPathPrefix)) } diff --git a/pkg/admission/kubequota/kubequota_clusterworkspace_monitor.go b/pkg/admission/kubequota/kubequota_clusterworkspace_monitor.go index aa84bc2cfd2..0166c60e83a 100644 --- a/pkg/admission/kubequota/kubequota_clusterworkspace_monitor.go +++ b/pkg/admission/kubequota/kubequota_clusterworkspace_monitor.go @@ -106,6 +106,7 @@ func (m *LogicalClusterDeletionMonitor) processNextWorkItem() bool { defer m.queue.Done(key) if err := m.process(key); err != nil { + //nolint:revive runtime.HandleError(fmt.Errorf("LogicalClusterDeletionMonitor failed to sync %q, err: %w", key, err)) m.queue.AddRateLimited(key) diff --git a/pkg/admission/logicalcluster/admission.go b/pkg/admission/logicalcluster/admission.go index 27c328bb97e..2b0cacdc6ed 100644 --- a/pkg/admission/logicalcluster/admission.go +++ b/pkg/admission/logicalcluster/admission.go @@ -18,6 +18,7 @@ package logicalcluster import ( "context" + "errors" "fmt" "io" @@ -157,25 +158,25 @@ func (o *plugin) Validate(ctx context.Context, a admission.Attributes, _ admissi newStatus := toSet(logicalCluster.Status.Initializers) if !oldSpec.Equal(newSpec) { - return admission.NewForbidden(a, fmt.Errorf("spec.initializers is immutable")) + return admission.NewForbidden(a, errors.New("spec.initializers is immutable")) } transitioningToInitializing := old.Status.Phase != corev1alpha1.LogicalClusterPhaseInitializing && logicalCluster.Status.Phase == corev1alpha1.LogicalClusterPhaseInitializing if transitioningToInitializing && !newSpec.Equal(newStatus) { - return admission.NewForbidden(a, fmt.Errorf("status.initializers do not equal spec.initializers")) + return admission.NewForbidden(a, errors.New("status.initializers do not equal spec.initializers")) } if !transitioningToInitializing && logicalCluster.Status.Phase == corev1alpha1.LogicalClusterPhaseInitializing && !oldStatus.IsSuperset(newStatus) { - return admission.NewForbidden(a, fmt.Errorf("status.initializers must not grow")) + return admission.NewForbidden(a, errors.New("status.initializers must not grow")) } if logicalCluster.Status.Phase != corev1alpha1.LogicalClusterPhaseInitializing && !oldStatus.Equal(newStatus) { - return admission.NewForbidden(a, fmt.Errorf("status.initializers is immutable after initialization")) + return admission.NewForbidden(a, errors.New("status.initializers is immutable after initialization")) } if old.Status.Phase == corev1alpha1.LogicalClusterPhaseInitializing && logicalCluster.Status.Phase != corev1alpha1.LogicalClusterPhaseInitializing { if len(logicalCluster.Status.Initializers) > 0 { - return admission.NewForbidden(a, fmt.Errorf("status.initializers is not empty")) + return admission.NewForbidden(a, errors.New("status.initializers is not empty")) } } @@ -188,14 +189,15 @@ func (o *plugin) Validate(ctx context.Context, a admission.Attributes, _ admissi case admission.Delete: logicalCluster, err := o.logicalClusterLister.Cluster(clusterName).Get(corev1alpha1.LogicalClusterName) if err != nil { + //nolint:revive return fmt.Errorf("LogicalCluster cannot be deleted: %w", err) } if !logicalCluster.Spec.DirectlyDeletable { - return admission.NewForbidden(a, fmt.Errorf("LogicalCluster cannot be deleted")) + return admission.NewForbidden(a, errors.New("LogicalCluster cannot be deleted")) //nolint:revive } case admission.Create: - return admission.NewForbidden(a, fmt.Errorf("LogicalCluster cannot be created")) + return admission.NewForbidden(a, errors.New("LogicalCluster cannot be created")) //nolint:revive } return nil @@ -203,7 +205,7 @@ func (o *plugin) Validate(ctx context.Context, a admission.Attributes, _ admissi func (o *plugin) ValidateInitialization() error { if o.logicalClusterLister == nil { - return fmt.Errorf(PluginName + " plugin needs an LogicalCluster lister") + return errors.New(PluginName + " plugin needs an LogicalCluster lister") } return nil } diff --git a/pkg/cache/server/config.go b/pkg/cache/server/config.go index cf5445c3351..691e0d7d833 100644 --- a/pkg/cache/server/config.go +++ b/pkg/cache/server/config.go @@ -17,6 +17,7 @@ limitations under the License. package server import ( + "errors" "fmt" "net/http" "strings" @@ -165,16 +166,18 @@ func NewConfig(opts *cacheserveroptions.CompletedOptions, optionalLocalShardRest rt, func(rq *http.Request) (string, string, error) { if serverConfig.Config.RequestInfoResolver == nil { - return "", "", fmt.Errorf("RequestInfoResolver wasn't provided") + return "", "", errors.New("no RequestInfoResolver provided") } // the k8s request info resolver expects a cluster-less path, but the client we're using knows how to // add the cluster we are targeting to the path before this round-tripper fires, so we need to strip it // to use the k8s library parts := strings.Split(rq.URL.Path, "/") if len(parts) < 4 { + //nolint:revive return "", "", fmt.Errorf("RequestInfoResolver: got invalid path: %v", rq.URL.Path) } if parts[1] != "clusters" { + //nolint:revive return "", "", fmt.Errorf("RequestInfoResolver: got path without cluster prefix: %v", rq.URL.Path) } // we clone the request here to safely mutate the URL path, but this cloned request is never realized diff --git a/pkg/reconciler/apis/apibinding/apibinding_reconcile.go b/pkg/reconciler/apis/apibinding/apibinding_reconcile.go index a86f22b22e0..71ee4ce6eba 100644 --- a/pkg/reconciler/apis/apibinding/apibinding_reconcile.go +++ b/pkg/reconciler/apis/apibinding/apibinding_reconcile.go @@ -357,7 +357,8 @@ func (r *bindingReconciler) reconcile(ctx context.Context, apiBinding *apisv1alp apisv1alpha1.BindingUpToDate, apisv1alpha1.APIResourceSchemaInvalidReason, conditionsv1alpha1.ConditionSeverityError, - fmt.Sprintf("APIResourceSchema %s|%s is invalid: %v\"", schemaClusterName, schemaName, status.Status().Details.Causes), + "APIResourceSchema %s|%s is invalid: %v", + schemaClusterName, schemaName, status.Status().Details.Causes, ) // Only change InitialBindingCompleted if it's false if conditions.IsFalse(apiBinding, apisv1alpha1.InitialBindingCompleted) { @@ -366,7 +367,8 @@ func (r *bindingReconciler) reconcile(ctx context.Context, apiBinding *apisv1alp apisv1alpha1.InitialBindingCompleted, apisv1alpha1.APIResourceSchemaInvalidReason, conditionsv1alpha1.ConditionSeverityError, - fmt.Sprintf("APIResourceSchema %s|%s is invalid: %v\"", schemaClusterName, schemaName, status.Status().Details.Causes), + "APIResourceSchema %s|%s is invalid: %v", + schemaClusterName, schemaName, status.Status().Details.Causes, ) } @@ -453,7 +455,8 @@ func (r *bindingReconciler) reconcile(ctx context.Context, apiBinding *apisv1alp apisv1alpha1.BindingUpToDate, apisv1alpha1.WaitingForEstablishedReason, conditionsv1alpha1.ConditionSeverityInfo, - "Waiting for API(s) to be established: %s", strings.Join(needToWaitForRequeueWhenEstablished, ", "), + "Waiting for API(s) to be established: %s", + strings.Join(needToWaitForRequeueWhenEstablished, ", "), ) // Only change InitialBindingCompleted if it's false @@ -463,7 +466,8 @@ func (r *bindingReconciler) reconcile(ctx context.Context, apiBinding *apisv1alp apisv1alpha1.InitialBindingCompleted, apisv1alpha1.WaitingForEstablishedReason, conditionsv1alpha1.ConditionSeverityInfo, - "Waiting for API(s) to be established: %s", strings.Join(needToWaitForRequeueWhenEstablished, ", "), + "Waiting for API(s) to be established: %s", + strings.Join(needToWaitForRequeueWhenEstablished, ", "), ) } } else { @@ -512,7 +516,6 @@ func generateCRD(schema *apisv1alpha1.APIResourceSchema) (*apiextensionsv1.Custo } for _, version := range schema.Spec.Versions { - version := version crdVersion := apiextensionsv1.CustomResourceDefinitionVersion{ Name: version.Name, Served: version.Served, diff --git a/pkg/reconciler/apis/apibindingdeletion/apibinding_deletion_controller.go b/pkg/reconciler/apis/apibindingdeletion/apibinding_deletion_controller.go index 23db24ef7ab..6d8e5ec41ec 100644 --- a/pkg/reconciler/apis/apibindingdeletion/apibinding_deletion_controller.go +++ b/pkg/reconciler/apis/apibindingdeletion/apibinding_deletion_controller.go @@ -239,7 +239,8 @@ func (c *Controller) process(ctx context.Context, key string) error { apisv1alpha1.BindingResourceDeleteSuccess, ResourceDeletionFailedReason, conditionsv1alpha1.ConditionSeverityError, - deleteErr.Error(), + "%v", + deleteErr, ) newResource := &Resource{ObjectMeta: apibindingCopy.ObjectMeta, Spec: &apibindingCopy.Spec, Status: &apibindingCopy.Status} @@ -294,7 +295,8 @@ func (c *Controller) mutateResourceRemainingStatus(resourceRemaining gvrDeletion apisv1alpha1.BindingResourceDeleteSuccess, ResourceFinalizersRemainReason, conditionsv1alpha1.ConditionSeverityError, - fmt.Sprintf("Some content in the workspace has finalizers remaining: %s", strings.Join(remainingByFinalizer, ", ")), + "Some content in the workspace has finalizers remaining: %s", + strings.Join(remainingByFinalizer, ", "), ) return apibinding, &deletion.ResourcesRemainingError{ @@ -320,7 +322,8 @@ func (c *Controller) mutateResourceRemainingStatus(resourceRemaining gvrDeletion apisv1alpha1.BindingResourceDeleteSuccess, ResourceRemainingReason, conditionsv1alpha1.ConditionSeverityError, - fmt.Sprintf("Some resources are remaining: %s", strings.Join(remainingResources, ", ")), + "Some resources are remaining: %s", + strings.Join(remainingResources, ", "), ) return apibinding, &deletion.ResourcesRemainingError{ diff --git a/pkg/reconciler/apis/apiexport/apiexport_controller_test.go b/pkg/reconciler/apis/apiexport/apiexport_controller_test.go index 195b5b3ac30..2a4c86c05c1 100644 --- a/pkg/reconciler/apis/apiexport/apiexport_controller_test.go +++ b/pkg/reconciler/apis/apiexport/apiexport_controller_test.go @@ -138,8 +138,6 @@ func TestReconcile(t *testing.T) { } for name, tc := range tests { - tc := tc // to avoid t.Parallel() races - t.Run(name, func(t *testing.T) { createSecretCalled := false diff --git a/pkg/reconciler/apis/apiexport/apiexport_reconcile.go b/pkg/reconciler/apis/apiexport/apiexport_reconcile.go index 5ed610a5d0b..63c4c6cf658 100644 --- a/pkg/reconciler/apis/apiexport/apiexport_reconcile.go +++ b/pkg/reconciler/apis/apiexport/apiexport_reconcile.go @@ -91,7 +91,8 @@ func (c *controller) reconcile(ctx context.Context, apiExport *apisv1alpha1.APIE apisv1alpha1.APIExportIdentityValid, apisv1alpha1.IdentityVerificationFailedReason, conditionsv1alpha1.ConditionSeverityError, - err.Error(), + "%v", + err, ) } @@ -115,7 +116,8 @@ func (c *controller) reconcile(ctx context.Context, apiExport *apisv1alpha1.APIE apisv1alpha1.APIExportVirtualWorkspaceURLsReady, apisv1alpha1.ErrorGeneratingURLsReason, conditionsv1alpha1.ConditionSeverityError, - err.Error(), + "%v", + err, ) } diff --git a/pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_controller_test.go b/pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_controller_test.go index 0b17ce4c87e..002e9c5e69e 100644 --- a/pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_controller_test.go +++ b/pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_controller_test.go @@ -87,8 +87,6 @@ func TestReconcile(t *testing.T) { } for name, tc := range tests { - tc := tc // to avoid t.Parallel() races - t.Run(name, func(t *testing.T) { c := &controller{ listShards: func(selector labels.Selector) ([]*corev1alpha1.Shard, error) { diff --git a/pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_reconcile.go b/pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_reconcile.go index 1003f7a06a5..5aaf4a73e38 100644 --- a/pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_reconcile.go +++ b/pkg/reconciler/apis/apiexportendpointslice/apiexportendpointslice_reconcile.go @@ -125,7 +125,8 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, apiExportEndpointSl apisv1alpha1.PartitionValid, apisv1alpha1.PartitionInvalidReferenceReason, conditionsv1alpha1.ConditionSeverityError, - err.Error(), + "%v", + err, ) conditions.MarkFalse( apiExportEndpointSlice, @@ -142,7 +143,8 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, apiExportEndpointSl apisv1alpha1.PartitionValid, apisv1alpha1.InternalErrorReason, conditionsv1alpha1.ConditionSeverityError, - err.Error(), + "%v", + err, ) conditions.MarkUnknown( apiExportEndpointSlice, @@ -160,7 +162,8 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, apiExportEndpointSl apisv1alpha1.PartitionValid, apisv1alpha1.PartitionInvalidReferenceReason, conditionsv1alpha1.ConditionSeverityError, - err.Error(), + "%v", + err, ) conditions.MarkFalse( apiExportEndpointSlice, @@ -196,7 +199,8 @@ func (r *endpointsReconciler) reconcile(ctx context.Context, apiExportEndpointSl apisv1alpha1.APIExportEndpointSliceURLsReady, apisv1alpha1.ErrorGeneratingURLsReason, conditionsv1alpha1.ConditionSeverityError, - err.Error(), + "%v", + err, ) return err } diff --git a/pkg/reconciler/cache/replication/replication_controller.go b/pkg/reconciler/cache/replication/replication_controller.go index 9f50a67f836..6461de07e14 100644 --- a/pkg/reconciler/cache/replication/replication_controller.go +++ b/pkg/reconciler/cache/replication/replication_controller.go @@ -75,8 +75,6 @@ func NewController( } for gvr, info := range c.Gvrs { - // shadow gvr to get the right value in the closure - gvr := gvr _, _ = info.Local.AddEventHandler(cache.FilteringResourceEventHandler{ FilterFunc: IsNoSystemClusterName, Handler: cache.ResourceEventHandlerFuncs{ diff --git a/pkg/reconciler/core/logicalclusterdeletion/deletion/logicalcluster_resource_deletor.go b/pkg/reconciler/core/logicalclusterdeletion/deletion/logicalcluster_resource_deletor.go index edc7467bc8d..774322bab24 100644 --- a/pkg/reconciler/core/logicalclusterdeletion/deletion/logicalcluster_resource_deletor.go +++ b/pkg/reconciler/core/logicalclusterdeletion/deletion/logicalcluster_resource_deletor.go @@ -450,6 +450,7 @@ func (d *logicalClusterResourcesDeleter) deleteAllContent(ctx context.Context, w tenancyv1alpha1.WorkspaceContentDeleted, "SomeResourcesRemain", conditionsv1alpha1.ConditionSeverityInfo, + "%s", message, ) logger.V(4).Error(utilerrors.NewAggregate(errs), "resource remaining") @@ -462,6 +463,7 @@ func (d *logicalClusterResourcesDeleter) deleteAllContent(ctx context.Context, w tenancyv1alpha1.WorkspaceContentDeleted, deletionContentSuccessReason, conditionsv1alpha1.ConditionSeverityError, + "%v", utilerrors.NewAggregate(errs).Error(), ) logger.Error(utilerrors.NewAggregate(errs), "content deletion failed", "message", deletionContentSuccessReason) diff --git a/pkg/reconciler/tenancy/initialization/apibinder_initializer_reconcile.go b/pkg/reconciler/tenancy/initialization/apibinder_initializer_reconcile.go index 7d8119c9407..b24a6d131d4 100644 --- a/pkg/reconciler/tenancy/initialization/apibinder_initializer_reconcile.go +++ b/pkg/reconciler/tenancy/initialization/apibinder_initializer_reconcile.go @@ -70,8 +70,7 @@ func (b *APIBinder) reconcile(ctx context.Context, logicalCluster *corev1alpha1. tenancyv1alpha1.WorkspaceInitializedWorkspaceTypeInvalid, conditionsv1alpha1.ConditionSeverityError, "error getting WorkspaceType %s|%s: %v", - wtCluster.String(), wtName, - err, + wtCluster.String(), wtName, err, ) return nil @@ -238,7 +237,8 @@ func (b *APIBinder) reconcile(ctx context.Context, logicalCluster *corev1alpha1. tenancyv1alpha1.WorkspaceAPIBindingsInitialized, tenancyv1alpha1.WorkspaceInitializedWaitingOnAPIBindings, conditionsv1alpha1.ConditionSeverityInfo, - "APIBinding(s) not yet fully bound: %s", strings.Join(incomplete, ", "), + "APIBinding(s) not yet fully bound: %s", + strings.Join(incomplete, ", "), ) return nil diff --git a/pkg/reconciler/tenancy/workspace/workspace_reconcile_scheduling.go b/pkg/reconciler/tenancy/workspace/workspace_reconcile_scheduling.go index 03a1fbc567f..109ec3f5d7d 100644 --- a/pkg/reconciler/tenancy/workspace/workspace_reconcile_scheduling.go +++ b/pkg/reconciler/tenancy/workspace/workspace_reconcile_scheduling.go @@ -108,7 +108,7 @@ func (r *schedulingReconciler) reconcile(ctx context.Context, workspace *tenancy return reconcileStatusStopAndRequeue, err } if shard == nil { - conditions.MarkFalse(workspace, tenancyv1alpha1.WorkspaceScheduled, tenancyv1alpha1.WorkspaceReasonUnschedulable, conditionsv1alpha1.ConditionSeverityError, reason) + conditions.MarkFalse(workspace, tenancyv1alpha1.WorkspaceScheduled, tenancyv1alpha1.WorkspaceReasonUnschedulable, conditionsv1alpha1.ConditionSeverityError, "%s", reason) return reconcileStatusContinue, nil // retry is automatic when new shards show up } logger.V(2).Info("Chose shard", "shard", shard.Name) diff --git a/pkg/reconciler/tenancy/workspace/workspace_reconcile_scheduling_test.go b/pkg/reconciler/tenancy/workspace/workspace_reconcile_scheduling_test.go index 10f8ed6a8b5..357484be3a8 100644 --- a/pkg/reconciler/tenancy/workspace/workspace_reconcile_scheduling_test.go +++ b/pkg/reconciler/tenancy/workspace/workspace_reconcile_scheduling_test.go @@ -76,7 +76,7 @@ func TestReconcileScheduling(t *testing.T) { initialWS.Annotations["internal.tenancy.kcp.io/shard"] = "1pfxsevk" initialWS.Finalizers = append(initialWS.Finalizers, "core.kcp.io/logicalcluster") if !equality.Semantic.DeepEqual(ws, initialWS) { - t.Fatal(fmt.Errorf("unexpected Workspace:\n%s", cmp.Diff(ws, initialWS))) + t.Fatalf("unexpected Workspace:\n%s", cmp.Diff(ws, initialWS)) } }, expectedStatus: reconcileStatusStopAndRequeue, @@ -99,7 +99,7 @@ func TestReconcileScheduling(t *testing.T) { Status: corev1.ConditionTrue, }) if !equality.Semantic.DeepEqual(wsAfterReconciliation, initialWS) { - t.Fatal(fmt.Errorf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS))) + t.Fatalf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS)) } }, validateKcpClientActions: func(t *testing.T, actions []kcpclientgotesting.Action) { @@ -133,7 +133,7 @@ func TestReconcileScheduling(t *testing.T) { Status: corev1.ConditionTrue, }) if !equality.Semantic.DeepEqual(wsAfterReconciliation, initialWS) { - t.Fatal(fmt.Errorf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS))) + t.Fatalf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS)) } }, validateKcpClientActions: func(t *testing.T, actions []kcpclientgotesting.Action) { @@ -162,7 +162,7 @@ func TestReconcileScheduling(t *testing.T) { initialWS.CreationTimestamp = wsAfterReconciliation.CreationTimestamp delete(initialWS.Annotations, "internal.tenancy.kcp.io/cluster") if !equality.Semantic.DeepEqual(wsAfterReconciliation, initialWS) { - t.Fatal(fmt.Errorf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS))) + t.Fatalf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS)) } }, expectedStatus: reconcileStatusStopAndRequeue, @@ -196,7 +196,7 @@ func TestReconcileScheduling(t *testing.T) { Status: corev1.ConditionTrue, }) if !equality.Semantic.DeepEqual(wsAfterReconciliation, initialWS) { - t.Fatal(fmt.Errorf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS))) + t.Fatalf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS)) } }, validateKcpClientActions: func(t *testing.T, actions []kcpclientgotesting.Action) { @@ -222,7 +222,7 @@ func TestReconcileScheduling(t *testing.T) { Message: "No available shards to schedule the workspace", }) if !equality.Semantic.DeepEqual(wsAfterReconciliation, initialWS) { - t.Fatal(fmt.Errorf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS))) + t.Fatalf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS)) } }, expectedStatus: reconcileStatusContinue, @@ -248,7 +248,7 @@ func TestReconcileScheduling(t *testing.T) { initialWS.Annotations["internal.tenancy.kcp.io/shard"] = "29hdqnv7" initialWS.Finalizers = append(initialWS.Finalizers, "core.kcp.io/logicalcluster") if !equality.Semantic.DeepEqual(wsAfterReconciliation, initialWS) { - t.Fatal(fmt.Errorf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS))) + t.Fatalf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS)) } }, expectedStatus: reconcileStatusStopAndRequeue, @@ -274,7 +274,7 @@ func TestReconcileScheduling(t *testing.T) { Message: "No available shards to schedule the workspace", }) if !equality.Semantic.DeepEqual(wsAfterReconciliation, initialWS) { - t.Fatal(fmt.Errorf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS))) + t.Fatalf("unexpected Workspace:\n%s", cmp.Diff(wsAfterReconciliation, initialWS)) } }, expectedStatus: reconcileStatusContinue, @@ -461,7 +461,7 @@ func validateWellKnownLogicalClusterActions(t *testing.T, actions []kcpclientgot actualObj := createAction.GetObject().(*corev1alpha1.LogicalCluster) if !equality.Semantic.DeepEqual(actualObj, expectedObj) { - t.Errorf(cmp.Diff(actualObj, expectedObj)) + t.Error(cmp.Diff(actualObj, expectedObj)) } wasLogicalClusterCreated = true } @@ -479,7 +479,7 @@ func validateWellKnownLogicalClusterActions(t *testing.T, actions []kcpclientgot delete(actualObj.Annotations, "kcp.io/cluster") if !equality.Semantic.DeepEqual(actualObj, expectedObjCopy) { - t.Errorf(cmp.Diff(actualObj, expectedObjCopy)) + t.Error(cmp.Diff(actualObj, expectedObjCopy)) } wasLogicalClusterUpdated = true } diff --git a/pkg/reconciler/tenancy/workspacemounts/workspacemounts_reconcile_updater.go b/pkg/reconciler/tenancy/workspacemounts/workspacemounts_reconcile_updater.go index a854beae2e4..d402101b1db 100644 --- a/pkg/reconciler/tenancy/workspacemounts/workspacemounts_reconcile_updater.go +++ b/pkg/reconciler/tenancy/workspacemounts/workspacemounts_reconcile_updater.go @@ -18,7 +18,6 @@ package workspacemounts import ( "context" - "fmt" "github.com/kcp-dev/logicalcluster/v3" @@ -108,8 +107,14 @@ func (r *workspaceStatusUpdater) reconcile(ctx context.Context, workspace *tenan } return reconcileStatusContinue, nil default: - msg := fmt.Sprintf("Mount is not reporting ready. See %s %q status for more details", obj.GroupVersionKind().Kind, obj.GetName()) - conditions.MarkFalse(workspace, tenancyv1alpha1.MountConditionReady, "Mount is not reporting ready.", conditionsv1alpha1.ConditionSeverityError, msg) + conditions.MarkFalse( + workspace, + tenancyv1alpha1.MountConditionReady, + "Mount is not reporting ready.", + conditionsv1alpha1.ConditionSeverityError, + "Mount is not reporting ready. See %s %q status for more details", + obj.GroupVersionKind().Kind, obj.GetName(), + ) } } diff --git a/pkg/reconciler/tenancy/workspacetype/workspacetype_controller_reconcile.go b/pkg/reconciler/tenancy/workspacetype/workspacetype_controller_reconcile.go index ba33744e5c7..1f211fcbe6b 100644 --- a/pkg/reconciler/tenancy/workspacetype/workspacetype_controller_reconcile.go +++ b/pkg/reconciler/tenancy/workspacetype/workspacetype_controller_reconcile.go @@ -40,7 +40,8 @@ func (c *controller) reconcile(ctx context.Context, wt *tenancyv1alpha1.Workspac tenancyv1alpha1.WorkspaceTypeVirtualWorkspaceURLsReady, tenancyv1alpha1.ErrorGeneratingURLsReason, conditionsv1alpha1.ConditionSeverityError, - err.Error(), + "%v", + err, ) } else { conditions.MarkTrue( diff --git a/pkg/reconciler/topology/partitionset/partitionset_controller_test.go b/pkg/reconciler/topology/partitionset/partitionset_controller_test.go index 67cac0eebf4..264db80e0b9 100644 --- a/pkg/reconciler/topology/partitionset/partitionset_controller_test.go +++ b/pkg/reconciler/topology/partitionset/partitionset_controller_test.go @@ -47,7 +47,7 @@ func TestReconcile(t *testing.T) { wantError bool wantPartitionsReady bool wantPartitionsNotReady bool - wantPartitionCount int + wantPartitionCount uint wantCountCreated int wantCountDeleted int }{ @@ -94,8 +94,6 @@ func TestReconcile(t *testing.T) { } for name, tc := range tests { - tc := tc // to avoid t.Parallel() races - t.Run(name, func(t *testing.T) { nbPartitionsCreated := 0 nbPartitionsDeleted := 0 @@ -314,7 +312,7 @@ func TestReconcile(t *testing.T) { require.Error(t, err, "expected an error") } else { require.NoError(t, err, "expected no error") - require.Equal(t, uint(tc.wantPartitionCount), partitionSet.Status.Count) + require.Equal(t, tc.wantPartitionCount, partitionSet.Status.Count) } if tc.wantPartitionsNotReady { diff --git a/pkg/reconciler/topology/partitionset/partitionset_reconcile.go b/pkg/reconciler/topology/partitionset/partitionset_reconcile.go index 0d39e0fa3fb..d7ad2be8306 100644 --- a/pkg/reconciler/topology/partitionset/partitionset_reconcile.go +++ b/pkg/reconciler/topology/partitionset/partitionset_reconcile.go @@ -50,7 +50,8 @@ func (c *controller) reconcile(ctx context.Context, partitionSet *topologyv1alph topologyv1alpha1.PartitionSetValid, topologyv1alpha1.PartitionSetInvalidSelectorReason, conditionsv1alpha1.ConditionSeverityError, - err.Error(), + "%v", + err, ) conditions.MarkFalse( partitionSet, @@ -84,7 +85,8 @@ func (c *controller) reconcile(ctx context.Context, partitionSet *topologyv1alph topologyv1alpha1.PartitionsReady, topologyv1alpha1.ErrorGeneratingPartitionsReason, conditionsv1alpha1.ConditionSeverityError, - err.Error(), + "%v", + err, ) return err } diff --git a/pkg/virtual/framework/dynamic/apiserver/handler_test.go b/pkg/virtual/framework/dynamic/apiserver/handler_test.go index 4f57128bfda..58ebad04a39 100644 --- a/pkg/virtual/framework/dynamic/apiserver/handler_test.go +++ b/pkg/virtual/framework/dynamic/apiserver/handler_test.go @@ -188,7 +188,7 @@ func TestRouting(t *testing.T) { } // note that in production we delegate to the special handler that is attached at the end of the delegation chain that checks if the server has installed all known HTTP paths before replying to the client. - // it returns 503 if not all registered signals have been ready (closed) otherwise it simply replies with 404. + // it returns http.StatusServiceUnavailable if not all registered signals have been ready (closed) otherwise it simply replies with 404. // the apiextentionserver is considered to be initialized once hasCRDInformerSyncedSignal is closed. // // here, in this test the delegate represent the special handler and hasSync represents the signal. @@ -253,11 +253,11 @@ func TestRouting(t *testing.T) { HasSynced: false, IsResourceRequest: false, ExpectDelegateCalled: false, - ExpectStatus: 200, + ExpectStatus: http.StatusOK, ExpectResponse: func(t *testing.T, r *http.Response, b []byte) { t.Helper() - if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != 200 { + if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != http.StatusOK { // why? return } @@ -289,11 +289,11 @@ func TestRouting(t *testing.T) { HasSynced: true, IsResourceRequest: false, ExpectDelegateCalled: false, - ExpectStatus: 200, + ExpectStatus: http.StatusOK, ExpectResponse: func(t *testing.T, r *http.Response, b []byte) { t.Helper() - if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != 200 { + if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != http.StatusOK { // why? return } @@ -326,7 +326,7 @@ func TestRouting(t *testing.T) { HasSynced: false, IsResourceRequest: false, ExpectDelegateCalled: true, - ExpectStatus: 503, + ExpectStatus: http.StatusServiceUnavailable, }, { Name: "nonexisting group discovery", @@ -337,7 +337,7 @@ func TestRouting(t *testing.T) { HasSynced: true, IsResourceRequest: false, ExpectDelegateCalled: true, - ExpectStatus: 418, + ExpectStatus: http.StatusTeapot, }, { @@ -349,11 +349,11 @@ func TestRouting(t *testing.T) { HasSynced: false, IsResourceRequest: false, ExpectDelegateCalled: false, - ExpectStatus: 200, + ExpectStatus: http.StatusOK, ExpectResponse: func(t *testing.T, r *http.Response, b []byte) { t.Helper() - if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != 200 { + if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != http.StatusOK { // why? return } @@ -387,11 +387,11 @@ func TestRouting(t *testing.T) { HasSynced: true, IsResourceRequest: false, ExpectDelegateCalled: false, - ExpectStatus: 200, + ExpectStatus: http.StatusOK, ExpectResponse: func(t *testing.T, r *http.Response, b []byte) { t.Helper() - if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != 200 { + if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != http.StatusOK { // why? return } @@ -426,7 +426,7 @@ func TestRouting(t *testing.T) { HasSynced: false, IsResourceRequest: false, ExpectDelegateCalled: true, - ExpectStatus: 503, + ExpectStatus: http.StatusServiceUnavailable, }, { Name: "nonexisting group version discovery", @@ -437,7 +437,7 @@ func TestRouting(t *testing.T) { HasSynced: true, IsResourceRequest: false, ExpectDelegateCalled: true, - ExpectStatus: 418, + ExpectStatus: http.StatusTeapot, }, { @@ -449,7 +449,7 @@ func TestRouting(t *testing.T) { HasSynced: false, IsResourceRequest: false, ExpectDelegateCalled: true, - ExpectStatus: 503, + ExpectStatus: http.StatusServiceUnavailable, }, { Name: "existing group, nonexisting version discovery", @@ -460,7 +460,7 @@ func TestRouting(t *testing.T) { HasSynced: true, IsResourceRequest: false, ExpectDelegateCalled: true, - ExpectStatus: 418, + ExpectStatus: http.StatusTeapot, }, { @@ -474,7 +474,7 @@ func TestRouting(t *testing.T) { HasSynced: false, IsResourceRequest: true, ExpectDelegateCalled: true, - ExpectStatus: 503, + ExpectStatus: http.StatusServiceUnavailable, }, { Name: "nonexisting group, resource request", @@ -487,7 +487,7 @@ func TestRouting(t *testing.T) { HasSynced: true, IsResourceRequest: true, ExpectDelegateCalled: true, - ExpectStatus: 418, + ExpectStatus: http.StatusTeapot, }, { @@ -499,11 +499,11 @@ func TestRouting(t *testing.T) { HasSynced: false, IsResourceRequest: false, ExpectDelegateCalled: false, - ExpectStatus: 200, + ExpectStatus: http.StatusOK, ExpectResponse: func(t *testing.T, r *http.Response, b []byte) { t.Helper() - if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != 200 { + if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != http.StatusOK { // why? return } @@ -533,11 +533,11 @@ func TestRouting(t *testing.T) { HasSynced: true, IsResourceRequest: false, ExpectDelegateCalled: false, - ExpectStatus: 200, + ExpectStatus: http.StatusOK, ExpectResponse: func(t *testing.T, r *http.Response, b []byte) { t.Helper() - if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != 200 { + if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != http.StatusOK { // why? return } @@ -567,11 +567,11 @@ func TestRouting(t *testing.T) { HasSynced: false, IsResourceRequest: false, ExpectDelegateCalled: false, - ExpectStatus: 200, + ExpectStatus: http.StatusOK, ExpectResponse: func(t *testing.T, r *http.Response, b []byte) { t.Helper() - if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != 200 { + if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != http.StatusOK { // why? return } @@ -610,11 +610,11 @@ func TestRouting(t *testing.T) { HasSynced: true, IsResourceRequest: false, ExpectDelegateCalled: false, - ExpectStatus: 200, + ExpectStatus: http.StatusOK, ExpectResponse: func(t *testing.T, r *http.Response, b []byte) { t.Helper() - if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != 200 { + if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != http.StatusOK { // why? return } @@ -653,7 +653,7 @@ func TestRouting(t *testing.T) { HasSynced: false, IsResourceRequest: false, ExpectDelegateCalled: true, - ExpectStatus: 503, + ExpectStatus: http.StatusServiceUnavailable, }, { Name: "existing core group, nonexisting version discovery", @@ -664,7 +664,7 @@ func TestRouting(t *testing.T) { HasSynced: true, IsResourceRequest: false, ExpectDelegateCalled: true, - ExpectStatus: 418, + ExpectStatus: http.StatusTeapot, }, { @@ -678,7 +678,7 @@ func TestRouting(t *testing.T) { HasSynced: false, IsResourceRequest: true, ExpectDelegateCalled: true, - ExpectStatus: 503, + ExpectStatus: http.StatusServiceUnavailable, }, { Name: "nonexisting core group, resource request", @@ -691,7 +691,7 @@ func TestRouting(t *testing.T) { HasSynced: true, IsResourceRequest: true, ExpectDelegateCalled: true, - ExpectStatus: 418, + ExpectStatus: http.StatusTeapot, }, { Name: "existing group, resource request", @@ -704,11 +704,11 @@ func TestRouting(t *testing.T) { HasSynced: true, IsResourceRequest: true, ExpectDelegateCalled: false, - ExpectStatus: 405, + ExpectStatus: http.StatusMethodNotAllowed, ExpectResponse: func(t *testing.T, r *http.Response, b []byte) { t.Helper() - if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != 200 { + if r.Header.Get("Content-Type") != "application/json" || r.StatusCode != http.StatusOK { // why? return } @@ -757,8 +757,8 @@ func TestRouting(t *testing.T) { case "unknown": req.Header.Set("Accept", "application/vnd.kubernetes.unknown") // rather than success, we'll get a not supported error - if expectStatus == 200 { - expectStatus = 406 + if expectStatus == http.StatusOK { + expectStatus = http.StatusNotAcceptable } default: t.Fatalf("unknown content type %v", contentType) diff --git a/pkg/virtual/framework/dynamic/apiserver/serving_info.go b/pkg/virtual/framework/dynamic/apiserver/serving_info.go index 1a5f2affbda..2e29eb954b7 100644 --- a/pkg/virtual/framework/dynamic/apiserver/serving_info.go +++ b/pkg/virtual/framework/dynamic/apiserver/serving_info.go @@ -124,7 +124,6 @@ func CreateServingInfoFor(genericConfig genericapiserver.CompletedConfig, apiRes if openAPIModels != nil { schemas := make(map[string]*spec.Schema, len(s.Definitions)) for k, v := range s.Definitions { - v := v schemas[k] = &v } typeConverter, err = managedfields.NewTypeConverter(schemas, false) diff --git a/pkg/virtual/framework/transforming/client.go b/pkg/virtual/framework/transforming/client.go index 20929ed5d36..7eeb9faaee6 100644 --- a/pkg/virtual/framework/transforming/client.go +++ b/pkg/virtual/framework/transforming/client.go @@ -161,7 +161,6 @@ func (tc *transformingListerWatcherClient) List(ctx context.Context, opts metav1 transformedResult := result.DeepCopy() transformedResult.Items = []unstructured.Unstructured{} for _, item := range result.Items { - item := item itemAfterLogger := logging.WithObject(afterLogger, &item) itemAfterLogger.Info(startingMessage) if transformed, err := tc.transformer.AfterRead(tc.resourceClient(&item), ctx, tc.resource, &item, nil); err != nil { @@ -428,7 +427,6 @@ func (tc *transformingResourceClient) DeleteCollectionWithResult(ctx context.Con transformedResult := result.DeepCopy() transformedResult.Items = []unstructured.Unstructured{} for _, item := range result.Items { - item := item itemAfterLogger := logging.WithObject(afterLogger, &item) itemAfterLogger.Info(startingMessage) if transformed, err := tc.transformer.AfterRead(tc.resourceClient(&item), ctx, tc.resource, &item, nil); err != nil { diff --git a/sdk/apis/test/cel.go b/sdk/apis/test/cel.go index ceae073b981..f2e6511031f 100644 --- a/sdk/apis/test/cel.go +++ b/sdk/apis/test/cel.go @@ -111,7 +111,6 @@ func findCEL(t *testing.T, s *schema.Structural, root bool, pth *field.Path) (ma } for k, v := range s.Properties { - v := v sub, err := findCEL(t, &v, false, pth.Child("properties").Child(k)) if err != nil { return nil, err diff --git a/sdk/apis/test/pattern.go b/sdk/apis/test/pattern.go index c0be74c8985..5e836da2834 100644 --- a/sdk/apis/test/pattern.go +++ b/sdk/apis/test/pattern.go @@ -78,7 +78,6 @@ func findPattern(t *testing.T, s *schema.Structural, pth *field.Path) (map[strin } for k, v := range s.Properties { - v := v sub, err := findPattern(t, &v, pth.Child("properties").Child(k)) if err != nil { return nil, err diff --git a/sdk/apis/third_party/conditions/util/conditions/setter_test.go b/sdk/apis/third_party/conditions/util/conditions/setter_test.go index 9bebd4855c3..d75dbed6ebd 100644 --- a/sdk/apis/third_party/conditions/util/conditions/setter_test.go +++ b/sdk/apis/third_party/conditions/util/conditions/setter_test.go @@ -217,7 +217,7 @@ func TestMarkMethods(t *testing.T) { })) // test MarkUnknown - MarkUnknown(cluster, "conditionBaz", "reasonBaz", "messageBaz") + MarkUnknown(cluster, "conditionBaz", "reasonBaz", "%s", "messageBaz") g.Expect(Get(cluster, "conditionBaz")).To(HaveSameStateOf(&conditionsapi.Condition{ Type: "conditionBaz", Status: corev1.ConditionUnknown, diff --git a/test/e2e/authorizer/authorizer_test.go b/test/e2e/authorizer/authorizer_test.go index 33859033f03..2cc7c1423b5 100644 --- a/test/e2e/authorizer/authorizer_test.go +++ b/test/e2e/authorizer/authorizer_test.go @@ -369,8 +369,7 @@ func TestAuthorizer(t *testing.T) { }}, } - for i := range testCases { - testCase := testCases[i] + for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { t.Parallel() testCase.run(t) diff --git a/test/e2e/authorizer/serviceaccounts_test.go b/test/e2e/authorizer/serviceaccounts_test.go index bd8b8d691aa..0c204702af5 100644 --- a/test/e2e/authorizer/serviceaccounts_test.go +++ b/test/e2e/authorizer/serviceaccounts_test.go @@ -162,8 +162,6 @@ func TestServiceAccounts(t *testing.T) { }}, } for i, ttc := range testCases { - i := i - ttc := ttc t.Run(ttc.name, func(t *testing.T) { t.Parallel() diff --git a/test/e2e/authorizer/workspace_test.go b/test/e2e/authorizer/workspace_test.go index befe694cff7..6ffa22777ed 100644 --- a/test/e2e/authorizer/workspace_test.go +++ b/test/e2e/authorizer/workspace_test.go @@ -141,7 +141,6 @@ func TestWorkspaces(t *testing.T) { } for _, testCase := range testCases { - testCase := testCase t.Run(testCase.name, func(t *testing.T) { t.Parallel() diff --git a/test/e2e/cache/cache_server_test.go b/test/e2e/cache/cache_server_test.go index 4543ed5406f..d8d1548edc2 100644 --- a/test/e2e/cache/cache_server_test.go +++ b/test/e2e/cache/cache_server_test.go @@ -382,7 +382,6 @@ func TestCacheServerAllScenarios(t *testing.T) { cacheClientRT := cache2e.ClientRoundTrippersFor(cacheClientRestConfig) for _, scenario := range scenarios { - scenario := scenario t.Run(scenario.name, func(t *testing.T) { t.Parallel() scenario.work(ctx, t, cacheClientRT, logicalcluster.NewPath("acme"), schema.GroupVersionResource{Group: "apis.kcp.io", Version: "v1alpha1", Resource: "apiexports"}) diff --git a/test/e2e/conformance/cross_logical_cluster_list_test.go b/test/e2e/conformance/cross_logical_cluster_list_test.go index 6e237f6c277..1a31283a294 100644 --- a/test/e2e/conformance/cross_logical_cluster_list_test.go +++ b/test/e2e/conformance/cross_logical_cluster_list_test.go @@ -75,8 +75,6 @@ func TestCrossLogicalClusterList(t *testing.T) { } expectedWorkspaces := sets.New[string]() for i, clusterName := range logicalClusters { - clusterName := clusterName // shadow - t.Logf("Creating Workspace CRs in logical cluster %s", clusterName) sourceWorkspace := &tenancyv1alpha1.Workspace{ ObjectMeta: metav1.ObjectMeta{ @@ -93,7 +91,7 @@ func TestCrossLogicalClusterList(t *testing.T) { }) } - t.Logf("Listing Workspace CRs across logical clusters with identity") + t.Log("Listing Workspace CRs across logical clusters with identity") tenancyExport, err := kcpClusterClient.ApisV1alpha1().APIExports().Cluster(core.RootCluster.Path()).Get(ctx, "tenancy.kcp.io", metav1.GetOptions{}) require.NoError(t, err, "error getting tenancy API export") require.NotEmptyf(t, tenancyExport.Status.IdentityHash, "tenancy API export has no identity hash") diff --git a/test/e2e/framework/kcp.go b/test/e2e/framework/kcp.go index 1da6ec03817..2040af8fb5a 100644 --- a/test/e2e/framework/kcp.go +++ b/test/e2e/framework/kcp.go @@ -990,7 +990,7 @@ func newPersistentKCPServer(name, kubeconfigPath string, shardKubeconfigPaths ma func NewFakeWorkloadServer(t *testing.T, server RunningServer, org logicalcluster.Path, syncTargetName string) RunningServer { t.Helper() - path, ws := NewWorkspaceFixture(t, server, org, WithName(syncTargetName+"-sink"), TODO_WithoutMultiShardSupport()) + path, ws := NewWorkspaceFixture(t, server, org, WithName("%s", syncTargetName+"-sink"), TODO_WithoutMultiShardSupport()) logicalClusterName := logicalcluster.Name(ws.Spec.Cluster) rawConfig, err := server.RawConfig() require.NoError(t, err, "failed to read config for server") diff --git a/test/e2e/garbagecollector/garbagecollector_test.go b/test/e2e/garbagecollector/garbagecollector_test.go index 03ed87cb6d7..a34966dc7d0 100644 --- a/test/e2e/garbagecollector/garbagecollector_test.go +++ b/test/e2e/garbagecollector/garbagecollector_test.go @@ -142,7 +142,6 @@ func TestGarbageCollectorTypesFromBinding(t *testing.T) { // Test multiple workspaces in parallel for i := 0; i < 3; i++ { - i := i t.Run(fmt.Sprintf("tc%d", i), func(t *testing.T) { t.Parallel() diff --git a/test/e2e/mounts/mounts_machinery_test.go b/test/e2e/mounts/mounts_machinery_test.go index 8247e54762d..0ebd186efbd 100644 --- a/test/e2e/mounts/mounts_machinery_test.go +++ b/test/e2e/mounts/mounts_machinery_test.go @@ -66,7 +66,7 @@ func TestMountsMachinery(t *testing.T) { orgPath, _ := framework.NewOrganizationFixture(t, server) workspaceName := "mounts-machinery" - mountPath, _ := framework.NewWorkspaceFixture(t, server, orgPath, framework.WithName(workspaceName)) + mountPath, _ := framework.NewWorkspaceFixture(t, server, orgPath, framework.WithName("%s", workspaceName)) cfg := server.BaseConfig(t) kcpClusterClient, err := kcpclientset.NewForConfig(cfg) diff --git a/test/e2e/reconciler/cache/replication_test.go b/test/e2e/reconciler/cache/replication_test.go index e0b73162dfc..553b2e193c0 100644 --- a/test/e2e/reconciler/cache/replication_test.go +++ b/test/e2e/reconciler/cache/replication_test.go @@ -428,7 +428,6 @@ func TestReplication(t *testing.T) { {"WorkspaceTypeNegative", replicateWorkspaceTypeNegativeScenario}, } for _, scenario := range scenarios { - scenario := scenario t.Run(scenario.name, func(t *testing.T) { t.Parallel() scenario.work(ctx, t, server, kcpShardDynamicClient, cacheKcpClusterDynamicClient) @@ -446,8 +445,6 @@ func TestReplicationDisruptive(t *testing.T) { {"ShardNegative", replicateShardNegativeScenario}, } for _, scenario := range disruptiveScenarios { - scenario := scenario - t.Run(scenario.name, func(t *testing.T) { t.Parallel() diff --git a/test/e2e/reconciler/shard/controller_test.go b/test/e2e/reconciler/shard/controller_test.go index 78b9c6ddf66..bc7aa20d029 100644 --- a/test/e2e/reconciler/shard/controller_test.go +++ b/test/e2e/reconciler/shard/controller_test.go @@ -52,7 +52,6 @@ func TestWorkspaceShardController(t *testing.T) { sharedServer := framework.SharedKcpServer(t) for _, testCase := range testCases { - testCase := testCase t.Run(testCase.name, func(t *testing.T) { t.Parallel() diff --git a/test/e2e/reconciler/workspace/controller_test.go b/test/e2e/reconciler/workspace/controller_test.go index dbbfa2eafdb..687c4c0c488 100644 --- a/test/e2e/reconciler/workspace/controller_test.go +++ b/test/e2e/reconciler/workspace/controller_test.go @@ -143,7 +143,6 @@ func TestWorkspaceController(t *testing.T) { sharedServer := framework.SharedKcpServer(t) for _, testCase := range testCases { - testCase := testCase t.Run(testCase.name, func(t *testing.T) { t.Parallel() diff --git a/test/e2e/reconciler/workspacedeletion/controller_test.go b/test/e2e/reconciler/workspacedeletion/controller_test.go index 26c39b432b1..62c3088faeb 100644 --- a/test/e2e/reconciler/workspacedeletion/controller_test.go +++ b/test/e2e/reconciler/workspacedeletion/controller_test.go @@ -282,7 +282,6 @@ func TestWorkspaceDeletion(t *testing.T) { sharedServer := framework.SharedKcpServer(t) for _, testCase := range testCases { - testCase := testCase t.Run(testCase.name, func(t *testing.T) { t.Parallel() diff --git a/test/e2e/workspacetype/controller_test.go b/test/e2e/workspacetype/controller_test.go index adf562dab7f..543e556e733 100644 --- a/test/e2e/workspacetype/controller_test.go +++ b/test/e2e/workspacetype/controller_test.go @@ -327,7 +327,6 @@ func TestWorkspaceTypes(t *testing.T) { server := framework.SharedKcpServer(t) for _, testCase := range testCases { - testCase := testCase t.Run(testCase.name, func(t *testing.T) { t.Parallel()