diff --git a/.github/workflows/pr-golangci-lint.yaml b/.github/workflows/pr-golangci-lint.yaml index 8866a4ccc3a2..6cd9c43fbeb0 100644 --- a/.github/workflows/pr-golangci-lint.yaml +++ b/.github/workflows/pr-golangci-lint.yaml @@ -30,6 +30,6 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@ec5d18412c0aeab7936cb16880d708ba2a64e1ae # tag=v6.2.0 with: - version: v1.60.2 + version: v1.63.4 args: --out-format=colored-line-number working-directory: ${{matrix.working-directory}} diff --git a/controlplane/kubeadm/internal/workload_cluster_coredns_test.go b/controlplane/kubeadm/internal/workload_cluster_coredns_test.go index fd68d0a1595e..514da5810ceb 100644 --- a/controlplane/kubeadm/internal/workload_cluster_coredns_test.go +++ b/controlplane/kubeadm/internal/workload_cluster_coredns_test.go @@ -552,7 +552,7 @@ func TestUpdateCoreDNS(t *testing.T) { return errors.New("the coredns ConfigMap does not have the Corefile-backup entry or this it has an unexpected value") } return nil - }, "5s").Should(BeNil()) + }, "5s").Should(Succeed()) // assert CoreDNS deployment var actualDeployment appsv1.Deployment diff --git a/exp/internal/controllers/machinepool_controller_phases.go b/exp/internal/controllers/machinepool_controller_phases.go index c8bb00928327..a2067677410e 100644 --- a/exp/internal/controllers/machinepool_controller_phases.go +++ b/exp/internal/controllers/machinepool_controller_phases.go @@ -533,7 +533,7 @@ func (r *MachinePoolReconciler) waitForMachineCreation(ctx context.Context, mach // The polling is against a local memory cache. const waitForCacheUpdateInterval = 100 * time.Millisecond - for i := range len(machineList) { + for i := range machineList { machine := machineList[i] pollErr := wait.PollUntilContextTimeout(ctx, waitForCacheUpdateInterval, waitForCacheUpdateTimeout, true, func(ctx context.Context) (bool, error) { key := client.ObjectKey{Namespace: machine.Namespace, Name: machine.Name} diff --git a/exp/runtime/internal/controllers/extensionconfig_controller_test.go b/exp/runtime/internal/controllers/extensionconfig_controller_test.go index 31ce7f7641d7..c6d93fb4b67e 100644 --- a/exp/runtime/internal/controllers/extensionconfig_controller_test.go +++ b/exp/runtime/internal/controllers/extensionconfig_controller_test.go @@ -157,7 +157,7 @@ func TestExtensionReconciler_Reconcile(t *testing.T) { return errors.Errorf("URL not set on updated object: got: %s, want: %s", *conf.Spec.ClientConfig.URL, updatedServer.URL) } return nil - }, 30*time.Second, 100*time.Millisecond).Should(BeNil()) + }, 30*time.Second, 100*time.Millisecond).Should(Succeed()) // Reconcile the extension and assert discovery has succeeded. _, err = r.Reconcile(ctx, ctrl.Request{NamespacedName: util.ObjectKey(extensionConfig)}) diff --git a/exp/topology/desiredstate/desired_state_test.go b/exp/topology/desiredstate/desired_state_test.go index 27cd4e405775..eb2077a0f400 100644 --- a/exp/topology/desiredstate/desired_state_test.go +++ b/exp/topology/desiredstate/desired_state_test.go @@ -1205,7 +1205,13 @@ func TestComputeControlPlaneVersion(t *testing.T) { } _, err := r.computeControlPlaneVersion(ctx, tt.s) - g.Expect(fakeRuntimeClient.CallAllCount(runtimehooksv1.AfterControlPlaneUpgrade) == 1).To(Equal(tt.wantHookToBeCalled)) + + if tt.wantHookToBeCalled { + g.Expect(fakeRuntimeClient.CallAllCount(runtimehooksv1.AfterControlPlaneUpgrade)).To(Equal(1), "Expected hook to be called once") + } else { + g.Expect(fakeRuntimeClient.CallAllCount(runtimehooksv1.AfterControlPlaneUpgrade)).To(Equal(0), "Did not expect hook to be called") + } + g.Expect(hooks.IsPending(runtimehooksv1.AfterControlPlaneUpgrade, tt.s.Current.Cluster)).To(Equal(tt.wantIntentToCall)) g.Expect(err != nil).To(Equal(tt.wantErr)) if tt.wantHookToBeCalled && !tt.wantErr { diff --git a/internal/controllers/machineset/machineset_controller.go b/internal/controllers/machineset/machineset_controller.go index ed0d980fe21d..a1832f4ebc47 100644 --- a/internal/controllers/machineset/machineset_controller.go +++ b/internal/controllers/machineset/machineset_controller.go @@ -1022,7 +1022,7 @@ func (r *Reconciler) adoptOrphan(ctx context.Context, machineSet *clusterv1.Mach func (r *Reconciler) waitForMachineCreation(ctx context.Context, machineList []*clusterv1.Machine) error { log := ctrl.LoggerFrom(ctx) - for i := range len(machineList) { + for i := range machineList { machine := machineList[i] pollErr := wait.PollUntilContextTimeout(ctx, stateConfirmationInterval, stateConfirmationTimeout, true, func(ctx context.Context) (bool, error) { key := client.ObjectKey{Namespace: machine.Namespace, Name: machine.Name} @@ -1048,7 +1048,7 @@ func (r *Reconciler) waitForMachineCreation(ctx context.Context, machineList []* func (r *Reconciler) waitForMachineDeletion(ctx context.Context, machineList []*clusterv1.Machine) error { log := ctrl.LoggerFrom(ctx) - for i := range len(machineList) { + for i := range machineList { machine := machineList[i] pollErr := wait.PollUntilContextTimeout(ctx, stateConfirmationInterval, stateConfirmationTimeout, true, func(ctx context.Context) (bool, error) { m := &clusterv1.Machine{} diff --git a/internal/controllers/topology/cluster/cluster_controller_test.go b/internal/controllers/topology/cluster/cluster_controller_test.go index 9b6b3419c76b..9b077360d698 100644 --- a/internal/controllers/topology/cluster/cluster_controller_test.go +++ b/internal/controllers/topology/cluster/cluster_controller_test.go @@ -578,7 +578,12 @@ func TestClusterReconciler_reconcileDelete(t *testing.T) { g.Expect(err).ToNot(HaveOccurred()) g.Expect(res).To(BeComparableTo(tt.wantResult)) g.Expect(hooks.IsOkToDelete(tt.cluster)).To(Equal(tt.wantOkToDelete)) - g.Expect(fakeRuntimeClient.CallAllCount(runtimehooksv1.BeforeClusterDelete) == 1).To(Equal(tt.wantHookToBeCalled)) + + if tt.wantHookToBeCalled { + g.Expect(fakeRuntimeClient.CallAllCount(runtimehooksv1.BeforeClusterDelete)).To(Equal(1), "Expected hook to be called once") + } else { + g.Expect(fakeRuntimeClient.CallAllCount(runtimehooksv1.BeforeClusterDelete)).To(Equal(0), "Did not expect hook to be called") + } } }) } diff --git a/internal/controllers/topology/cluster/reconcile_state_test.go b/internal/controllers/topology/cluster/reconcile_state_test.go index 59c13b44a888..016069ab65b7 100644 --- a/internal/controllers/topology/cluster/reconcile_state_test.go +++ b/internal/controllers/topology/cluster/reconcile_state_test.go @@ -471,7 +471,13 @@ func TestReconcile_callAfterControlPlaneInitialized(t *testing.T) { } err := r.callAfterControlPlaneInitialized(ctx, s) - g.Expect(fakeRuntimeClient.CallAllCount(runtimehooksv1.AfterControlPlaneInitialized) == 1).To(Equal(tt.wantHookToBeCalled)) + + if tt.wantHookToBeCalled { + g.Expect(fakeRuntimeClient.CallAllCount(runtimehooksv1.AfterControlPlaneInitialized)).To(Equal(1), "Expected hook to be called once") + } else { + g.Expect(fakeRuntimeClient.CallAllCount(runtimehooksv1.AfterControlPlaneInitialized)).To(Equal(0), "Did not expect hook to be called") + } + g.Expect(hooks.IsPending(runtimehooksv1.AfterControlPlaneInitialized, tt.cluster)).To(Equal(tt.wantMarked)) g.Expect(err != nil).To(Equal(tt.wantError)) }) @@ -1089,7 +1095,13 @@ func TestReconcile_callAfterClusterUpgrade(t *testing.T) { } err := r.callAfterClusterUpgrade(ctx, tt.s) - g.Expect(fakeRuntimeClient.CallAllCount(runtimehooksv1.AfterClusterUpgrade) == 1).To(Equal(tt.wantHookToBeCalled)) + + if tt.wantHookToBeCalled { + g.Expect(fakeRuntimeClient.CallAllCount(runtimehooksv1.AfterClusterUpgrade)).To(Equal(1), "Expected hook to be called once") + } else { + g.Expect(fakeRuntimeClient.CallAllCount(runtimehooksv1.AfterClusterUpgrade)).To(Equal(0), "Did not expect hook to be called") + } + g.Expect(hooks.IsPending(runtimehooksv1.AfterClusterUpgrade, tt.s.Current.Cluster)).To(Equal(tt.wantMarked)) g.Expect(err != nil).To(Equal(tt.wantError)) }) diff --git a/test/e2e/clusterclass_changes.go b/test/e2e/clusterclass_changes.go index 454543f2a707..61979966792a 100644 --- a/test/e2e/clusterclass_changes.go +++ b/test/e2e/clusterclass_changes.go @@ -301,7 +301,7 @@ func modifyControlPlaneViaClusterClassAndWait(ctx context.Context, input modifyC g.Expect(currentValue).To(Equal(expectedValue), fmt.Sprintf("field %q should be equal", fieldPath)) } return nil - }, input.WaitForControlPlane...).Should(BeNil()) + }, input.WaitForControlPlane...).Should(Succeed()) } // assertControlPlaneTopologyFields asserts that all fields set in the ControlPlaneTopology have been set on the ControlPlane. @@ -454,7 +454,7 @@ func modifyMachineDeploymentViaClusterClassAndWait(ctx context.Context, input mo g.Expect(currentValue).To(Equal(expectedValue), fmt.Sprintf("field %q should be equal", fieldPath)) } return nil - }, input.WaitForMachineDeployments...).Should(BeNil()) + }, input.WaitForMachineDeployments...).Should(Succeed()) } } } @@ -580,7 +580,7 @@ func modifyMachinePoolViaClusterClassAndWait(ctx context.Context, input modifyMa g.Expect(currentValue).To(Equal(expectedValue), fmt.Sprintf("field %q should be equal", fieldPath)) } return nil - }, input.WaitForMachinePools...).Should(BeNil()) + }, input.WaitForMachinePools...).Should(Succeed()) } } } @@ -735,7 +735,7 @@ func rebaseClusterClassAndWait(ctx context.Context, input rebaseClusterClassAndW } return nil - }, input.WaitForMachineDeployments...).Should(BeNil()) + }, input.WaitForMachineDeployments...).Should(Succeed()) } // Verify that the ControlPlane has not been changed. @@ -783,5 +783,5 @@ func deleteMachineDeploymentTopologyAndWait(ctx context.Context, input deleteMac return errors.Errorf("expected no MachineDeployment for topology %q, but got %d", mdTopologyToDelete.Name, len(mdList.Items)) } return nil - }, input.WaitForMachineDeployments...).Should(BeNil()) + }, input.WaitForMachineDeployments...).Should(Succeed()) } diff --git a/test/e2e/self_hosted.go b/test/e2e/self_hosted.go index d562b9d2f2c1..c4eec033b798 100644 --- a/test/e2e/self_hosted.go +++ b/test/e2e/self_hosted.go @@ -236,11 +236,11 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput) Consistently(func() error { kubeSystem := &corev1.Namespace{} return input.BootstrapClusterProxy.GetClient().Get(ctx, client.ObjectKey{Name: "kube-system"}, kubeSystem) - }, "5s", "100ms").Should(BeNil(), "Failed to assert bootstrap API server stability") + }, "5s", "100ms").Should(Succeed(), "Failed to assert bootstrap API server stability") Consistently(func() error { kubeSystem := &corev1.Namespace{} return selfHostedClusterProxy.GetClient().Get(ctx, client.ObjectKey{Name: "kube-system"}, kubeSystem) - }, "5s", "100ms").Should(BeNil(), "Failed to assert self-hosted API server stability") + }, "5s", "100ms").Should(Succeed(), "Failed to assert self-hosted API server stability") // Get the machines of the workloadCluster before it is moved to become self-hosted to make sure that the move did not trigger // any unexpected rollouts. @@ -438,11 +438,11 @@ func SelfHostedSpec(ctx context.Context, inputGetter func() SelfHostedSpecInput) Consistently(func() error { kubeSystem := &corev1.Namespace{} return input.BootstrapClusterProxy.GetClient().Get(ctx, client.ObjectKey{Name: "kube-system"}, kubeSystem) - }, "5s", "100ms").Should(BeNil(), "Failed to assert bootstrap API server stability") + }, "5s", "100ms").Should(Succeed(), "Failed to assert bootstrap API server stability") Consistently(func() error { kubeSystem := &corev1.Namespace{} return selfHostedClusterProxy.GetClient().Get(ctx, client.ObjectKey{Name: "kube-system"}, kubeSystem) - }, "5s", "100ms").Should(BeNil(), "Failed to assert self-hosted API server stability") + }, "5s", "100ms").Should(Succeed(), "Failed to assert self-hosted API server stability") By("Moving the cluster back to bootstrap") clusterctl.Move(ctx, clusterctl.MoveInput{