From 69f0290e1acdf5ffcf681fd400b1e95d700fec71 Mon Sep 17 00:00:00 2001 From: Ashish Ranjan Yadav Date: Thu, 5 Sep 2024 14:03:22 +0530 Subject: [PATCH] Make linter happy --- pkg/controller/deployment_machineset_util.go | 10 +++++----- pkg/controller/machine_safety.go | 4 ++-- pkg/test/utils/matchers/deep.go | 2 +- pkg/util/provider/drain/drain.go | 2 +- pkg/util/provider/drain/drain_test.go | 6 +++--- pkg/util/provider/machinecontroller/machine_test.go | 6 +++--- pkg/util/provider/machinecontroller/machine_util.go | 6 +++--- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/pkg/controller/deployment_machineset_util.go b/pkg/controller/deployment_machineset_util.go index a32b2411d..a8eca2430 100644 --- a/pkg/controller/deployment_machineset_util.go +++ b/pkg/controller/deployment_machineset_util.go @@ -61,11 +61,11 @@ func updateMachineSetStatus(ctx context.Context, machineClient machineapi.Machin var getErr, updateErr error var updatedIS *v1alpha1.MachineSet for i, is := 0, is; ; i++ { - klog.V(4).Infof(fmt.Sprintf("Updating status for MachineSet: %s/%s, ", is.Namespace, is.Name) + - fmt.Sprintf("replicas %d->%d (need %d), ", is.Status.Replicas, newStatus.Replicas, is.Spec.Replicas) + - fmt.Sprintf("fullyLabeledReplicas %d->%d, ", is.Status.FullyLabeledReplicas, newStatus.FullyLabeledReplicas) + - fmt.Sprintf("readyReplicas %d->%d, ", is.Status.ReadyReplicas, newStatus.ReadyReplicas) + - fmt.Sprintf("availableReplicas %d->%d, ", is.Status.AvailableReplicas, newStatus.AvailableReplicas) + + klog.V(4).Infof("%s", fmt.Sprintf("Updating status for MachineSet: %s/%s, ", is.Namespace, is.Name)+ + fmt.Sprintf("replicas %d->%d (need %d), ", is.Status.Replicas, newStatus.Replicas, is.Spec.Replicas)+ + fmt.Sprintf("fullyLabeledReplicas %d->%d, ", is.Status.FullyLabeledReplicas, newStatus.FullyLabeledReplicas)+ + fmt.Sprintf("readyReplicas %d->%d, ", is.Status.ReadyReplicas, newStatus.ReadyReplicas)+ + fmt.Sprintf("availableReplicas %d->%d, ", is.Status.AvailableReplicas, newStatus.AvailableReplicas)+ fmt.Sprintf("sequence No: %v->%v", is.Status.ObservedGeneration, newStatus.ObservedGeneration)) is.Status = newStatus diff --git a/pkg/controller/machine_safety.go b/pkg/controller/machine_safety.go index 725ea142f..8b359303b 100644 --- a/pkg/controller/machine_safety.go +++ b/pkg/controller/machine_safety.go @@ -362,7 +362,7 @@ func (c *controller) unfreezeMachineSet(ctx context.Context, machineSet *v1alpha if machineSet == nil { err := fmt.Errorf("SafetyController: Machine Set not passed") - klog.Errorf(err.Error()) + klog.Errorf("%s", err.Error()) return err } @@ -443,7 +443,7 @@ func (c *controller) unfreezeMachineDeployment(ctx context.Context, machineDeplo if machineDeployment == nil { err := fmt.Errorf("SafetyController: Machine Deployment not passed") - klog.Errorf(err.Error()) + klog.Errorf("%s", err.Error()) return err } diff --git a/pkg/test/utils/matchers/deep.go b/pkg/test/utils/matchers/deep.go index 195bf4aac..72acf2f90 100644 --- a/pkg/test/utils/matchers/deep.go +++ b/pkg/test/utils/matchers/deep.go @@ -43,7 +43,7 @@ func newDeepEqualMatcher(expected interface{}) gomegatypes.GomegaMatcher { func (m *deepMatcher) Match(actual interface{}) (success bool, err error) { if actual == nil && m.expected == nil { - return false, fmt.Errorf(deepMatcherNilError) + return false, fmt.Errorf("%s", deepMatcherNilError) } return m.compareFn(m.expected, actual), nil diff --git a/pkg/util/provider/drain/drain.go b/pkg/util/provider/drain/drain.go index a2fd390e5..17d2fe978 100644 --- a/pkg/util/provider/drain/drain.go +++ b/pkg/util/provider/drain/drain.go @@ -924,7 +924,7 @@ func (o *Options) waitForReattach(ctx context.Context, podVolumeInfo PodVolumeIn case <-ctx.Done(): // Timeout occurred waiting for reattachment, exit function with error klog.Warningf("Timeout occurred while waiting for PVs %v to reattach to a different node", podVolumeInfo.persistentVolumeList) - return fmt.Errorf(reattachTimeoutErr) + return fmt.Errorf("%s", reattachTimeoutErr) case incomingEvent := <-volumeAttachmentEventCh: persistentVolumeName := *incomingEvent.Spec.Source.PersistentVolumeName diff --git a/pkg/util/provider/drain/drain_test.go b/pkg/util/provider/drain/drain_test.go index 0f1e78839..4de8f185e 100644 --- a/pkg/util/provider/drain/drain_test.go +++ b/pkg/util/provider/drain/drain_test.go @@ -194,7 +194,7 @@ var _ = Describe("drain", func() { nodes := d.client.CoreV1().Nodes() node, err := nodes.Get(context.TODO(), pod.Spec.NodeName, metav1.GetOptions{}) if err != nil { - fmt.Fprintln(GinkgoWriter, err) + _, _ = fmt.Fprintln(GinkgoWriter, err) continue } @@ -245,10 +245,10 @@ var _ = Describe("drain", func() { } _, err = nodes.Update(context.TODO(), node, metav1.UpdateOptions{}) - fmt.Fprintln(GinkgoWriter, err) + _, _ = fmt.Fprintln(GinkgoWriter, err) _, err = nodes.UpdateStatus(context.TODO(), node, metav1.UpdateOptions{}) - fmt.Fprintln(GinkgoWriter, err) + _, _ = fmt.Fprintln(GinkgoWriter, err) } }() diff --git a/pkg/util/provider/machinecontroller/machine_test.go b/pkg/util/provider/machinecontroller/machine_test.go index 2d50b4153..2b87907b7 100644 --- a/pkg/util/provider/machinecontroller/machine_test.go +++ b/pkg/util/provider/machinecontroller/machine_test.go @@ -1810,7 +1810,7 @@ var _ = Describe("machine", func() { }, }, expect: expect{ - err: fmt.Errorf(fmt.Sprintf("Force Drain successful. %s", machineutils.DelVolumesAttachments)), + err: fmt.Errorf("%s", fmt.Sprintf("Force Drain successful. %s", machineutils.DelVolumesAttachments)), retry: machineutils.ShortRetry, machine: newMachine( &v1alpha1.MachineTemplateSpec{ @@ -1912,7 +1912,7 @@ var _ = Describe("machine", func() { }, }, expect: expect{ - err: fmt.Errorf(fmt.Sprintf("Force Drain successful. %s", machineutils.DelVolumesAttachments)), + err: fmt.Errorf("%s", fmt.Sprintf("Force Drain successful. %s", machineutils.DelVolumesAttachments)), retry: machineutils.ShortRetry, machine: newMachine( &v1alpha1.MachineTemplateSpec{ @@ -2019,7 +2019,7 @@ var _ = Describe("machine", func() { }, }, expect: expect{ - err: fmt.Errorf(fmt.Sprintf("Force Drain successful. %s", machineutils.DelVolumesAttachments)), + err: fmt.Errorf("%s", fmt.Sprintf("Force Drain successful. %s", machineutils.DelVolumesAttachments)), retry: machineutils.ShortRetry, machine: newMachine( &v1alpha1.MachineTemplateSpec{ diff --git a/pkg/util/provider/machinecontroller/machine_util.go b/pkg/util/provider/machinecontroller/machine_util.go index 548b14c04..0058b6500 100644 --- a/pkg/util/provider/machinecontroller/machine_util.go +++ b/pkg/util/provider/machinecontroller/machine_util.go @@ -979,7 +979,7 @@ func (c *controller) getVMStatus(ctx context.Context, getMachineStatusRequest *d state = v1alpha1.MachineStateFailed retry = machineutils.LongRetry - err = fmt.Errorf("Machine deletion has failed. " + description) + err = fmt.Errorf("Machine deletion has failed. %s", description) } else { // Decoding machine error code switch machineErr.Code() { @@ -1199,7 +1199,7 @@ func (c *controller) drainNode(ctx context.Context, deleteMachineRequest *driver } else { // regular drain already waits for vol detach and attach for another node. description = fmt.Sprintf("Drain successful. %s", machineutils.InitiateVMDeletion) } - err = fmt.Errorf(description) + err = fmt.Errorf("%s", description) state = v1alpha1.MachineStateProcessing // Return error even when machine object is updated @@ -1346,7 +1346,7 @@ func (c *controller) deleteVM(ctx context.Context, deleteMachineRequest *driver. description = fmt.Sprintf("VM deletion was successful. %s", machineutils.InitiateNodeDeletion) state = v1alpha1.MachineStateProcessing - err = fmt.Errorf("Machine deletion in process. " + description) + err = fmt.Errorf("Machine deletion in process. %s", description) } if deleteMachineResponse != nil && deleteMachineResponse.LastKnownState != "" {