diff --git a/cmd/apiserver-watcher/run.go b/cmd/apiserver-watcher/run.go index 64a9457187..3d40e166fc 100644 --- a/cmd/apiserver-watcher/run.go +++ b/cmd/apiserver-watcher/run.go @@ -110,7 +110,7 @@ func runRunCmd(_ *cobra.Command, _ []string) error { }}) if err := h.Start(); err != nil { - return fmt.Errorf("failed to start heath checker: %v", err) + return fmt.Errorf("failed to start heath checker: %w", err) } c := make(chan os.Signal, 1) @@ -129,7 +129,7 @@ func runRunCmd(_ *cobra.Command, _ []string) error { select { case err := <-errCh: if err != nil { - return fmt.Errorf("error running health checker: %v", err) + return fmt.Errorf("error running health checker: %w", err) } } } @@ -138,7 +138,7 @@ func runRunCmd(_ *cobra.Command, _ []string) error { func newHandler(uri *url.URL) (*handler, error) { addrs, err := net.LookupHost(uri.Hostname()) if err != nil { - return nil, fmt.Errorf("failed to lookup host %s: %v", uri.Hostname(), err) + return nil, fmt.Errorf("failed to lookup host %s: %w", uri.Hostname(), err) } if len(addrs) == 0 { return nil, fmt.Errorf("hostname %s has no addresses, expected at least 1 - aborting", uri.Hostname()) @@ -186,7 +186,7 @@ func writeVipStateFile(vip, state string) error { // #nosec err := os.WriteFile(file, nil, 0o644) if err != nil { - return fmt.Errorf("failed to create file (%s): %v", file, err) + return fmt.Errorf("failed to create file (%s): %w", file, err) } return nil } @@ -195,7 +195,7 @@ func removeVipStateFile(vip, state string) error { file := path.Join(runOpts.rootMount, downFileDir, fmt.Sprintf("%s.%s", vip, state)) err := os.Remove(file) if err != nil && !os.IsNotExist(err) { - return fmt.Errorf("failed to remove file (%s): %v", file, err) + return fmt.Errorf("failed to remove file (%s): %w", file, err) } return nil } diff --git a/devex/cmd/mco-sanitize/processor.go b/devex/cmd/mco-sanitize/processor.go index f8819d779b..aaa54237a2 100644 --- a/devex/cmd/mco-sanitize/processor.go +++ b/devex/cmd/mco-sanitize/processor.go @@ -62,7 +62,7 @@ func (p *FileProcessorImpl) Process(_ context.Context, path string) (changed boo func writeOutput(outputWriter io.Writer, outputContent interface{}, marshaller contentMarshaler) error { encoded, err := marshaller(outputContent) if err != nil { - return fmt.Errorf("could not encode redacted data back to the original format: %v", err) + return fmt.Errorf("could not encode redacted data back to the original format: %w", err) } if _, err = outputWriter.Write(encoded); err != nil { diff --git a/pkg/controller/bootimage/boot_image_controller.go b/pkg/controller/bootimage/boot_image_controller.go index 5fdd51d6ef..c69788f974 100644 --- a/pkg/controller/bootimage/boot_image_controller.go +++ b/pkg/controller/bootimage/boot_image_controller.go @@ -684,7 +684,7 @@ func (ctrl *Controller) syncAll(event string) error { // Wait for MachineConfiguration/cluster to be ready before syncing any machine resources if err := ctrl.waitForMachineConfigurationReady(); err != nil { - ctrl.updateConditions(event, fmt.Errorf("MachineConfiguration was not ready: %v", err), opv1.MachineConfigurationBootImageUpdateDegraded) + ctrl.updateConditions(event, fmt.Errorf("MachineConfiguration was not ready: %w", err), opv1.MachineConfigurationBootImageUpdateDegraded) return err } diff --git a/pkg/controller/bootimage/cache/cache.go b/pkg/controller/bootimage/cache/cache.go index 25d5f059d9..4f59db7759 100644 --- a/pkg/controller/bootimage/cache/cache.go +++ b/pkg/controller/bootimage/cache/cache.go @@ -24,7 +24,7 @@ const ( func getFileHashBuffered(filePath string) (string, error) { file, err := os.Open(filePath) if err != nil { - return "", fmt.Errorf("couldn't open file %v", err) + return "", fmt.Errorf("couldn't open file %w", err) } defer file.Close() @@ -40,7 +40,7 @@ func getFileHashBuffered(filePath string) (string, error) { break } if err != nil { - return "", fmt.Errorf("error reading file: %v", err) + return "", fmt.Errorf("error reading file: %w", err) } } @@ -58,7 +58,7 @@ func getFileFromCache(fileName, cacheDir string) (string, string, error) { klog.Infof("The file was found in cache: %v. Reusing...", filePath) hash, err := getFileHashBuffered(filePath) if err != nil { - return "", "", fmt.Errorf("error calculating SHA256 hash of filepath %v: %v", filePath, err) + return "", "", fmt.Errorf("error calculating SHA256 hash of filepath %v: %w", filePath, err) } return filePath, hash, nil } diff --git a/pkg/controller/bootimage/cpms_helpers.go b/pkg/controller/bootimage/cpms_helpers.go index ac25c0f8ff..b362275395 100644 --- a/pkg/controller/bootimage/cpms_helpers.go +++ b/pkg/controller/bootimage/cpms_helpers.go @@ -43,14 +43,14 @@ func (ctrl *Controller) syncControlPlaneMachineSets(reason string) { mcop, err := ctrl.mcopLister.Get(ctrlcommon.MCOOperatorKnobsObjectName) if err != nil { klog.Errorf("Failed to get MachineConfiguration: %v", err) - ctrl.updateConditions(reason, fmt.Errorf("failed to get MachineConfiguration while enqueueing ControlPlaneMachineSet: %v", err), opv1.MachineConfigurationBootImageUpdateDegraded) + ctrl.updateConditions(reason, fmt.Errorf("failed to get MachineConfiguration while enqueueing ControlPlaneMachineSet: %w", err), opv1.MachineConfigurationBootImageUpdateDegraded) return } machineManagerFound, machineResourceSelector, err := getMachineResourceSelectorFromMachineManagers(mcop.Status.ManagedBootImagesStatus.MachineManagers, opv1.MachineAPI, opv1.ControlPlaneMachineSets) if err != nil { klog.Errorf("failed to create a machineset selector while enqueueing controlplanemachineset %v", err) - ctrl.updateConditions(reason, fmt.Errorf("failed to create a machineset selector while enqueueing ControlPlaneMachineSet %v", err), opv1.MachineConfigurationBootImageUpdateDegraded) + ctrl.updateConditions(reason, fmt.Errorf("failed to create a machineset selector while enqueueing ControlPlaneMachineSet %w", err), opv1.MachineConfigurationBootImageUpdateDegraded) return } if !machineManagerFound { @@ -64,7 +64,7 @@ func (ctrl *Controller) syncControlPlaneMachineSets(reason string) { controlPlaneMachineSets, err := ctrl.cpmsLister.List(machineResourceSelector) if err != nil { klog.Errorf("failed to fetch ControlPlaneMachineSet list while enqueueing ControlPlaneMachineSet %v", err) - ctrl.updateConditions(reason, fmt.Errorf("failed to fetch ControlPlaneMachineSet list while enqueueing ControlPlaneMachineSet %v", err), opv1.MachineConfigurationBootImageUpdateDegraded) + ctrl.updateConditions(reason, fmt.Errorf("failed to fetch ControlPlaneMachineSet list while enqueueing ControlPlaneMachineSet %w", err), opv1.MachineConfigurationBootImageUpdateDegraded) return } @@ -92,7 +92,7 @@ func (ctrl *Controller) syncControlPlaneMachineSets(reason string) { ctrl.cpmsStats.inProgress++ } else { klog.Errorf("Error syncing ControlPlaneMachineSet %v", err) - syncErrors = append(syncErrors, fmt.Errorf("error syncing ControlPlaneMachineSet %s: %v", controlPlaneMachineSet.Name, err)) + syncErrors = append(syncErrors, fmt.Errorf("error syncing ControlPlaneMachineSet %s: %w", controlPlaneMachineSet.Name, err)) ctrl.cpmsStats.erroredCount++ } // Update progressing conditions every step of the loop diff --git a/pkg/controller/bootimage/helpers.go b/pkg/controller/bootimage/helpers.go index 0af0869a02..ca79331e04 100644 --- a/pkg/controller/bootimage/helpers.go +++ b/pkg/controller/bootimage/helpers.go @@ -111,7 +111,7 @@ func upgradeStubIgnitionIfRequired(secretName string, secretClient clientset.Int klog.Infof("Out of date version=%s stub Ignition detected in %s, attempting upgrade", version, secret.Name) userDataIgnUpgraded, err := ctrlcommon.ParseAndConvertConfig(userData) if err != nil { - return fmt.Errorf("converting ignition stub failed: %v", err) + return fmt.Errorf("converting ignition stub failed: %w", err) } klog.Infof("ignition stub upgrade to %s successful", userDataIgnUpgraded.Ignition.Version) // Annotate the secret if an Ignition upgrade took place diff --git a/pkg/controller/bootimage/ms_helpers.go b/pkg/controller/bootimage/ms_helpers.go index 0190ffbd22..557b75b434 100644 --- a/pkg/controller/bootimage/ms_helpers.go +++ b/pkg/controller/bootimage/ms_helpers.go @@ -32,14 +32,14 @@ func (ctrl *Controller) syncMAPIMachineSets(reason string) { mcop, err := ctrl.mcopLister.Get(ctrlcommon.MCOOperatorKnobsObjectName) if err != nil { klog.Errorf("Failed to get MachineConfiguration: %v", err) - ctrl.updateConditions(reason, fmt.Errorf("failed to get MachineConfiguration while enqueueing MAPI MachineSets: %v", err), opv1.MachineConfigurationBootImageUpdateDegraded) + ctrl.updateConditions(reason, fmt.Errorf("failed to get MachineConfiguration while enqueueing MAPI MachineSets: %w", err), opv1.MachineConfigurationBootImageUpdateDegraded) return } machineManagerFound, machineResourceSelector, err := getMachineResourceSelectorFromMachineManagers(mcop.Status.ManagedBootImagesStatus.MachineManagers, opv1.MachineAPI, opv1.MachineSets) if err != nil { klog.Errorf("failed to create a machineset selector while enqueueing MAPI machineset %v", err) - ctrl.updateConditions(reason, fmt.Errorf("failed to create a machineset selector while enqueueing MAPI machineset %v", err), opv1.MachineConfigurationBootImageUpdateDegraded) + ctrl.updateConditions(reason, fmt.Errorf("failed to create a machineset selector while enqueueing MAPI machineset %w", err), opv1.MachineConfigurationBootImageUpdateDegraded) return } if !machineManagerFound { @@ -54,7 +54,7 @@ func (ctrl *Controller) syncMAPIMachineSets(reason string) { mapiMachineSets, err := ctrl.mapiMachineSetLister.List(machineResourceSelector) if err != nil { klog.Errorf("failed to fetch MachineSet list while enqueueing MAPI MachineSets %v", err) - ctrl.updateConditions(reason, fmt.Errorf("failed to fetch MachineSet list while enqueueing MAPI MachineSets %v", err), opv1.MachineConfigurationBootImageUpdateDegraded) + ctrl.updateConditions(reason, fmt.Errorf("failed to fetch MachineSet list while enqueueing MAPI MachineSets %w", err), opv1.MachineConfigurationBootImageUpdateDegraded) return } @@ -83,7 +83,7 @@ func (ctrl *Controller) syncMAPIMachineSets(reason string) { ctrl.mapiStats.inProgress++ } else { klog.Errorf("Error syncing MAPI MachineSet %v", err) - syncErrors = append(syncErrors, fmt.Errorf("error syncing MAPI MachineSet %s: %v", machineSet.Name, err)) + syncErrors = append(syncErrors, fmt.Errorf("error syncing MAPI MachineSet %s: %w", machineSet.Name, err)) ctrl.mapiStats.erroredCount++ } if patchSkipped { @@ -140,7 +140,7 @@ func (ctrl *Controller) syncMAPIMachineSet(machineSet *machinev1beta1.MachineSet // Fetch the ClusterVersion to determine if this is a multi-arch cluster clusterVersion, err := ctrl.clusterVersionLister.Get("version") if err != nil { - return false, fmt.Errorf("failed to fetch clusterversion during machineset sync: %v, defaulting to single-arch behavior", err) + return false, fmt.Errorf("failed to fetch clusterversion during machineset sync: %w", err) } // Fetch the architecture type of this machineset diff --git a/pkg/controller/bootimage/vsphere_helpers.go b/pkg/controller/bootimage/vsphere_helpers.go index a5d4818d35..c42cac29e8 100644 --- a/pkg/controller/bootimage/vsphere_helpers.go +++ b/pkg/controller/bootimage/vsphere_helpers.go @@ -483,7 +483,7 @@ func createNewVMTemplate(streamData *stream.Stream, providerSpec *machinev1beta1 var vmMo mo.VirtualMachine err = existingTemplateVM.Properties(ctx, existingTemplateVM.Reference(), nil, &vmMo) if err != nil { - return "", false, fmt.Errorf("Unable to extract properties from existing Template VM: %w", err) + return "", false, fmt.Errorf("unable to extract properties from existing Template VM: %w", err) } if vmMo.Summary.Config.Product != nil { @@ -503,11 +503,11 @@ func createNewVMTemplate(streamData *stream.Stream, providerSpec *machinev1beta1 ovaPath, err := cache.DownloadOva(ova) if err != nil { - return "", false, fmt.Errorf("Failed to download %s: %w", ova.Location, err) + return "", false, fmt.Errorf("failed to download %s: %w", ova.Location, err) } if len(name) > 80 { - return "", false, fmt.Errorf("Length of VM template name `%s` exceeds the permitted limit of 80 characters", name) + return "", false, fmt.Errorf("length of VM template name `%s` exceeds the permitted limit of 80 characters", name) } diskType := getDiskTypeFromExistingVM(vmMo) diff --git a/pkg/controller/bootstrap/bootstrap.go b/pkg/controller/bootstrap/bootstrap.go index eb09732f73..83fbaec174 100644 --- a/pkg/controller/bootstrap/bootstrap.go +++ b/pkg/controller/bootstrap/bootstrap.go @@ -567,7 +567,7 @@ type manifest struct { // UnmarshalJSON unmarshals bytes of single kubernetes object to manifest. func (m *manifest) UnmarshalJSON(in []byte) error { if m == nil { - return errors.New("Manifest: UnmarshalJSON on nil pointer") + return errors.New("manifest: UnmarshalJSON on nil pointer") } // This happens when marshalling diff --git a/pkg/controller/build/buildrequest/buildrequest.go b/pkg/controller/build/buildrequest/buildrequest.go index 7e89e93655..71288bb1b2 100644 --- a/pkg/controller/build/buildrequest/buildrequest.go +++ b/pkg/controller/build/buildrequest/buildrequest.go @@ -280,7 +280,7 @@ func (br buildRequestImpl) ignitionFileToConfigMapData(mc *mcfgv1.MachineConfig, // Extract and decode the encoded data decodedData, err := chelpers.DecodeIgnitionFileContents(file.Contents.Source, file.Contents.Compression) if err != nil { - return nil, fmt.Errorf("error decoding %s: %v", file.Path, err) + return nil, fmt.Errorf("error decoding %s: %w", file.Path, err) } // Key in the configmap is the path without the prefix diff --git a/pkg/controller/build/osbuildcontroller.go b/pkg/controller/build/osbuildcontroller.go index 0a6c4651ea..073f6b128c 100644 --- a/pkg/controller/build/osbuildcontroller.go +++ b/pkg/controller/build/osbuildcontroller.go @@ -340,12 +340,12 @@ func (ctrl *OSBuildController) deleteMachineOSConfig(cur interface{}) { if !ok { tombstone, ok := cur.(cache.DeletedFinalStateUnknown) if !ok { - utilruntime.HandleError(fmt.Errorf("Couldn't get object from tombstone %#v", cur)) + utilruntime.HandleError(fmt.Errorf("couldn't get object from tombstone %#v", cur)) return } mosc, ok = tombstone.Obj.(*mcfgv1.MachineOSConfig) if !ok { - utilruntime.HandleError(fmt.Errorf("Tombstone contained object that is not a MachineOSConfig %#v", cur)) + utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a MachineOSConfig %#v", cur)) return } } diff --git a/pkg/controller/certrotation/certrotation_controller.go b/pkg/controller/certrotation/certrotation_controller.go index 936b7e5cf4..a8137849de 100644 --- a/pkg/controller/certrotation/certrotation_controller.go +++ b/pkg/controller/certrotation/certrotation_controller.go @@ -438,7 +438,7 @@ func (c *CertRotationController) reconcileSecret(secret corev1.Secret) error { // Do a fresh get here since the lister will be likely out of date mcsCABundle, err := c.kubeClient.CoreV1().ConfigMaps(ctrlcommon.MCONamespace).Get(context.TODO(), ctrlcommon.MachineConfigServerCAName, metav1.GetOptions{}) if err != nil { - return fmt.Errorf("cannot read MCS CA bundle configmap: %v", err) + return fmt.Errorf("cannot read MCS CA bundle configmap: %w", err) } diff --git a/pkg/controller/certrotation/hostnames.go b/pkg/controller/certrotation/hostnames.go index bc7f4c3178..bac4793774 100644 --- a/pkg/controller/certrotation/hostnames.go +++ b/pkg/controller/certrotation/hostnames.go @@ -64,7 +64,7 @@ func (c *CertRotationController) processHostnames() bool { return true } - utilruntime.HandleError(fmt.Errorf("%v failed with : %v", dsKey, err)) + utilruntime.HandleError(fmt.Errorf("%v failed with : %w", dsKey, err)) c.hostnamesQueue.AddRateLimited(dsKey) return true diff --git a/pkg/controller/common/featuregates.go b/pkg/controller/common/featuregates.go index 7fb1a4b234..11252f11e5 100644 --- a/pkg/controller/common/featuregates.go +++ b/pkg/controller/common/featuregates.go @@ -59,7 +59,7 @@ func NewFeatureGatesAccessHandler(featureGateAccess featuregates.FeatureGateAcce func NewFeatureGatesHardcodedHandler(enabled, disabled []configv1.FeatureGateName) *FeatureGatesHandlerImpl { fgHandler := NewFeatureGatesAccessHandler(featuregates.NewHardcodedFeatureGateAccess(enabled, disabled)) if err := fgHandler.Connect(context.Background()); err != nil { - panic(fmt.Errorf("hardcoded feature gate impossible failure: %v", err)) + panic(fmt.Errorf("hardcoded feature gate impossible failure: %w", err)) } return fgHandler } @@ -73,7 +73,7 @@ func NewFeatureGatesCRHandlerImpl(featureGate *configv1.FeatureGate, desiredVers } fgHandler := NewFeatureGatesAccessHandler(fgAccess) if err = fgHandler.Connect(context.Background()); err != nil { - panic(fmt.Errorf("hardcoded feature gate impossible failure: %v", err)) + panic(fmt.Errorf("hardcoded feature gate impossible failure: %w", err)) } return fgHandler, nil } @@ -125,7 +125,7 @@ func (h *FeatureGatesHandlerImpl) Connect(ctx context.Context) error { case <-h.fgAccess.InitialFeatureGatesObserved(): fgs, err := h.fgAccess.CurrentFeatureGates() if err != nil { - return fmt.Errorf("unable to get initial features: %v", err) + return fmt.Errorf("unable to get initial features: %w", err) } h.registerFeatureGates(fgs) h.connectionDone = true diff --git a/pkg/controller/common/helpers.go b/pkg/controller/common/helpers.go index d39df73512..05de7646a5 100644 --- a/pkg/controller/common/helpers.go +++ b/pkg/controller/common/helpers.go @@ -81,7 +81,7 @@ func MergeMachineConfigs(configs []*mcfgv1.MachineConfig, cconfig *mcfgv1.Contro for _, config := range configs { if config.ObjectMeta.Labels == nil { // This shouldn't really be possible - return nil, fmt.Errorf("Cannot find label in MachineConfig %s", config.ObjectMeta.Name) + return nil, fmt.Errorf("cannot find label in MachineConfig %s", config.ObjectMeta.Name) } if config.ObjectMeta.Labels[MachineConfigRoleLabel] == MachineConfigPoolWorker { workerConfigs = append(workerConfigs, config) @@ -532,7 +532,7 @@ func GetPackagesForSupportedKernelType(kernelType string) (string, map[string][] if _, ok := kernelPackages[kernelType]; ok { return kernelType, kernelPackages, nil } - return "", nil, fmt.Errorf("Unhandled kernel type %s", kernelType) + return "", nil, fmt.Errorf("unhandled kernel type %s", kernelType) } // Resolves a list of supported extensions to the individual packages required diff --git a/pkg/controller/container-runtime-config/container_runtime_config_bootstrap.go b/pkg/controller/container-runtime-config/container_runtime_config_bootstrap.go index 6d8ce422bf..17d09ba95b 100644 --- a/pkg/controller/container-runtime-config/container_runtime_config_bootstrap.go +++ b/pkg/controller/container-runtime-config/container_runtime_config_bootstrap.go @@ -93,7 +93,7 @@ func RunContainerRuntimeBootstrap(templateDir string, crconfigs []*mcfgv1.Contai // we can simplify the logic for the bootstrap generation and avoid some edge cases. func generateBootstrapManagedKeyContainerConfig(pool *mcfgv1.MachineConfigPool, managedKeyExist map[string]bool) (string, error) { if _, ok := managedKeyExist[pool.Name]; ok { - return "", fmt.Errorf("Error found multiple ContainerConfig targeting MachineConfigPool %v. Please apply only one ContainerConfig manifest for each pool during installation", pool.Name) + return "", fmt.Errorf("error found multiple ContainerConfig targeting MachineConfigPool %v. Please apply only one ContainerConfig manifest for each pool during installation", pool.Name) } managedKey, err := ctrlcommon.GetManagedKey(pool, nil, "99", "containerruntime", "") if err != nil { diff --git a/pkg/controller/container-runtime-config/container_runtime_config_controller.go b/pkg/controller/container-runtime-config/container_runtime_config_controller.go index 01f551477d..e0e55eda2b 100644 --- a/pkg/controller/container-runtime-config/container_runtime_config_controller.go +++ b/pkg/controller/container-runtime-config/container_runtime_config_controller.go @@ -780,7 +780,7 @@ func (ctrl *Controller) syncContainerRuntimeConfig(key string) error { // OKD only: Run the migration function at the start of sync if version.IsSCOS() { if err := ctrl.migrateRuncToCrun(); err != nil { - return fmt.Errorf("Error during runc to crun migration: %w", err) + return fmt.Errorf("error during runc to crun migration: %w", err) } } diff --git a/pkg/controller/container-runtime-config/helpers.go b/pkg/controller/container-runtime-config/helpers.go index 30aa0c7453..e0714add46 100644 --- a/pkg/controller/container-runtime-config/helpers.go +++ b/pkg/controller/container-runtime-config/helpers.go @@ -325,7 +325,7 @@ func getManagedKeyCtrCfg(pool *mcfgv1.MachineConfigPool, client mcfgclientset.In if err != nil { key, err := ctrlcommon.GetManagedKey(pool, nil, managedContainerRuntimeConfigKeyPrefix, "containerruntime", getManagedKeyCtrCfgDeprecated(pool)) if err != nil { - klog.Infof("skipping error: %v", fmt.Errorf("error generating managedKey for suffix %s: %v", key, err)) + klog.Infof("skipping error: %v", fmt.Errorf("error generating managedKey for suffix %s: %w", key, err)) continue } if f != key { @@ -1040,13 +1040,13 @@ func policyItemFromSpec(policy apicfgv1.ImageSigstoreVerificationPolicy) (signat case apicfgv1.IdentityMatchPolicyRemapIdentity: identity, err := signature.NewPRMRemapIdentity(string(policy.SignedIdentity.PolicyMatchRemapIdentity.Prefix), string(policy.SignedIdentity.PolicyMatchRemapIdentity.SignedPrefix)) if err != nil { - return nil, fmt.Errorf("error getting signedIdentity for %s: %v", apicfgv1.IdentityMatchPolicyRemapIdentity, err) + return nil, fmt.Errorf("error getting signedIdentity for %s: %w", apicfgv1.IdentityMatchPolicyRemapIdentity, err) } signedIdentity = identity case apicfgv1.IdentityMatchPolicyExactRepository: identity, err := signature.NewPRMExactRepository(string(policy.SignedIdentity.PolicyMatchExactRepository.Repository)) if err != nil { - return nil, fmt.Errorf("error getting signedIdentity for %s: %v", apicfgv1.IdentityMatchPolicyExactRepository, err) + return nil, fmt.Errorf("error getting signedIdentity for %s: %w", apicfgv1.IdentityMatchPolicyExactRepository, err) } signedIdentity = identity case apicfgv1.IdentityMatchPolicyMatchRepository: @@ -1481,7 +1481,7 @@ func updateCredentialProviderConfig(credProviderConfigObject *credentialProvider credProviderConfigsYaml, err := yaml.Marshal(credProviderConfigObject) if err != nil { - return nil, nil, fmt.Errorf("error marshalling credential provider config: %v", err) + return nil, nil, fmt.Errorf("error marshalling credential provider config: %w", err) } return credProviderConfigsYaml, conflictList, nil diff --git a/pkg/controller/drain/drain_controller.go b/pkg/controller/drain/drain_controller.go index 42063f44de..63af0fd5d4 100644 --- a/pkg/controller/drain/drain_controller.go +++ b/pkg/controller/drain/drain_controller.go @@ -220,7 +220,7 @@ func (ctrl *Controller) handleNodeEvent(oldObj, newObj interface{}) { func (ctrl *Controller) enqueueAfter(node *corev1.Node, after time.Duration) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(node) if err != nil { - utilruntime.HandleError(fmt.Errorf("couldn't get key for object %#v: %v", node, err)) + utilruntime.HandleError(fmt.Errorf("couldn't get key for object %#v: %w", node, err)) return } @@ -345,7 +345,7 @@ func (ctrl *Controller) syncNode(key string) error { if nErr != nil { klog.Errorf("Error making MCN for Uncordon failure: %v", err) } - return fmt.Errorf("failed to uncordon node %v: %v", node.Name, err) + return fmt.Errorf("failed to uncordon node %v: %w", node.Name, err) } @@ -392,7 +392,7 @@ func (ctrl *Controller) syncNode(key string) error { daemonconsts.LastAppliedDrainerAnnotationKey: desiredState, } if err := ctrl.setNodeAnnotations(node.Name, annotations); err != nil { - return fmt.Errorf("node %s: failed to set node uncordoned annotation: %v", node.Name, err) + return fmt.Errorf("node %s: failed to set node uncordoned annotation: %w", node.Name, err) } ctrlcommon.UpdateStateMetric(ctrlcommon.MCCSubControllerState, "machine-config-controller-drain", desiredVerb, node.Name) return nil @@ -452,7 +452,7 @@ func (ctrl *Controller) drainNode(node *corev1.Node, drainer *drain.Helper) erro if Nerr != nil { klog.Errorf("Error making MCN for Cordon Failure: %v", Nerr) } - return fmt.Errorf("node %s: failed to cordon: %v", node.Name, err) + return fmt.Errorf("node %s: failed to cordon: %w", node.Name, err) } ctrl.ongoingDrains[node.Name] = time.Now() err := upgrademonitor.GenerateAndApplyMachineConfigNodes(&upgrademonitor.Condition{State: v1.MachineConfigNodeUpdateExecuted, Reason: string(v1.MachineConfigNodeUpdateCordoned), Message: "Cordoned Node as part of update executed phase"}, @@ -567,14 +567,14 @@ func (ctrl *Controller) setNodeAnnotations(nodeName string, annotations map[stri patchBytes, err := strategicpatch.CreateTwoWayMergePatch(oldNode, newNode, corev1.Node{}) if err != nil { - return fmt.Errorf("node %s: failed to create patch for: %v", nodeName, err) + return fmt.Errorf("node %s: failed to create patch for: %w", nodeName, err) } _, err = ctrl.kubeClient.CoreV1().Nodes().Patch(context.TODO(), nodeName, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{}) return err }); err != nil { // may be conflict if max retries were hit - return fmt.Errorf("node %s: unable to update: %v", nodeName, err) + return fmt.Errorf("node %s: unable to update: %w", nodeName, err) } return nil } @@ -622,7 +622,7 @@ func (ctrl *Controller) cordonOrUncordonNode(desired bool, node *corev1.Node, dr errs := kubeErrs.NewAggregate([]error{err, lastErr}) return fmt.Errorf("node %s: failed to %s (%d tries): %v", node.Name, verb, ctrl.cfg.CordonOrUncordonBackoff.Steps, errs) } - return fmt.Errorf("node %s: failed to %s: %v", node.Name, verb, err) + return fmt.Errorf("node %s: failed to %s: %w", node.Name, verb, err) } return nil diff --git a/pkg/controller/kubelet-config/helpers.go b/pkg/controller/kubelet-config/helpers.go index a0593000ac..ed0bc7781b 100644 --- a/pkg/controller/kubelet-config/helpers.go +++ b/pkg/controller/kubelet-config/helpers.go @@ -269,7 +269,7 @@ func getManagedKubeletConfigKey(pool *mcfgv1.MachineConfigPool, client mcfgclien if err != nil { key, err := ctrlcommon.GetManagedKey(pool, nil, managedKubeletConfigKeyPrefix, "kubelet", getManagedKubeletConfigKeyDeprecated(pool)) if err != nil { - klog.Infof("skipping error: %v", fmt.Errorf("error generating managedKey for suffix %s: %v", key, err)) + klog.Infof("skipping error: %v", fmt.Errorf("error generating managedKey for suffix %s: %w", key, err)) continue } if f != key { diff --git a/pkg/controller/kubelet-config/kubelet_config_bootstrap.go b/pkg/controller/kubelet-config/kubelet_config_bootstrap.go index 2dced82bab..bad2e73620 100644 --- a/pkg/controller/kubelet-config/kubelet_config_bootstrap.go +++ b/pkg/controller/kubelet-config/kubelet_config_bootstrap.go @@ -110,7 +110,7 @@ func RunKubeletBootstrap(templateDir string, kubeletConfigs []*mcfgv1.KubeletCon // we can simplify the logic for the bootstrap generation and avoid some edge cases. func generateBootstrapManagedKeyKubelet(pool *mcfgv1.MachineConfigPool, managedKeyExist map[string]bool) (string, error) { if _, ok := managedKeyExist[pool.Name]; ok { - return "", fmt.Errorf("Error found multiple KubeletConfigs targeting MachineConfigPool %v. Please apply only one KubeletConfig manifest for each pool during installation", pool.Name) + return "", fmt.Errorf("error found multiple KubeletConfigs targeting MachineConfigPool %v. Please apply only one KubeletConfig manifest for each pool during installation", pool.Name) } managedKey, err := ctrlcommon.GetManagedKey(pool, nil, "99", "kubelet", "") if err != nil { diff --git a/pkg/controller/kubelet-config/kubelet_config_bootstrap_test.go b/pkg/controller/kubelet-config/kubelet_config_bootstrap_test.go index 1d83e9a5ab..ebca6bc296 100644 --- a/pkg/controller/kubelet-config/kubelet_config_bootstrap_test.go +++ b/pkg/controller/kubelet-config/kubelet_config_bootstrap_test.go @@ -188,7 +188,7 @@ func TestGenerateDefaultManagedKeyKubelet(t *testing.T) { }, masterPool, "", - fmt.Errorf("Error found multiple KubeletConfigs targeting MachineConfigPool master. Please apply only one KubeletConfig manifest for each pool during installation"), + fmt.Errorf("error found multiple KubeletConfigs targeting MachineConfigPool master. Please apply only one KubeletConfig manifest for each pool during installation"), }, } { res, err := generateBootstrapManagedKeyKubelet(tc.pool, managedKeyExist) diff --git a/pkg/controller/kubelet-config/kubelet_config_controller.go b/pkg/controller/kubelet-config/kubelet_config_controller.go index 8776950727..b824a8d490 100644 --- a/pkg/controller/kubelet-config/kubelet_config_controller.go +++ b/pkg/controller/kubelet-config/kubelet_config_controller.go @@ -224,7 +224,7 @@ func (ctrl *Controller) filterAPIServer(apiServer *configv1.APIServer) { // to do them here again. Do a direct get call here in case the node config // lister's cache is empty. if nodeConfig, err := ctrl.configClient.ConfigV1().Nodes().Get(context.TODO(), ctrlcommon.ClusterNodeInstanceName, metav1.GetOptions{}); err != nil { - utilruntime.HandleError(fmt.Errorf("could not get NodeConfigs, err: %v", err)) + utilruntime.HandleError(fmt.Errorf("could not get NodeConfigs, err: %w", err)) } else { ctrl.enqueueNodeConfig(nodeConfig) } @@ -306,7 +306,7 @@ func (ctrl *Controller) deleteKubeletConfig(obj interface{}) { } cfg, ok = tombstone.Obj.(*mcfgv1.KubeletConfig) if !ok { - utilruntime.HandleError(fmt.Errorf("Tombstone contained object that is not a KubeletConfig %#v", obj)) + utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a KubeletConfig %#v", obj)) return } } @@ -787,16 +787,16 @@ func machineConfigFeatureGatesMatchesOriginalFeatureGates(mc *mcfgv1.MachineConf func findMachineConfigKubeletConfig(mc *mcfgv1.MachineConfig) (*kubeletconfigv1beta1.KubeletConfiguration, error) { file, err := findKubeletConfig(mc) if err != nil { - return nil, fmt.Errorf("Error finding kubelet config: %v", err) + return nil, fmt.Errorf("error finding kubelet config: %w", err) } // Extract and decode the encoded data decodedData, err := ctrlcommon.DecodeIgnitionFileContents(file.Contents.Source, file.Contents.Compression) if err != nil { - return nil, fmt.Errorf("Error decoding actual kubelet config: %v", err) + return nil, fmt.Errorf("error decoding actual kubelet config: %w", err) } mckubeConfig, err := DecodeKubeletConfig(decodedData) if err != nil { - return nil, fmt.Errorf("Error decoding actual kubelet config: %v", err) + return nil, fmt.Errorf("error decoding actual kubelet config: %w", err) } return mckubeConfig, nil } diff --git a/pkg/controller/kubelet-config/kubelet_config_features.go b/pkg/controller/kubelet-config/kubelet_config_features.go index 4dc62d4dca..906b998a88 100644 --- a/pkg/controller/kubelet-config/kubelet_config_features.go +++ b/pkg/controller/kubelet-config/kubelet_config_features.go @@ -69,7 +69,7 @@ func (ctrl *Controller) syncFeatureHandler(key string) error { // Grab APIServer to populate TLS settings in the default kubelet config apiServer, err := ctrl.apiserverLister.Get(ctrlcommon.APIServerInstanceName) if err != nil && !errors.IsNotFound(err) { - return fmt.Errorf("could not get the TLSSecurityProfile from %v: %v", ctrlcommon.APIServerInstanceName, err) + return fmt.Errorf("could not get the TLSSecurityProfile from %v: %w", ctrlcommon.APIServerInstanceName, err) } for _, pool := range mcpPools { @@ -132,7 +132,7 @@ func (ctrl *Controller) syncFeatureHandler(key string) error { func (ctrl *Controller) enqueueFeature(feat *osev1.FeatureGate) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(feat) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %w", feat, err)) + utilruntime.HandleError(fmt.Errorf("couldn't get key for object %#v: %w", feat, err)) return } ctrl.featureQueue.Add(key) @@ -158,12 +158,12 @@ func (ctrl *Controller) deleteFeature(obj interface{}) { if !ok { tombstone, ok := obj.(cache.DeletedFinalStateUnknown) if !ok { - utilruntime.HandleError(fmt.Errorf("Couldn't get object from tombstone %#v", obj)) + utilruntime.HandleError(fmt.Errorf("couldn't get object from tombstone %#v", obj)) return } features, ok = tombstone.Obj.(*osev1.FeatureGate) if !ok { - utilruntime.HandleError(fmt.Errorf("Tombstone contained object that is not a KubeletConfig %#v", obj)) + utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a KubeletConfig %#v", obj)) return } } diff --git a/pkg/controller/kubelet-config/kubelet_config_nodes.go b/pkg/controller/kubelet-config/kubelet_config_nodes.go index 4e4ccc37d8..e22b2398d5 100644 --- a/pkg/controller/kubelet-config/kubelet_config_nodes.go +++ b/pkg/controller/kubelet-config/kubelet_config_nodes.go @@ -90,7 +90,7 @@ func (ctrl *Controller) syncNodeConfigHandler(key string) error { // Grab APIServer to populate TLS settings in the default kubelet config apiServer, err := ctrl.apiserverLister.Get(ctrlcommon.APIServerInstanceName) if err != nil && !errors.IsNotFound(err) { - return fmt.Errorf("could not get the TLSSecurityProfile from %v: %v", ctrlcommon.APIServerInstanceName, err) + return fmt.Errorf("could not get the TLSSecurityProfile from %v: %w", ctrlcommon.APIServerInstanceName, err) } for _, pool := range mcpPools { @@ -157,7 +157,7 @@ func (ctrl *Controller) syncNodeConfigHandler(key string) error { } return err }); err != nil { - return fmt.Errorf("Could not Create/Update MachineConfig, error: %w", err) + return fmt.Errorf("could not Create/Update MachineConfig, error: %w", err) } klog.Infof("Applied Node configuration %v on MachineConfigPool %v", key, pool.Name) ctrlcommon.UpdateStateMetric(ctrlcommon.MCCSubControllerState, "machine-config-controller-kubelet-config", "Sync NodeConfig", pool.Name) @@ -189,7 +189,7 @@ func (ctrl *Controller) syncNodeConfigHandler(key string) error { func (ctrl *Controller) enqueueNodeConfig(nodeConfig *osev1.Node) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(nodeConfig) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %w", nodeConfig, err)) + utilruntime.HandleError(fmt.Errorf("couldn't get key for object %#v: %w", nodeConfig, err)) return } ctrl.nodeConfigQueue.Add(key) @@ -199,12 +199,12 @@ func (ctrl *Controller) updateNodeConfig(old, cur interface{}) { isValidWorkerLatencyProfleTransition := true oldNode, ok := old.(*osev1.Node) if !ok { - utilruntime.HandleError(fmt.Errorf("Couldn't retrieve the old object from the Update Node Config event %#v", old)) + utilruntime.HandleError(fmt.Errorf("couldn't retrieve the old object from the Update Node Config event %#v", old)) return } newNode, ok := cur.(*osev1.Node) if !ok { - utilruntime.HandleError(fmt.Errorf("Couldn't retrieve the new object from the Update Node Config event %#v", cur)) + utilruntime.HandleError(fmt.Errorf("couldn't retrieve the new object from the Update Node Config event %#v", cur)) return } if newNode.Name != ctrlcommon.ClusterNodeInstanceName { @@ -241,7 +241,7 @@ func (ctrl *Controller) updateNodeConfig(old, cur interface{}) { func (ctrl *Controller) addNodeConfig(obj interface{}) { nodeConfig, ok := obj.(*osev1.Node) if !ok { - utilruntime.HandleError(fmt.Errorf("Couldn't retrieve the object from the Add Node Config event %#v", obj)) + utilruntime.HandleError(fmt.Errorf("couldn't retrieve the object from the Add Node Config event %#v", obj)) return } if nodeConfig.Name != ctrlcommon.ClusterNodeInstanceName { @@ -259,12 +259,12 @@ func (ctrl *Controller) deleteNodeConfig(obj interface{}) { if !ok { tombstone, ok := obj.(cache.DeletedFinalStateUnknown) if !ok { - utilruntime.HandleError(fmt.Errorf("Couldn't get object from tombstone %#v", obj)) + utilruntime.HandleError(fmt.Errorf("couldn't get object from tombstone %#v", obj)) return } nodeConfig, ok = tombstone.Obj.(*osev1.Node) if !ok { - utilruntime.HandleError(fmt.Errorf("Tombstone contained object that is not a NodeConfig %#v", obj)) + utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a NodeConfig %#v", obj)) return } } diff --git a/pkg/controller/node/node_controller.go b/pkg/controller/node/node_controller.go index ced43a48d7..aa604f13f0 100644 --- a/pkg/controller/node/node_controller.go +++ b/pkg/controller/node/node_controller.go @@ -496,7 +496,7 @@ func (ctrl *Controller) addMachineOSConfig(obj interface{}) { klog.V(4).Infof("Adding MachineOSConfig %s", curMOSC.Name) mcp, err := ctrl.mcpLister.Get(curMOSC.Spec.MachineConfigPool.Name) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get MachineConfigPool from MachineOSConfig %#v", curMOSC)) + utilruntime.HandleError(fmt.Errorf("couldn't get MachineConfigPool from MachineOSConfig %#v", curMOSC)) return } klog.V(4).Infof("MachineConfigPool %s opt in to OCL", mcp.Name) @@ -513,7 +513,7 @@ func (ctrl *Controller) updateMachineOSConfig(old, cur interface{}) { klog.V(4).Infof("Updating MachineOSConfig %s", oldMOSC.Name) mcp, err := ctrl.mcpLister.Get(curMOSC.Spec.MachineConfigPool.Name) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get Machine Config Pool from MachineOSConfig %#v", curMOSC)) + utilruntime.HandleError(fmt.Errorf("couldn't get Machine Config Pool from MachineOSConfig %#v", curMOSC)) return } klog.V(4).Infof("Image is ready for MachineConfigPool %s", mcp.Name) @@ -538,7 +538,7 @@ func (ctrl *Controller) deleteMachineOSConfig(cur interface{}) { mcp, err := ctrl.mcpLister.Get(curMOSC.Spec.MachineConfigPool.Name) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get MachineConfigPool from MachineOSConfig %#v", curMOSC)) + utilruntime.HandleError(fmt.Errorf("couldn't get MachineConfigPool from MachineOSConfig %#v", curMOSC)) return } ctrl.enqueueMachineConfigPool(mcp) @@ -577,7 +577,7 @@ func (ctrl *Controller) addMachineOSBuild(obj interface{}) { mcp, err := ctrl.mcpLister.Get(poolName) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get MachineConfigPool from MachineOSBuild %#v: %v", curMOSB, err)) + utilruntime.HandleError(fmt.Errorf("couldn't get MachineConfigPool from MachineOSBuild %#v: %w", curMOSB, err)) return } klog.V(4).Infof("MachineOSBuild %s affects MachineConfigPool %s", curMOSB.Name, mcp.Name) @@ -609,7 +609,7 @@ func (ctrl *Controller) updateMachineOSBuild(old, cur interface{}) { mcp, err := ctrl.mcpLister.Get(poolName) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get MachineConfigPool from MachineOSBuild %#v: %v", curMOSB, err)) + utilruntime.HandleError(fmt.Errorf("couldn't get MachineConfigPool from MachineOSBuild %#v: %w", curMOSB, err)) return } klog.V(4).Infof("MachineOSBuild %s status changed for MachineConfigPool %s", curMOSB.Name, mcp.Name) @@ -629,7 +629,7 @@ func (ctrl *Controller) addMachineConfigNode(obj interface{}) { mcp, err := ctrl.mcpLister.Get(poolName) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get MachineConfigPool from MachineConfigNode %v: %v", curMCN, err)) + utilruntime.HandleError(fmt.Errorf("couldn't get MachineConfigPool from MachineConfigNode %v: %w", curMCN, err)) return } klog.V(4).Infof("MachineConfigNode %s affects MachineConfigPool %s", curMCN.Name, mcp.Name) @@ -654,7 +654,7 @@ func (ctrl *Controller) updateMachineConfigNode(old, cur interface{}) { mcp, err := ctrl.mcpLister.Get(curPoolName) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get MachineConfigPool from MachineConfigNode %v: %v", curMCN.Name, err)) + utilruntime.HandleError(fmt.Errorf("couldn't get MachineConfigPool from MachineConfigNode %v: %w", curMCN.Name, err)) return } klog.V(4).Infof("MachineConfigNode %s status changed for MachineConfigPool %s", curMCN.Name, mcp.Name) @@ -685,7 +685,7 @@ func (ctrl *Controller) deleteMachineConfigNode(obj interface{}) { } mcp, err := ctrl.mcpLister.Get(mcpName) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get MachineConfigPool from MachineConfigNode %v", curMCN.Name)) + utilruntime.HandleError(fmt.Errorf("couldn't get MachineConfigPool from MachineConfigNode %v", curMCN.Name)) return } ctrl.enqueueMachineConfigPool(mcp) @@ -1857,7 +1857,7 @@ func (ctrl *Controller) setUpdateInProgressTaint(ctx context.Context, nodeName s patchBytes, err := strategicpatch.CreateTwoWayMergePatch(oldData, newData, corev1.Node{}) if err != nil { - return fmt.Errorf("failed to create patch for node %q: %v", nodeName, err) + return fmt.Errorf("failed to create patch for node %q: %w", nodeName, err) } _, err = ctrl.kubeClient.CoreV1().Nodes().Patch(ctx, nodeName, types.StrategicMergePatchType, patchBytes, metav1.PatchOptions{}) return err @@ -1910,7 +1910,7 @@ func maxUnavailable(pool *mcfgv1.MachineConfigPool, nodes []*corev1.Node) (int, } maxunavail, err := intstrutil.GetScaledValueFromIntOrPercent(&intOrPercent, len(nodes), false) if err != nil { - return 0, fmt.Errorf("\"maxUnavailable\" %v", err) + return 0, fmt.Errorf("maxUnavailable: %w", err) } if maxunavail == 0 { maxunavail = 1 diff --git a/pkg/controller/render/render_controller.go b/pkg/controller/render/render_controller.go index befabeb95b..7aea57ea39 100644 --- a/pkg/controller/render/render_controller.go +++ b/pkg/controller/render/render_controller.go @@ -207,12 +207,12 @@ func (ctrl *Controller) deleteMachineConfigPool(obj interface{}) { if !ok { tombstone, ok := obj.(cache.DeletedFinalStateUnknown) if !ok { - utilruntime.HandleError(fmt.Errorf("Couldn't get object from tombstone %#v", obj)) + utilruntime.HandleError(fmt.Errorf("couldn't get object from tombstone %#v", obj)) return } pool, ok = tombstone.Obj.(*mcfgv1.MachineConfigPool) if !ok { - utilruntime.HandleError(fmt.Errorf("Tombstone contained object that is not a MachineConfigPool %#v", obj)) + utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a MachineConfigPool %#v", obj)) return } } @@ -311,12 +311,12 @@ func (ctrl *Controller) deleteMachineConfig(obj interface{}) { if !ok { tombstone, ok := obj.(cache.DeletedFinalStateUnknown) if !ok { - utilruntime.HandleError(fmt.Errorf("Couldn't get object from tombstone %#v", obj)) + utilruntime.HandleError(fmt.Errorf("couldn't get object from tombstone %#v", obj)) return } mc, ok = tombstone.Obj.(*mcfgv1.MachineConfig) if !ok { - utilruntime.HandleError(fmt.Errorf("Tombstone contained object that is not a MachineConfig %#v", obj)) + utilruntime.HandleError(fmt.Errorf("tombstone contained object that is not a MachineConfig %#v", obj)) return } } @@ -395,7 +395,7 @@ func (ctrl *Controller) getPoolsForMachineConfig(config *mcfgv1.MachineConfig) ( func (ctrl *Controller) enqueue(pool *mcfgv1.MachineConfigPool) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(pool) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %w", pool, err)) + utilruntime.HandleError(fmt.Errorf("couldn't get key for object %#v: %w", pool, err)) return } @@ -405,7 +405,7 @@ func (ctrl *Controller) enqueue(pool *mcfgv1.MachineConfigPool) { func (ctrl *Controller) enqueueRateLimited(pool *mcfgv1.MachineConfigPool) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(pool) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %w", pool, err)) + utilruntime.HandleError(fmt.Errorf("couldn't get key for object %#v: %w", pool, err)) return } @@ -416,7 +416,7 @@ func (ctrl *Controller) enqueueRateLimited(pool *mcfgv1.MachineConfigPool) { func (ctrl *Controller) enqueueAfter(pool *mcfgv1.MachineConfigPool, after time.Duration) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(pool) if err != nil { - utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %w", pool, err)) + utilruntime.HandleError(fmt.Errorf("couldn't get key for object %#v: %w", pool, err)) return } @@ -760,10 +760,10 @@ func generateRenderedMachineConfig(pool *mcfgv1.MachineConfigPool, configs []*mc // https://bugzilla.redhat.com/show_bug.cgi?id=1879099 if genver, ok := cconfig.Annotations[daemonconsts.GeneratedByVersionAnnotationKey]; ok { if genver != version.Raw { - return nil, fmt.Errorf("Ignoring controller config generated from %s (my version: %s)", genver, version.Raw) + return nil, fmt.Errorf("ignoring controller config generated from %s (my version: %s)", genver, version.Raw) } } else { - return nil, fmt.Errorf("Ignoring controller config generated without %s annotation (my version: %s)", daemonconsts.GeneratedByVersionAnnotationKey, version.Raw) + return nil, fmt.Errorf("ignoring controller config generated without %s annotation (my version: %s)", daemonconsts.GeneratedByVersionAnnotationKey, version.Raw) } // As an additional check, we should wait until all MCO-owned configs have been regenerated by the newest controller, @@ -771,7 +771,7 @@ func generateRenderedMachineConfig(pool *mcfgv1.MachineConfigPool, configs []*mc for _, config := range configs { generatedByControllerVersion := config.Annotations[ctrlcommon.GeneratedByControllerVersionAnnotationKey] if generatedByControllerVersion != "" && generatedByControllerVersion != version.Hash { - return nil, fmt.Errorf("Ignoring MC %s generated by older version %s (my version: %s)", config.Name, generatedByControllerVersion, version.Hash) + return nil, fmt.Errorf("ignoring MC %s generated by older version %s (my version: %s)", config.Name, generatedByControllerVersion, version.Hash) } } diff --git a/pkg/controller/template/render.go b/pkg/controller/template/render.go index e283217e2c..39492770f9 100644 --- a/pkg/controller/template/render.go +++ b/pkg/controller/template/render.go @@ -765,7 +765,7 @@ func cloudPlatformLoadBalancerIPs(cfg RenderConfig, lbType LoadBalancerType) (in case ingressLB: return cfg.Infra.Status.PlatformStatus.GCP.CloudLoadBalancerConfig.ClusterHosted.IngressLoadBalancerIPs, nil default: - return nil, fmt.Errorf("Invalid GCP Load Balancer Type provided : %s", lbType) + return nil, fmt.Errorf("invalid GCP Load Balancer Type provided : %s", lbType) } case absentLBIPState: @@ -784,7 +784,7 @@ func cloudPlatformLoadBalancerIPs(cfg RenderConfig, lbType LoadBalancerType) (in case ingressLB: return cfg.Infra.Status.PlatformStatus.AWS.CloudLoadBalancerConfig.ClusterHosted.IngressLoadBalancerIPs, nil default: - return nil, fmt.Errorf("Invalid AWS Load Balancer Type provided : %s", lbType) + return nil, fmt.Errorf("invalid AWS Load Balancer Type provided : %s", lbType) } case absentLBIPState: return nil, fmt.Errorf("AWS %s Load Balancer IPs unavailable when the DNSType is ClusterHosted", lbType) @@ -802,10 +802,10 @@ func cloudPlatformLoadBalancerIPs(cfg RenderConfig, lbType LoadBalancerType) (in case ingressLB: return cfg.Infra.Status.PlatformStatus.Azure.CloudLoadBalancerConfig.ClusterHosted.IngressLoadBalancerIPs, nil default: - return nil, fmt.Errorf("Invalid Azure Load Balancer Type provided : %s", lbType) + return nil, fmt.Errorf("invalid Azure Load Balancer Type provided : %s", lbType) } case absentLBIPState: - return nil, fmt.Errorf("Azure %s Load Balancer IPs unavailable when the DNSType is ClusterHosted", lbType) + return nil, fmt.Errorf("azure %s Load Balancer IPs unavailable when the DNSType is ClusterHosted", lbType) default: return nil, fmt.Errorf("") } diff --git a/pkg/daemon/bootc.go b/pkg/daemon/bootc.go index f07e62c542..63bef8113d 100644 --- a/pkg/daemon/bootc.go +++ b/pkg/daemon/bootc.go @@ -167,7 +167,7 @@ func (b *BootcClient) Initialize() error { // make sure we get access to them when we Initialize err := useMergedPullSecrets(bootcSystem) if err != nil { - return fmt.Errorf("Error while ensuring access to pull secrets: %w", err) + return fmt.Errorf("error while ensuring access to pull secrets: %w", err) } return nil } @@ -210,7 +210,7 @@ func (b *BootcClient) GetBootedImageInfo() (*BootedImageInfo, error) { func (b *BootcClient) Switch(imgURL string) error { // Try to re-link the merged pull secrets if they exist, since it could have been populated without a daemon reboot if err := useMergedPullSecrets(bootcSystem); err != nil { - return fmt.Errorf("Error while ensuring access to pull secrets: %w", err) + return fmt.Errorf("error while ensuring access to pull secrets: %w", err) } klog.Infof("Executing switch to %s", imgURL) return runBootc("switch", imgURL) diff --git a/pkg/daemon/certificate_writer.go b/pkg/daemon/certificate_writer.go index d2e0095f57..447d9fcb0a 100644 --- a/pkg/daemon/certificate_writer.go +++ b/pkg/daemon/certificate_writer.go @@ -98,7 +98,7 @@ func (dn *Daemon) syncControllerConfigHandler(key string) error { controllerConfig, err := dn.ccLister.Get(ctrlcommon.ControllerConfigName) if err != nil { - return fmt.Errorf("could not get ControllerConfig: %v", err) + return fmt.Errorf("could not get ControllerConfig: %w", err) } if dn.node == nil { @@ -148,7 +148,7 @@ func (dn *Daemon) syncControllerConfigHandler(key string) error { if kcBytes != nil { err = yaml.Unmarshal(kcBytes, &onDiskKC) if err != nil { - return fmt.Errorf("could not unmarshal kubeconfig into struct. Data: %s, Error: %v", string(kcBytes), err) + return fmt.Errorf("could not unmarshal kubeconfig into struct. Data: %s, Error: %w", string(kcBytes), err) } kubeConfigDiff = !bytes.Equal(bytes.TrimSpace(onDiskKC.Clusters[0].Cluster.CertificateAuthorityData), bytes.TrimSpace(data)) @@ -217,7 +217,7 @@ func (dn *Daemon) syncControllerConfigHandler(key string) error { onDiskKC.Clusters[0].Cluster.CertificateAuthorityData = []byte(strings.Join(fullCA, "")) newData, err = yaml.Marshal(onDiskKC) if err != nil { - return fmt.Errorf("could not marshal kubeconfig into bytes. Error: %v", err) + return fmt.Errorf("could not marshal kubeconfig into bytes. Error: %w", err) } pathToData[kubeConfigPath] = newData @@ -303,7 +303,7 @@ func (dn *Daemon) syncControllerConfigHandler(key string) error { klog.Warningf("Failed to get kubeconfig file: %v", err) return err } else if err != nil { - return fmt.Errorf("unexpected error reading kubeconfig file, %v", err) + return fmt.Errorf("unexpected error reading kubeconfig file, %w", err) } kubeletKC := clientcmdv1.Config{} err = yaml.Unmarshal(f, &kubeletKC) @@ -314,7 +314,7 @@ func (dn *Daemon) syncControllerConfigHandler(key string) error { kubeletKC.Clusters[0].Cluster.CertificateAuthorityData = onDiskKC.Clusters[0].Cluster.CertificateAuthorityData newData, err := yaml.Marshal(kubeletKC) if err != nil { - return fmt.Errorf("could not marshal kubeconfig into bytes. Error: %v", err) + return fmt.Errorf("could not marshal kubeconfig into bytes. Error: %w", err) } filesToWrite := make(map[string][]byte) filesToWrite["/var/lib/kubelet/kubeconfig"] = newData @@ -352,7 +352,7 @@ func (dn *Daemon) syncInternalRegistryPullSecrets(controllerConfig *mcfgv1.Contr if controllerConfig == nil { cfg, err := dn.ccLister.Get(ctrlcommon.ControllerConfigName) if err != nil { - return fmt.Errorf("could not get ControllerConfig: %v", err) + return fmt.Errorf("could not get ControllerConfig: %w", err) } controllerConfig = cfg diff --git a/pkg/daemon/daemon.go b/pkg/daemon/daemon.go index 20467924a0..9bb0fbeb12 100644 --- a/pkg/daemon/daemon.go +++ b/pkg/daemon/daemon.go @@ -188,7 +188,7 @@ type IrreconcilableReporter interface { CheckReportIrreconcilableDifferences(targetMachineConfig *mcfgv1.MachineConfig, nodeName string) error } -var ErrAuxiliary = errors.New("Error from auxiliary packages") +var ErrAuxiliary = errors.New("error from auxiliary packages") const ( // pathSystemd is the path systemd modifiable units, services, etc.. reside @@ -1431,7 +1431,7 @@ func (dn *Daemon) Run(stopCh <-chan struct{}, exitCh <-chan error, errCh chan er func (dn *Daemon) kubeletRebootstrap(ctx context.Context) error { dn.deferKubeletRestart = false if err := os.Remove("/var/lib/kubelet/kubeconfig"); err != nil { - return fmt.Errorf("could not remove kubelet's kubeconfig file: %v", err) + return fmt.Errorf("could not remove kubelet's kubeconfig file: %w", err) } if err := runCmdSync("systemctl", "restart", "kubelet"); err != nil { return err @@ -1442,12 +1442,12 @@ func (dn *Daemon) kubeletRebootstrap(ctx context.Context) error { klog.Warningf("Failed to get kubeconfig file: %v", err) return false, nil } else if err != nil { - return false, fmt.Errorf("unexpected error reading kubeconfig file, %v", err) + return false, fmt.Errorf("unexpected error reading kubeconfig file, %w", err) } return true, nil }); err != nil { - return fmt.Errorf("something went wrong while waiting for kubeconfig file to generate: %v", err) + return fmt.Errorf("something went wrong while waiting for kubeconfig file to generate: %w", err) } return nil @@ -2088,7 +2088,7 @@ func PersistNetworkInterfaces(osRoot string) error { rpmOstreeArgs = append(rpmOstreeArgs, "--remove", karg) } default: - return fmt.Errorf("Unexpected host OS %s", hostos.ToPrometheusLabel()) + return fmt.Errorf("unexpected host OS %s", hostos.ToPrometheusLabel()) } if osRoot != "/" { @@ -2606,7 +2606,7 @@ func (dn *Daemon) completeUpdate(desiredConfigName string) error { dn.nodeWriter.Eventf(corev1.EventTypeWarning, "FailedToUncordon", failMsg) return errors.New(failMsg) } - return fmt.Errorf("something went wrong while attempting to uncordon node: %v", err) + return fmt.Errorf("something went wrong while attempting to uncordon node: %w", err) } logSystem("Update completed for config %s and node has been successfully uncordoned", desiredConfigName) diff --git a/pkg/daemon/drain.go b/pkg/daemon/drain.go index 23cd1ec20c..e34405abfb 100644 --- a/pkg/daemon/drain.go +++ b/pkg/daemon/drain.go @@ -93,7 +93,7 @@ func (dn *Daemon) performDrain() error { // TODO (jerzhang): definitely don't have to block here, but as an initial PoC, this is easier if err := dn.nodeWriter.SetDesiredDrainer(desiredDrainAnnotationValue); err != nil { - return fmt.Errorf("Could not set drain annotation: %w", err) + return fmt.Errorf("could not set drain annotation: %w", err) } ctx := context.TODO() @@ -116,7 +116,7 @@ func (dn *Daemon) performDrain() error { return errors.New(failMsg) } - return fmt.Errorf("Something went wrong while attempting to drain node: %v", err) + return fmt.Errorf("something went wrong while attempting to drain node: %w", err) } logSystem("drain complete") diff --git a/pkg/daemon/image_manager_helper.go b/pkg/daemon/image_manager_helper.go index 6848d523ca..f7d07b45d0 100644 --- a/pkg/daemon/image_manager_helper.go +++ b/pkg/daemon/image_manager_helper.go @@ -85,7 +85,7 @@ func validateImageSystem(imgSys imageSystem) error { return nil } - return fmt.Errorf("Invalid system %s! Valid systems are: %v", imgSys, sets.List(valid)) + return fmt.Errorf("invalid system %s! Valid systems are: %v", imgSys, sets.List(valid)) } // linkAuthFile gives rpm-ostree / bootc client access to secrets in the file located at `path` by symlinking so that diff --git a/pkg/daemon/internalreleaseimage/internalreleaseimage_fakeregistry_test.go b/pkg/daemon/internalreleaseimage/internalreleaseimage_fakeregistry_test.go index 1fc7d258f9..c338ca45ab 100644 --- a/pkg/daemon/internalreleaseimage/internalreleaseimage_fakeregistry_test.go +++ b/pkg/daemon/internalreleaseimage/internalreleaseimage_fakeregistry_test.go @@ -84,7 +84,7 @@ func (fr *FakeIRIRegistry) Start() error { func (fr *FakeIRIRegistry) newTLSServer(handler http.HandlerFunc) error { listener, err := net.Listen("tcp", "127.0.0.1:22625") if err != nil { - return fmt.Errorf("failed to bind port: %v", err) + return fmt.Errorf("failed to bind port: %w", err) } fr.server = httptest.NewUnstartedServer(handler) fr.server.Listener = listener diff --git a/pkg/daemon/internalreleaseimage/iriregistry.go b/pkg/daemon/internalreleaseimage/iriregistry.go index 0f9ffd0f93..593f92e1a1 100644 --- a/pkg/daemon/internalreleaseimage/iriregistry.go +++ b/pkg/daemon/internalreleaseimage/iriregistry.go @@ -96,7 +96,7 @@ func (r *iriRegistry) query(endpoint string, headers ...map[string]string) (*htt } resp, err := r.client.Do(req) if err != nil { - return nil, fmt.Errorf("registry query %s failed with error: %v", regURL, err) + return nil, fmt.Errorf("registry query %s failed with error: %w", regURL, err) } if resp.StatusCode != http.StatusOK { diff --git a/pkg/daemon/irreconcilable_diff_reporter.go b/pkg/daemon/irreconcilable_diff_reporter.go index e0b1ab63d5..e1ca1cb9bb 100644 --- a/pkg/daemon/irreconcilable_diff_reporter.go +++ b/pkg/daemon/irreconcilable_diff_reporter.go @@ -241,7 +241,7 @@ func (r *IrreconcilableReporterImpl) CheckReportIrreconcilableDifferences( diffs, err := r.diffGenerator.GenerateReport(targetMachineConfig) if err != nil { - return fmt.Errorf("error generating the irreconcilable differences list of changes. %v", err) + return fmt.Errorf("error generating the irreconcilable differences list of changes. %w", err) } mcNode.Status.IrreconcilableChanges = diffs diff --git a/pkg/daemon/podman.go b/pkg/daemon/podman.go index 32c6d34193..5bdd29d358 100644 --- a/pkg/daemon/podman.go +++ b/pkg/daemon/podman.go @@ -56,7 +56,7 @@ func (p *PodmanExecInterface) GetPodmanImageInfoByReference(reference string) (* } var podmanInfos []PodmanImageInfo if err := json.Unmarshal(output, &podmanInfos); err != nil { - return nil, fmt.Errorf("failed to decode podman image ls output: %v", err) + return nil, fmt.Errorf("failed to decode podman image ls output: %w", err) } if len(podmanInfos) == 0 { @@ -85,7 +85,7 @@ func (p *PodmanExecInterface) GetPodmanInfo() (*PodmanInfo, error) { } var podmanInfo PodmanInfo if err := json.Unmarshal(output, &podmanInfo); err != nil { - return nil, fmt.Errorf("failed to decode podman system info output: %v", err) + return nil, fmt.Errorf("failed to decode podman system info output: %w", err) } return &podmanInfo, nil } diff --git a/pkg/daemon/rpm-ostree.go b/pkg/daemon/rpm-ostree.go index 785682b1db..73a5fb01df 100644 --- a/pkg/daemon/rpm-ostree.go +++ b/pkg/daemon/rpm-ostree.go @@ -196,7 +196,7 @@ func (r *RpmOstreeClient) IsNewEnoughForLayering() (bool, error) { func (r *RpmOstreeClient) RebaseLayered(imgURL string) error { // Try to re-link the merged pull secrets if they exist, since it could have been populated without a daemon reboot if err := useMergedPullSecrets(rpmOstreeSystem); err != nil { - return fmt.Errorf("Error while ensuring access to pull secrets: %w", err) + return fmt.Errorf("error while ensuring access to pull secrets: %w", err) } klog.Infof("Executing rebase to %s", imgURL) return runRpmOstree("rebase", "--experimental", "ostree-unverified-registry:"+imgURL) @@ -206,7 +206,7 @@ func (r *RpmOstreeClient) RebaseLayered(imgURL string) error { func (r *RpmOstreeClient) RebaseLayeredFromContainerStorage(podmanImageInfo *PodmanImageInfo) error { // Try to re-link the merged pull secrets if they exist, since it could have been populated without a daemon reboot if err := useMergedPullSecrets(rpmOstreeSystem); err != nil { - return fmt.Errorf("Error while ensuring access to pull secrets: %w", err) + return fmt.Errorf("error while ensuring access to pull secrets: %w", err) } defer func() { diff --git a/pkg/daemon/update.go b/pkg/daemon/update.go index 98207b737a..604714e89c 100644 --- a/pkg/daemon/update.go +++ b/pkg/daemon/update.go @@ -2528,11 +2528,11 @@ func (dn *Daemon) atomicallyWriteSSHKey(authKeyPath, keys string) error { if userInfo, err := user.LookupId(fmt.Sprint(uid)); err == nil { if userInfo.Username != constants.CoreUserName { if err := os.RemoveAll(constants.CoreUserSSHPath); err != nil { - return fmt.Errorf("Failed to remove existing root user owned .ssh path %s:%w", constants.CoreUserSSHPath, err) + return fmt.Errorf("failed to remove existing root user owned .ssh path %s:%w", constants.CoreUserSSHPath, err) } } } else { - return fmt.Errorf("Failed to look up the user of the .ssh path %s:%w", constants.CoreUserSSHPath, err) + return fmt.Errorf("failed to look up the user of the .ssh path %s:%w", constants.CoreUserSSHPath, err) } } else if !os.IsNotExist(err) { return err @@ -2559,7 +2559,7 @@ func (dn *Daemon) atomicallyWriteSSHKey(authKeyPath, keys string) error { func getUserPasswordHash(user string) (string, error) { shadowOut, err := exec.Command("getent", "shadow", user).CombinedOutput() if err != nil { - return "", fmt.Errorf("Failed to check password hash for %s: %w", user, err) + return "", fmt.Errorf("failed to check password hash for %s: %w", user, err) } shadowSlice := strings.SplitN(strings.TrimSpace(string(shadowOut)), ":", 3) if len(shadowSlice) >= 2 { @@ -2605,7 +2605,7 @@ func (dn *Daemon) SetPasswordHash(newUsers, oldUsers []ign3types.PasswdUser) err } if out, err := exec.Command("usermod", "-p", pwhash, u.Name).CombinedOutput(); err != nil { - return fmt.Errorf("Failed to reset password for %s: %s:%w", u.Name, out, err) + return fmt.Errorf("failed to reset password for %s: %s:%w", u.Name, out, err) } klog.Info("Password has been configured") } @@ -2622,10 +2622,10 @@ func (dn *Daemon) updateKubeConfigPermission() error { // Checking if kubeconfig is existed in the expected path: if _, err := os.Stat(kubeConfigPath); err == nil { if err := os.Chmod(kubeConfigPath, 0o600); err != nil { - return fmt.Errorf("Failed to reset permission for %s:%w", kubeConfigPath, err) + return fmt.Errorf("failed to reset permission for %s:%w", kubeConfigPath, err) } } else { - return fmt.Errorf("Cannot stat %s: %w", kubeConfigPath, err) + return fmt.Errorf("cannot stat %s: %w", kubeConfigPath, err) } return nil } @@ -2715,7 +2715,7 @@ func deconfigureUser(user ign3types.PasswdUser) error { user.PasswordHash = &pwhash if out, err := exec.Command("usermod", "-p", *user.PasswordHash, user.Name).CombinedOutput(); err != nil { - return fmt.Errorf("Failed to change password for %s: %s:%w", user.Name, out, err) + return fmt.Errorf("failed to change password for %s: %s:%w", user.Name, out, err) } return nil } @@ -2985,7 +2985,7 @@ func (dn *Daemon) updateLayeredOS(config *mcfgv1.MachineConfig) error { klog.Errorf("Error setting ImagePulledFromRegistry condition to false: %v", mcnErr) } } - return fmt.Errorf("Failed to update OS to %s after retries: %w", newURL, err) + return fmt.Errorf("failed to update OS to %s after retries: %w", newURL, err) } // Report ImagePulledFromRegistry condition as true (success) diff --git a/pkg/operator/bootstrap.go b/pkg/operator/bootstrap.go index c0b9bed742..459143e431 100644 --- a/pkg/operator/bootstrap.go +++ b/pkg/operator/bootstrap.go @@ -27,12 +27,12 @@ func RenderBootstrap( ) error { dependencies, err := NewBootstrapDependencies(dependenciesFiles) if err != nil { - return fmt.Errorf("error parsing dependencies for MCO bootstrap: %w", err) + return fmt.Errorf("parsing dependencies for MCO bootstrap: %w", err) } config, err := buildSpec(dependencies, imgs, releaseImage) if err != nil { - return fmt.Errorf("error building spec for MCO bootstrap: %w", err) + return fmt.Errorf("building spec for MCO bootstrap: %w", err) } manifests := []manifest{ diff --git a/pkg/operator/osimagestream_ocp.go b/pkg/operator/osimagestream_ocp.go index cf51b33021..6926e4c5b0 100644 --- a/pkg/operator/osimagestream_ocp.go +++ b/pkg/operator/osimagestream_ocp.go @@ -58,7 +58,7 @@ func (optr *Operator) updateOSImageStream(existingOSImageStream *mcfgv1.OSImageS currentDefault := existingOSImageStream.Status.DefaultStream if currentDefault != requestedDefault { if _, err := osimagestream.GetOSImageStreamSetByName(existingOSImageStream, requestedDefault); err != nil { - return fmt.Errorf("error syncing default OSImageStream with OSImageStream %s: %v", requestedDefault, err) + return fmt.Errorf("syncing default OSImageStream with OSImageStream %s: %w", requestedDefault, err) } // DeepCopy to avoid mutating the shared informer cache @@ -68,7 +68,7 @@ func (optr *Operator) updateOSImageStream(existingOSImageStream *mcfgv1.OSImageS MachineconfigurationV1(). OSImageStreams(). UpdateStatus(context.TODO(), osImageStream, metav1.UpdateOptions{}); err != nil { - return fmt.Errorf("error updating the default OSImageStream status: %w", err) + return fmt.Errorf("updating the default OSImageStream status: %w", err) } klog.Infof("OSImageStream default has changed from %s to %s", currentDefault, requestedDefault) @@ -82,11 +82,11 @@ func (optr *Operator) buildOSImageStream(existingOSImageStream *mcfgv1.OSImageSt // Get the release payload image from ClusterVersion clusterVersion, err := osimagestream.GetClusterVersion(optr.clusterVersionLister) if err != nil { - return fmt.Errorf("error getting cluster version for OSImageStream inspection: %w", err) + return fmt.Errorf("getting cluster version for OSImageStream inspection: %w", err) } image, err := osimagestream.GetReleasePayloadImage(clusterVersion) if err != nil { - return fmt.Errorf("error getting the Release Image digest from the ClusterVersion for OSImageStream sync: %w", err) + return fmt.Errorf("getting the Release Image digest from the ClusterVersion for OSImageStream sync: %w", err) } // The original cluster version is used as a fallback to infer the default stream @@ -139,7 +139,7 @@ func (optr *Operator) buildOSImageStream(existingOSImageStream *mcfgv1.OSImageSt InstallVersion: installVersion, }) if err != nil { - return fmt.Errorf("error building the OSImageStream: %w", err) + return fmt.Errorf("building the OSImageStream: %w", err) } // Create or update the OSImageStream resource @@ -296,7 +296,7 @@ func (optr *Operator) getExistingOSImageStream() (*mcfgv1.OSImageStream, error) osImageStream, err := optr.osImageStreamLister.Get(ctrlcommon.ClusterInstanceNameOSImageStream) if err != nil { if !apierrors.IsNotFound(err) { - return nil, fmt.Errorf("failed to retrieve existing OSImageStream: %v", err) + return nil, fmt.Errorf("failed to retrieve existing OSImageStream: %w", err) } return nil, nil } diff --git a/pkg/operator/render.go b/pkg/operator/render.go index 1afcd1e3d9..5fb2c3aa85 100644 --- a/pkg/operator/render.go +++ b/pkg/operator/render.go @@ -390,7 +390,7 @@ func cloudPlatformLoadBalancerIPs(cfg mcfgv1.ControllerConfigSpec, lbType LoadBa case ingressLB: return cfg.Infra.Status.PlatformStatus.GCP.CloudLoadBalancerConfig.ClusterHosted.IngressLoadBalancerIPs, nil default: - return nil, fmt.Errorf("Invalid GCP Load Balancer Type provided : %s", lbType) + return nil, fmt.Errorf("invalid GCP Load Balancer Type provided : %s", lbType) } case absentLBIPState: return nil, fmt.Errorf("GCP %s Load Balancer IPs unavailable when the DNSType is ClusterHosted", lbType) @@ -408,7 +408,7 @@ func cloudPlatformLoadBalancerIPs(cfg mcfgv1.ControllerConfigSpec, lbType LoadBa case ingressLB: return cfg.Infra.Status.PlatformStatus.AWS.CloudLoadBalancerConfig.ClusterHosted.IngressLoadBalancerIPs, nil default: - return nil, fmt.Errorf("Invalid AWS Load Balancer Type provided : %s", lbType) + return nil, fmt.Errorf("invalid AWS Load Balancer Type provided : %s", lbType) } case absentLBIPState: return nil, fmt.Errorf("AWS %s Load Balancer IPs unavailable when the DNSType is ClusterHosted", lbType) @@ -426,10 +426,10 @@ func cloudPlatformLoadBalancerIPs(cfg mcfgv1.ControllerConfigSpec, lbType LoadBa case ingressLB: return cfg.Infra.Status.PlatformStatus.Azure.CloudLoadBalancerConfig.ClusterHosted.IngressLoadBalancerIPs, nil default: - return nil, fmt.Errorf("Invalid Azure Load Balancer Type provided : %s", lbType) + return nil, fmt.Errorf("invalid Azure Load Balancer Type provided : %s", lbType) } case absentLBIPState: - return nil, fmt.Errorf("Azure %s Load Balancer IPs unavailable when the DNSType is ClusterHosted", lbType) + return nil, fmt.Errorf("azure %s Load Balancer IPs unavailable when the DNSType is ClusterHosted", lbType) default: return nil, fmt.Errorf("") } diff --git a/pkg/operator/status.go b/pkg/operator/status.go index b56f27d5f0..65f604209a 100644 --- a/pkg/operator/status.go +++ b/pkg/operator/status.go @@ -416,7 +416,7 @@ func (optr *Operator) GetAllManagedNodes(pools []*mcfgv1.MachineConfigPool) ([]* for _, pool := range pools { selector, err := metav1.LabelSelectorAsSelector(pool.Spec.NodeSelector) if err != nil { - return nil, fmt.Errorf("label selector for pool %v failed %v", pool.Name, err) + return nil, fmt.Errorf("label selector for pool %v failed %w", pool.Name, err) } poolNodes, err := optr.nodeLister.List(selector) if err != nil { @@ -582,7 +582,7 @@ func isMachineConfigPoolConfigurationValid(pool *mcfgv1.MachineConfigPool, versi } if !ok { - return fmt.Errorf("Unable to access annotation %s for %s expected: %s", ctrlcommon.ReleaseImageVersionAnnotationKey, renderedMC.Name, releaseVersion) + return fmt.Errorf("unable to access annotation %s for %s expected: %s", ctrlcommon.ReleaseImageVersionAnnotationKey, renderedMC.Name, releaseVersion) } return nil @@ -621,7 +621,7 @@ func checkBootImageControllerReady(mcop *opv1.MachineConfiguration) (bool, error // If boot image controller is degraded, return Upgradable=false and an error if meta.IsStatusConditionTrue(mcop.Status.Conditions, opv1.MachineConfigurationBootImageUpdateDegraded) { degradedCondition := meta.FindStatusCondition(mcop.Status.Conditions, opv1.MachineConfigurationBootImageUpdateDegraded) - return false, fmt.Errorf("Boot image controller is degraded: %s", degradedCondition.Message) + return false, fmt.Errorf("boot image controller is degraded: %s", degradedCondition.Message) } // If boot image controller is still progressing or hasn't completed its first pass, return true for statusReady diff --git a/pkg/operator/status_test.go b/pkg/operator/status_test.go index 6f654be800..952584d7e7 100644 --- a/pkg/operator/status_test.go +++ b/pkg/operator/status_test.go @@ -32,7 +32,7 @@ import ( ) func TestIsMachineConfigPoolConfigurationValid(t *testing.T) { - configNotFound := errors.New("Config Not Found") + configNotFound := errors.New("config not found") type config struct { name string version string @@ -871,7 +871,7 @@ func TestCheckBootImageSkewUpgradeableGuard(t *testing.T) { }, }, expectUpgradeBlock: true, - expectMessage: "Upgrades have been disabled due to boot image update failures: Boot image controller is degraded: failed to update boot images", + expectMessage: "Upgrades have been disabled due to boot image update failures: boot image controller is degraded: failed to update boot images", expectError: false, }, { diff --git a/pkg/operator/sync.go b/pkg/operator/sync.go index 5eeda92e0c..cff069be95 100644 --- a/pkg/operator/sync.go +++ b/pkg/operator/sync.go @@ -215,7 +215,7 @@ func (optr *Operator) syncAll(syncFuncs []syncFunc) error { // If there was no sync error for this function, attempt to clear degrade updatedCO, err = optr.clearDegradedStatus(updatedCO, sf.name) if err != nil { - return fmt.Errorf("error clearing degraded status: %v", err) + return fmt.Errorf("clearing degraded status: %w", err) } } @@ -235,16 +235,16 @@ func (optr *Operator) syncAll(syncFuncs []syncFunc) error { // syncRequiredMachineConfigPools has done an update prior to this. In such a case, // updateClusterOperatorStatus will refetch the Cluster Operator object before updating the new status. if _, err := optr.updateClusterOperatorStatus(co, &updatedCO.Status, nil); err != nil { - return fmt.Errorf("error updating cluster operator status: %w", err) + return fmt.Errorf("updating cluster operator status: %w", err) } // Handle these errors after as CO status updates should have priority over this if syncUpgradeableStatusErr != nil { - return fmt.Errorf("error syncingUpgradeableStatus: %w", syncUpgradeableStatusErr) + return fmt.Errorf("syncingUpgradeableStatus: %w", syncUpgradeableStatusErr) } if syncClusterFleetEvaluationErr != nil { - return fmt.Errorf("error updating cluster operator status: %w", syncClusterFleetEvaluationErr) + return fmt.Errorf("updating cluster operator status: %w", syncClusterFleetEvaluationErr) } if optr.inClusterBringup && syncErr.err == nil { @@ -408,7 +408,7 @@ func (optr *Operator) syncRenderConfig(_ *renderConfig, _ *configv1.ClusterOpera return true, nil }); err != nil { errs := kubeErrs.NewAggregate([]error{err, lastErr}) - return fmt.Errorf("error during operator version check: %w", errs) + return fmt.Errorf("during operator version check: %w", errs) } // handle image registry certificates. @@ -498,7 +498,7 @@ func (optr *Operator) syncRenderConfig(_ *renderConfig, _ *configv1.ClusterOpera } _, err = optr.kubeClient.CoreV1().ConfigMaps("openshift-config-managed").Patch(context.TODO(), "merged-trusted-image-registry-ca", types.MergePatchType, patchBytes, metav1.PatchOptions{}) if err != nil { - return fmt.Errorf("Could not patch merged-trusted-image-registry-ca with data %s: %w", string(patchBytes), err) + return fmt.Errorf("could not patch merged-trusted-image-registry-ca with data %s: %w", string(patchBytes), err) } break } @@ -1045,7 +1045,7 @@ func (optr *Operator) safetySyncControllerConfig(config *renderConfig) error { // we can't render a new one here, it won't succeed because the existing controller won't touch it // and we'll time out waiting. if existingCc.Annotations[daemonconsts.GeneratedByVersionAnnotationKey] != version.Raw { - return fmt.Errorf("Our version (%s) differs from controllerconfig (%s), can't do 'safety' controllerconfig sync until controller is updated", version.Raw, existingCc.Annotations[daemonconsts.GeneratedByVersionAnnotationKey]) + return fmt.Errorf("our version (%s) differs from controllerconfig (%s), can't do 'safety' controllerconfig sync until controller is updated", version.Raw, existingCc.Annotations[daemonconsts.GeneratedByVersionAnnotationKey]) } // If we made it here, we should be able to sync controllerconfig, and the existing controller should handle it @@ -1131,21 +1131,21 @@ func (optr *Operator) syncControllerConfig(config *renderConfig) error { cmNew.BinaryData = binData cmMarshal, err := json.Marshal(mcoCM) if err != nil { - return fmt.Errorf("could not marshal old configmap data. Err: %v ", err) + return fmt.Errorf("could not marshal old configmap data: %w", err) } // new mco CM Data newCMMarshal, err := json.Marshal(cmNew) if err != nil { - return fmt.Errorf("could not marshal new configmap data. Data: %s Err: %v ", string(data), err) + return fmt.Errorf("could not marshal new configmap data: %w", err) } // patch mco CM patchBytes, err := jsonmergepatch.CreateThreeWayJSONMergePatch(cmMarshal, newCMMarshal, cmMarshal) if err != nil { - return fmt.Errorf("Could not create a three way json merge patch: %w", err) + return fmt.Errorf("could not create a three way json merge patch: %w", err) } _, err = optr.kubeClient.CoreV1().ConfigMaps(ctrlcommon.MCONamespace).Patch(context.TODO(), "kubeconfig-data", types.MergePatchType, patchBytes, metav1.PatchOptions{}) if err != nil { - return fmt.Errorf("Could not patch kubeconfig-data with data %s: %w", string(patchBytes), err) + return fmt.Errorf("could not patch kubeconfig-data with data %s: %w", string(patchBytes), err) } editCCAnno = true } else if getErr != nil { @@ -1154,7 +1154,7 @@ func (optr *Operator) syncControllerConfig(config *renderConfig) error { cmNew.BinaryData = binData _, err := optr.kubeClient.CoreV1().ConfigMaps(ctrlcommon.MCONamespace).Create(context.TODO(), &cmNew, metav1.CreateOptions{}) if err != nil { - return fmt.Errorf("Could not make kubeconfig-data CM, %v", err) + return fmt.Errorf("could not make kubeconfig-data CM, %w", err) } editCCAnno = true } @@ -1565,7 +1565,7 @@ func (optr *Operator) reconcileGlobalPullSecretCopy(layeredMCPs []*mcfgv1.Machin // Atleast one pool is opted-in, let's create or update the copy if needed. First, grab the global pull secret. globalPullSecret, err := optr.ocSecretLister.Secrets(ctrlcommon.OpenshiftConfigNamespace).Get("pull-secret") if err != nil { - return fmt.Errorf("error fetching cluster pull secret: %w", err) + return fmt.Errorf("fetching cluster pull secret: %w", err) } // Create a clone of clusterPullSecret, and modify it to be in the MCO namespace. @@ -1741,7 +1741,7 @@ func (optr *Operator) syncRequiredMachineConfigPools(config *renderConfig, co *c // Calculate total timeout for "required"(aka master) nodes in the pool. pools, err := optr.mcpLister.List(labels.Everything()) if err != nil { - return fmt.Errorf("error during syncRequiredMachineConfigPools: %w", err) + return fmt.Errorf("during syncRequiredMachineConfigPools: %w", err) } requiredMachineCount := 0 @@ -1788,7 +1788,7 @@ func (optr *Operator) syncRequiredMachineConfigPools(config *renderConfig, co *c degraded := isPoolStatusConditionTrue(pool, mcfgv1.MachineConfigPoolDegraded) if degraded { - lastErr = fmt.Errorf("error MachineConfigPool %s is not ready, retrying. Status: (pool degraded: %v total: %d, ready %d, updated: %d, unavailable: %d, reason: %s)", pool.Name, degraded, pool.Status.MachineCount, pool.Status.ReadyMachineCount, pool.Status.UpdatedMachineCount, pool.Status.UnavailableMachineCount, getPoolStatusConditionMessage(pool, mcfgv1.MachineConfigPoolDegraded)) + lastErr = fmt.Errorf("MachineConfigPool %s is not ready, retrying. Status: (pool degraded: %v total: %d, ready %d, updated: %d, unavailable: %d, reason: %s)", pool.Name, degraded, pool.Status.MachineCount, pool.Status.ReadyMachineCount, pool.Status.UpdatedMachineCount, pool.Status.UnavailableMachineCount, getPoolStatusConditionMessage(pool, mcfgv1.MachineConfigPoolDegraded)) klog.Errorf("Error syncing Required MachineConfigPools: %q", lastErr) newCO := co.DeepCopy() syncerr := optr.syncUpgradeableStatus(newCO) @@ -1835,7 +1835,7 @@ func (optr *Operator) syncRequiredMachineConfigPools(config *renderConfig, co *c isPoolStatusConditionTrue(pool, mcfgv1.MachineConfigPoolUpdated) { continue } - lastErr = fmt.Errorf("error required MachineConfigPool %s is not ready, retrying. Status: (total: %d, ready %d, updated: %d, unavailable: %d, degraded: %d)", pool.Name, pool.Status.MachineCount, pool.Status.ReadyMachineCount, pool.Status.UpdatedMachineCount, pool.Status.UnavailableMachineCount, pool.Status.DegradedMachineCount) + lastErr = fmt.Errorf("required MachineConfigPool %s is not ready, retrying. Status: (total: %d, ready %d, updated: %d, unavailable: %d, degraded: %d)", pool.Name, pool.Status.MachineCount, pool.Status.ReadyMachineCount, pool.Status.UpdatedMachineCount, pool.Status.UnavailableMachineCount, pool.Status.DegradedMachineCount) newCO := co.DeepCopy() syncerr := optr.syncUpgradeableStatus(newCO) if syncerr != nil { @@ -1850,7 +1850,7 @@ func (optr *Operator) syncRequiredMachineConfigPools(config *renderConfig, co *c if isPoolStatusConditionTrue(pool, mcfgv1.MachineConfigPoolUpdated) { return false, fmt.Errorf("the required MachineConfigPool %s was paused with no pending updates; no further syncing will occur until it is unpaused", pool.Name) } - return false, fmt.Errorf("error required MachineConfigPool %s is paused and cannot sync until it is unpaused", pool.Name) + return false, fmt.Errorf("required MachineConfigPool %s is paused and cannot sync until it is unpaused", pool.Name) } return false, nil } @@ -1860,7 +1860,7 @@ func (optr *Operator) syncRequiredMachineConfigPools(config *renderConfig, co *c if wait.Interrupted(err) { klog.Errorf("Error syncing Required MachineConfigPools: %q", lastErr) errs := kubeErrs.NewAggregate([]error{err, lastErr}) - return fmt.Errorf("error during syncRequiredMachineConfigPools: %w", errs) + return fmt.Errorf("during syncRequiredMachineConfigPools: %w", errs) } return err } @@ -1895,7 +1895,7 @@ func (optr *Operator) waitForDeploymentRollout(resource *appsv1.Deployment) erro if err != nil { // Do not return error here, as we could be updating the API Server itself, in which case we // want to continue waiting. - lastErr = fmt.Errorf("error getting Deployment %s during rollout: %w", resource.Name, err) + lastErr = fmt.Errorf("getting Deployment %s during rollout: %w", resource.Name, err) return false, nil } @@ -1911,7 +1911,7 @@ func (optr *Operator) waitForDeploymentRollout(resource *appsv1.Deployment) erro }); err != nil { if wait.Interrupted(err) { errs := kubeErrs.NewAggregate([]error{err, lastErr}) - return fmt.Errorf("error during waitForDeploymentRollout: %w", errs) + return fmt.Errorf("during waitForDeploymentRollout: %w", errs) } return err } @@ -1932,7 +1932,7 @@ func (optr *Operator) waitForDaemonsetRollout(resource *appsv1.DaemonSet) error if err != nil { // Do not return error here, as we could be updating the API Server itself, in which case we // want to continue waiting. - lastErr = fmt.Errorf("error getting Daemonset %s during rollout: %w", resource.Name, err) + lastErr = fmt.Errorf("getting Daemonset %s during rollout: %w", resource.Name, err) return false, nil } @@ -1948,7 +1948,7 @@ func (optr *Operator) waitForDaemonsetRollout(resource *appsv1.DaemonSet) error }); err != nil { if wait.Interrupted(err) { errs := kubeErrs.NewAggregate([]error{err, lastErr}) - return fmt.Errorf("error during waitForDaemonsetRollout: %w", errs) + return fmt.Errorf("during waitForDaemonsetRollout: %w", errs) } return err } @@ -1968,7 +1968,7 @@ func (optr *Operator) waitForControllerConfigToBeCompleted(resource *mcfgv1.Cont }); err != nil { if wait.Interrupted(err) { errs := kubeErrs.NewAggregate([]error{err, lastErr}) - return fmt.Errorf("error during waitForControllerConfigToBeCompleted: %w", errs) + return fmt.Errorf("during waitForControllerConfigToBeCompleted: %w", errs) } return err } @@ -2123,12 +2123,12 @@ func (optr *Operator) getGlobalConfig() (*configv1.Infrastructure, *configv1.Net infra = infra.DeepCopy() err = setGVK(infra, configclientscheme.Scheme) if err != nil { - return nil, nil, nil, nil, nil, fmt.Errorf("Failed setting gvk for infra object: %w", err) + return nil, nil, nil, nil, nil, fmt.Errorf("failed setting gvk for infra object: %w", err) } dns = dns.DeepCopy() err = setGVK(dns, configclientscheme.Scheme) if err != nil { - return nil, nil, nil, nil, nil, fmt.Errorf("Failed setting gvk for dns object: %w", err) + return nil, nil, nil, nil, nil, fmt.Errorf("failed setting gvk for dns object: %w", err) } return infra, network, proxy, dns, apiServer, nil @@ -2268,7 +2268,7 @@ func (optr *Operator) getImageRegistryPullSecrets() ([]byte, error) { // Fetch the cluster pull secret clusterPullSecret, err := optr.ocSecretLister.Secrets(ctrlcommon.OpenshiftConfigNamespace).Get("pull-secret") if err != nil { - return nil, fmt.Errorf("error fetching cluster pull secret: %w", err) + return nil, fmt.Errorf("fetching cluster pull secret: %w", err) } if clusterPullSecret.Type != corev1.SecretTypeDockerConfigJson { return nil, fmt.Errorf("expected secret type %s found %s", corev1.SecretTypeDockerConfigJson, clusterPullSecret.Type) @@ -2354,7 +2354,7 @@ func (optr *Operator) syncMachineConfiguration(_ *renderConfig, _ *configv1.Clus // This causes a re-sync and allows the cache for the lister to refresh. return nil } - return fmt.Errorf("grabbing MachineConfiguration/%s CR failed: %v", ctrlcommon.MCOOperatorKnobsObjectName, err) + return fmt.Errorf("grabbing MachineConfiguration/%s CR failed: %w", ctrlcommon.MCOOperatorKnobsObjectName, err) } // Set the log level to the value defined in the MachineConfiguration object @@ -2399,7 +2399,7 @@ func (optr *Operator) syncMachineConfiguration(_ *renderConfig, _ *configv1.Clus annoPatch := fmt.Sprintf(`{"metadata": {"annotations": {"%s": "%s"}}}`, ctrlcommon.BootImageOptedInAnnotation, metav1.Now().Format(time.RFC3339)) mcop, err = optr.mcopClient.OperatorV1().MachineConfigurations().Patch(context.TODO(), ctrlcommon.MCOOperatorKnobsObjectName, types.MergePatchType, []byte(annoPatch), metav1.PatchOptions{}) if err != nil { - return fmt.Errorf("failed to apply MachineConfiguration bootimage updates opt-in annotation : %v", err) + return fmt.Errorf("failed to apply MachineConfiguration bootimage updates opt-in annotation : %w", err) } } mcop.Status = *newMachineConfigurationStatus @@ -2415,7 +2415,7 @@ func (optr *Operator) syncMachineConfiguration(_ *renderConfig, _ *configv1.Clus _, err = optr.mcopClient.OperatorV1().MachineConfigurations().UpdateStatus(context.TODO(), mcop, metav1.UpdateOptions{}) return err }); err != nil { - return fmt.Errorf("error updating MachineConfiguration status: %v", err) + return fmt.Errorf("updating MachineConfiguration status: %w", err) } } diff --git a/pkg/server/server.go b/pkg/server/server.go index ad1792bf92..0b0b773d07 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -279,7 +279,7 @@ func MigrateKernelArgsIfNecessary(conf *ign3types.Config, mc *mcfgv1.MachineConf if version != nil && version.LessThan(*semver.New("3.3.0")) { // we're converting to a version that doesn't support kargs, so we need to stuff them in machineconfig if len(conf.KernelArguments.ShouldNotExist) > 0 { - return fmt.Errorf("Can't serve version %s with ignition KernelArguments.ShouldNotExist populated", version) + return fmt.Errorf("can't serve version %s with ignition KernelArguments.ShouldNotExist populated", version) } for _, karg := range conf.KernelArguments.ShouldExist { diff --git a/test/e2e-bootstrap/bootstrap_test.go b/test/e2e-bootstrap/bootstrap_test.go index 2c3303d0de..ac0c85d200 100644 --- a/test/e2e-bootstrap/bootstrap_test.go +++ b/test/e2e-bootstrap/bootstrap_test.go @@ -791,7 +791,7 @@ func loadRawManifests(t *testing.T, rawObjs [][]byte) []runtime.Object { // both directories must exist, does not copy recursively func copyDir(src string, dest string) error { if strings.HasPrefix(dest, src) { - return fmt.Errorf("Cannot copy a folder into the folder itself!") + return fmt.Errorf("cannot copy a folder into the folder itself!") } f, err := os.Open(src) @@ -804,7 +804,7 @@ func copyDir(src string, dest string) error { return err } if !file.IsDir() { - return fmt.Errorf("Source %v is not a directory!", file.Name()) + return fmt.Errorf("source %v is not a directory!", file.Name()) } files, err := ctrlcommon.ReadDir(src) diff --git a/test/extended-priv/configmap.go b/test/extended-priv/configmap.go index 67621b4ed8..7ba55875af 100644 --- a/test/extended-priv/configmap.go +++ b/test/extended-priv/configmap.go @@ -56,7 +56,7 @@ func (cm *ConfigMap) GetDataValue(key string) (string, error) { data, ok := dataMap[key] if !ok { - return "", fmt.Errorf("Key %s does not exist in the .data in Configmap -n %s %s", + return "", fmt.Errorf("key %s does not exist in the .data in Configmap -n %s %s", key, cm.GetNamespace(), cm.GetName()) } diff --git a/test/extended-priv/containerruntimeconfig.go b/test/extended-priv/containerruntimeconfig.go index 4beb411d3f..bfaf5c278c 100644 --- a/test/extended-priv/containerruntimeconfig.go +++ b/test/extended-priv/containerruntimeconfig.go @@ -60,7 +60,7 @@ func (cr ContainerRuntimeConfig) GetGeneratedMCName() (string, error) { return "", err } if mcName == "" { - return "", fmt.Errorf("It was not possible to get the finalizer from %s %s: %s", cr.GetKind(), cr.GetName(), cr.PrettyString()) + return "", fmt.Errorf("it was not possible to get the finalizer from %s %s: %s", cr.GetKind(), cr.GetName(), cr.PrettyString()) } return mcName, nil } diff --git a/test/extended-priv/controller.go b/test/extended-priv/controller.go index 612d12d325..a6fe864c18 100644 --- a/test/extended-priv/controller.go +++ b/test/extended-priv/controller.go @@ -109,7 +109,7 @@ func (mcc *Controller) GetRawLogs() (string, error) { return "", err } if cachedPodName == "" { - err := fmt.Errorf("Cannot get controller pod name. Failed getting MCO controller logs") + err := fmt.Errorf("cannot get controller pod name. Failed getting MCO controller logs") logger.Errorf("Error getting controller pod name. Error: %s", err) return "", err } @@ -200,7 +200,7 @@ func (mcc *Controller) GetPreviousLogs() (string, error) { return "", err } if cachedPodName == "" { - err := fmt.Errorf("Cannot get controller pod name. Failed getting MCO controller logs") + err := fmt.Errorf("cannot get controller pod name. Failed getting MCO controller logs") logger.Errorf("Error getting controller pod name. Error: %s", err) return "", err } diff --git a/test/extended-priv/controllerconfig.go b/test/extended-priv/controllerconfig.go index 422410d7f2..b95ca552db 100644 --- a/test/extended-priv/controllerconfig.go +++ b/test/extended-priv/controllerconfig.go @@ -118,7 +118,7 @@ func (cc *ControllerConfig) GetImageRegistryBundleDataByFileName(fileName string data, ok := certs[fileName] if !ok { - return "", fmt.Errorf("There is no image registry bundle with file name %s", fileName) + return "", fmt.Errorf("there is no image registry bundle with file name %s", fileName) } return data, nil @@ -133,7 +133,7 @@ func (cc *ControllerConfig) GetImageRegistryBundleUserDataByFileName(fileName st data, ok := certs[fileName] if !ok { - return "", fmt.Errorf("There is no image registry bundle with file name %s", fileName) + return "", fmt.Errorf("there is no image registry bundle with file name %s", fileName) } return data, nil diff --git a/test/extended-priv/controlplanemachineset.go b/test/extended-priv/controlplanemachineset.go index 82e919359b..f45361d7a5 100644 --- a/test/extended-priv/controlplanemachineset.go +++ b/test/extended-priv/controlplanemachineset.go @@ -368,7 +368,7 @@ func GCPGetControlPlaneMachinesetBootDiskIndex(cpms ControlPlaneMachineSet) (int // Get the disks array from the ControlPlaneMachineSet spec disksJSON, err := cpms.Get(`{.spec.template.machines_v1beta1_machine_openshift_io.spec.providerSpec.value.disks}`) if err != nil { - return -1, fmt.Errorf("Failed to get disks array: %v", err) + return -1, fmt.Errorf("failed to get disks array: %v", err) } // Parse the disks array and find the boot disk @@ -380,5 +380,5 @@ func GCPGetControlPlaneMachinesetBootDiskIndex(cpms ControlPlaneMachineSet) (int } } - return -1, fmt.Errorf("No boot disk found in disks array (no disk with boot: true)") + return -1, fmt.Errorf("no boot disk found in disks array (no disk with boot: true)") } diff --git a/test/extended-priv/gomega_json_matcher.go b/test/extended-priv/gomega_json_matcher.go index f4431f9ffc..bc02691167 100644 --- a/test/extended-priv/gomega_json_matcher.go +++ b/test/extended-priv/gomega_json_matcher.go @@ -76,15 +76,15 @@ func (matcher *gjsonMatcher) Match(actual interface{}) (success bool, err error) strJSON, ok := actual.(string) logger.Debugf("Matched JSON: %s", strJSON) if !ok { - return false, fmt.Errorf(`Wrong type. Matcher expects a type "string": %s`, actual) + return false, fmt.Errorf(`wrong type. Matcher expects a type "string": %s`, actual) } if !gjson.Valid(strJSON) { - return false, fmt.Errorf(`Wrong format. The string is not a valid JSON: %s`, strJSON) + return false, fmt.Errorf(`wrong format. The string is not a valid JSON: %s`, strJSON) } data := gjson.Get(strJSON, matcher.path) if !data.Exists() { - return false, fmt.Errorf(`The matched path %s does not exist in the provided JSON: %s`, matcher.path, strJSON) + return false, fmt.Errorf(`the matched path %s does not exist in the provided JSON: %s`, matcher.path, strJSON) } matcher.data = data.Value() diff --git a/test/extended-priv/gomega_matchers.go b/test/extended-priv/gomega_matchers.go index fd03073c92..0ef058230a 100644 --- a/test/extended-priv/gomega_matchers.go +++ b/test/extended-priv/gomega_matchers.go @@ -28,7 +28,7 @@ func (matcher *conditionMatcher) Match(actual interface{}) (success bool, err er resource, ok := actual.(ResourceInterface) if !ok { logger.Errorf("Wrong type. Matcher expects a type implementing 'ResourceInterface'") - return false, fmt.Errorf(`Wrong type. Matcher expects a type "ResourceInterface" in test case %v`, g.CurrentSpecReport().FullText()) + return false, fmt.Errorf(`wrong type. Matcher expects a type "ResourceInterface" in test case %v`, g.CurrentSpecReport().FullText()) } // Extract the value of the condition that we want to check @@ -38,7 +38,7 @@ func (matcher *conditionMatcher) Match(actual interface{}) (success bool, err er } if matcher.currentCondition == "" { - return false, fmt.Errorf(`Condition type "%s" cannot be found in resource %s in test case %v`, matcher.conditionType, resource, g.CurrentSpecReport().FullText()) + return false, fmt.Errorf(`condition type "%s" cannot be found in resource %s in test case %v`, matcher.conditionType, resource, g.CurrentSpecReport().FullText()) } var conditionMap map[string]string @@ -49,7 +49,7 @@ func (matcher *conditionMatcher) Match(actual interface{}) (success bool, err er matcher.value, ok = conditionMap[matcher.field] if !ok { - return false, fmt.Errorf(`Condition field "%s" cannot be found in condition %s for resource %s in test case %v`, + return false, fmt.Errorf(`condition field "%s" cannot be found in condition %s for resource %s in test case %v`, matcher.field, matcher.conditionType, resource, g.CurrentSpecReport().FullText()) } diff --git a/test/extended-priv/inside_node_containers.go b/test/extended-priv/inside_node_containers.go index 3747f1e6f4..6d63ecc2ad 100644 --- a/test/extended-priv/inside_node_containers.go +++ b/test/extended-priv/inside_node_containers.go @@ -73,7 +73,7 @@ func (b *OsImageBuilderInNode) prepareEnvironment() error { pullSecret := GetPullSecret(b.node.oc.AsAdmin()) tokenDir, err := pullSecret.Extract() if err != nil { - return fmt.Errorf("Error extracting pull-secret. Error: %s", err) + return fmt.Errorf("error extracting pull-secret. Error: %s", err) } logger.Infof("Pull secret has been extracted to: %s\n", tokenDir) b.dockerConfig = filepath.Join(tokenDir, ".dockerconfigjson") @@ -83,7 +83,7 @@ func (b *OsImageBuilderInNode) prepareEnvironment() error { b.remoteTmpDir = filepath.Join("/root", e2e.TestContext.OutputDir, fmt.Sprintf("mco-test-%s", exutil.GetRandomString())) _, err = b.node.DebugNodeWithChroot("mkdir", "-p", b.remoteTmpDir) if err != nil { - return fmt.Errorf("Error creating tmp dir %s in node %s. Error: %s", b.remoteTmpDir, b.node.GetName(), err) + return fmt.Errorf("error creating tmp dir %s in node %s. Error: %s", b.remoteTmpDir, b.node.GetName(), err) } if b.remoteDockerConfig == "" { @@ -103,18 +103,18 @@ func (b *OsImageBuilderInNode) prepareEnvironment() error { pool, poolErr := b.node.GetPrimaryPool() if poolErr != nil { - return fmt.Errorf("Error getting the primary pool for node %s. Error: %s", b.node.GetName(), poolErr) + return fmt.Errorf("error getting the primary pool for node %s. Error: %s", b.node.GetName(), poolErr) } stream, streamErr := GetEffectiveOsImageStream(pool) if streamErr != nil { - return fmt.Errorf("Error getting the effective osImageStream for pool %s. Error: %s", pool.GetName(), streamErr) + return fmt.Errorf("error getting the effective osImageStream for pool %s. Error: %s", pool.GetName(), streamErr) } logger.Infof("Builder node %s stream: %s", b.node.GetName(), stream) b.baseImage, err = GetLayeringBaseImageByStream(b.node.oc.AsAdmin(), stream, b.dockerConfig) if err != nil { - return fmt.Errorf("Error getting the base image to build new osImages. Error: %s", err) + return fmt.Errorf("error getting the base image to build new osImages. Error: %s", err) } uniqueTag, err := generateUniqueTag(b.node.oc.AsAdmin()) @@ -162,7 +162,7 @@ func (b *OsImageBuilderInNode) preparePushToInternalRegistry() error { if nsExistsErr != nil { err := b.node.oc.Run("create").Args("namespace", layeringTestsTmpNamespace).Execute() if err != nil { - return fmt.Errorf("Error creating namespace %s to store the tmp SAs. Error: %s", + return fmt.Errorf("error creating namespace %s to store the tmp SAs. Error: %s", layeringTestsTmpNamespace, err) } } else { @@ -174,7 +174,7 @@ func (b *OsImageBuilderInNode) preparePushToInternalRegistry() error { if saExistsErr != nil { cErr := b.node.oc.Run("create").Args("-n", layeringTestsTmpNamespace, "serviceaccount", layeringRegistryAdminSAName).Execute() if cErr != nil { - return fmt.Errorf("Error creating ServiceAccount %s/%s: %s", layeringTestsTmpNamespace, layeringRegistryAdminSAName, cErr) + return fmt.Errorf("error creating ServiceAccount %s/%s: %s", layeringTestsTmpNamespace, layeringRegistryAdminSAName, cErr) } } else { logger.Infof("SA %s/%s already exists. Skip SA creation", layeringTestsTmpNamespace, layeringRegistryAdminSAName) @@ -182,7 +182,7 @@ func (b *OsImageBuilderInNode) preparePushToInternalRegistry() error { admErr := b.node.oc.Run("adm").Args("-n", layeringTestsTmpNamespace, "policy", "add-cluster-role-to-user", "registry-admin", "-z", layeringRegistryAdminSAName).Execute() if admErr != nil { - return fmt.Errorf("Error creating ServiceAccount %s: %s", layeringRegistryAdminSAName, admErr) + return fmt.Errorf("error creating ServiceAccount %s: %s", layeringRegistryAdminSAName, admErr) } logger.Infof("Get SA token") @@ -198,7 +198,7 @@ func (b *OsImageBuilderInNode) preparePushToInternalRegistry() error { defer b.node.GetOC().SetShowInfo() loginOut, loginErr := b.node.DebugNodeWithChroot("podman", "login", InternalRegistrySvcURL, "-u", layeringRegistryAdminSAName, "-p", saToken, "--authfile", b.remoteDockerConfig) if loginErr != nil { - return fmt.Errorf("Error trying to login to internal registry:\nOutput:%s\nError:%s", loginOut, loginErr) + return fmt.Errorf("error trying to login to internal registry:\nOutput:%s\nError:%s", loginOut, loginErr) } logger.Infof("OK!\n") @@ -212,7 +212,7 @@ func (b *OsImageBuilderInNode) CleanUp() error { logger.Infof("Removing namespace %s", layeringTestsTmpNamespace) err := b.node.oc.Run("delete").Args("namespace", layeringTestsTmpNamespace, "--ignore-not-found").Execute() if err != nil { - return fmt.Errorf("Error deleting namespace %s. Error: %s", + return fmt.Errorf("error deleting namespace %s. Error: %s", layeringTestsTmpNamespace, err) } @@ -240,12 +240,12 @@ func (b *OsImageBuilderInNode) buildImage() error { localBuildDir, err := prepareDockerfileDirectory(b.tmpDir, dockerFile) if err != nil { - return fmt.Errorf("Error creating the build directory with the Dockerfile. Error: %s", err) + return fmt.Errorf("error creating the build directory with the Dockerfile. Error: %s", err) } cpErr := b.node.CopyFromLocal(filepath.Join(localBuildDir, "Dockerfile"), b.remoteDockerfile) if cpErr != nil { - return fmt.Errorf("Error creating the Dockerfile in the remote node. Error: %s", cpErr) + return fmt.Errorf("error creating the Dockerfile in the remote node. Error: %s", cpErr) } logger.Infof("OK!\n") diff --git a/test/extended-priv/jsondata.go b/test/extended-priv/jsondata.go index a818ff64ff..984664da57 100644 --- a/test/extended-priv/jsondata.go +++ b/test/extended-priv/jsondata.go @@ -92,12 +92,12 @@ func (jd *JSONData) String() string { // GetSafe returns the value of a key in the data and an error func (jd *JSONData) GetSafe(key string) (*JSONData, error) { if jd.data == nil { - return nil, fmt.Errorf("Data does not exist. It is empty: %v", jd.data) + return nil, fmt.Errorf("data does not exist. It is empty: %v", jd.data) } mapData, ok := jd.data.(map[string]interface{}) if !ok { - return nil, fmt.Errorf("Data is not a map: %v", jd.data) + return nil, fmt.Errorf("data is not a map: %v", jd.data) } value, found := mapData[key] if found { @@ -109,12 +109,12 @@ func (jd *JSONData) GetSafe(key string) (*JSONData, error) { // ItemSafe returns the value of a given item in a list and an error func (jd *JSONData) ItemSafe(index int) (*JSONData, error) { if jd.data == nil { - return nil, fmt.Errorf("Data does not exist. It is empty: %v", jd.data) + return nil, fmt.Errorf("data does not exist. It is empty: %v", jd.data) } listData, ok := jd.data.([]interface{}) if !ok { - return nil, fmt.Errorf("Data is not a list: %v", jd.data) + return nil, fmt.Errorf("data is not a list: %v", jd.data) } return &JSONData{listData[index]}, nil } diff --git a/test/extended-priv/kubeletconfig.go b/test/extended-priv/kubeletconfig.go index 47c888c2d3..c28087a5bb 100644 --- a/test/extended-priv/kubeletconfig.go +++ b/test/extended-priv/kubeletconfig.go @@ -60,7 +60,7 @@ func (kc KubeletConfig) GetGeneratedMCName() (string, error) { return "", err } if mcName == "" { - return "", fmt.Errorf("It was not possible to get the finalizer from %s %s: %s", kc.GetKind(), kc.GetName(), kc.PrettyString()) + return "", fmt.Errorf("it was not possible to get the finalizer from %s %s: %s", kc.GetKind(), kc.GetName(), kc.PrettyString()) } return mcName, nil } diff --git a/test/extended-priv/machine.go b/test/extended-priv/machine.go index fcd0b50e8f..130b34f46d 100644 --- a/test/extended-priv/machine.go +++ b/test/extended-priv/machine.go @@ -33,12 +33,12 @@ func (m Machine) GetNode() (*Node, error) { } numNodes := len(nodes) if numNodes > 1 { - return nil, fmt.Errorf("More than one nodes linked to this Machine. Machine: %s. Num nodes:%d", + return nil, fmt.Errorf("more than one nodes linked to this Machine. Machine: %s. Num nodes:%d", m.GetName(), numNodes) } if numNodes == 0 { - return nil, fmt.Errorf("No node linked to this Machine. Machine: %s", m.GetName()) + return nil, fmt.Errorf("no node linked to this Machine. Machine: %s", m.GetName()) } return nodes[0], nil diff --git a/test/extended-priv/machineconfigpool.go b/test/extended-priv/machineconfigpool.go index 27d5c8ef7e..856ce12035 100644 --- a/test/extended-priv/machineconfigpool.go +++ b/test/extended-priv/machineconfigpool.go @@ -546,7 +546,7 @@ func (mcp *MachineConfigPool) GetCordonedNodes() []*Node { err := wait.PollUntilContextTimeout(context.TODO(), 5*time.Second, 10*time.Minute, true, func(_ context.Context) (bool, error) { nodes, nerr := mcp.GetNodes() if nerr != nil { - return false, fmt.Errorf("Get all linux node failed, will try again in next run %v", nerr) + return false, fmt.Errorf("get all linux node failed, will try again in next run %v", nerr) } for _, node := range nodes { schedulable, serr := node.IsSchedulable() @@ -858,14 +858,14 @@ func (mcp *MachineConfigPool) RecoverFromDegraded() error { logger.Infof("Restoring desired config in node: %s", node) isUpdated, err := node.IsUpdated() if err != nil { - return fmt.Errorf("Error checking if node %s is updated: %s", node.GetName(), err) + return fmt.Errorf("error checking if node %s is updated: %s", node.GetName(), err) } if isUpdated { logger.Infof("node is updated, don't need to recover") } else { err := node.RestoreDesiredConfig() if err != nil { - return fmt.Errorf("Error restoring desired config in node %s. Error: %s", + return fmt.Errorf("error restoring desired config in node %s. Error: %s", mcp.GetName(), err) } } @@ -1047,7 +1047,7 @@ func (mcp *MachineConfigPool) GetPinnedImageSets() ([]*PinnedImageSet, error) { } if labelsString == "" { - return nil, fmt.Errorf("No machineConfigSelector found in %s", mcp) + return nil, fmt.Errorf("no machineConfigSelector found in %s", mcp) } labels := gjson.Parse(labelsString) @@ -1059,7 +1059,7 @@ func (mcp *MachineConfigPool) GetPinnedImageSets() ([]*PinnedImageSet, error) { }) if requiredLabel == "" { - return nil, fmt.Errorf("No labels matcher could be built for %s", mcp) + return nil, fmt.Errorf("no labels matcher could be built for %s", mcp) } // remove the last comma requiredLabel = strings.TrimSuffix(requiredLabel, ",") @@ -1080,7 +1080,7 @@ func (mcp MachineConfigPool) GetMOSC() (*MachineOSConfig, error) { } if len(moscs) > 1 { moscList.PrintDebugCommand() - return nil, fmt.Errorf("There are more than one MOSC for pool %s", mcp.GetName()) + return nil, fmt.Errorf("there are more than one MOSC for pool %s", mcp.GetName()) } if len(moscs) == 0 { @@ -1221,7 +1221,7 @@ func CreateCustomMCPWithStreamByLabel(oc *exutil.CLI, name, label, osstream stri } if len(nodes) < numNodes { - return nil, fmt.Errorf("The worker MCP only has %d nodes, it is not possible to take %d nodes from worker pool to create a custom pool", + return nil, fmt.Errorf("the worker MCP only has %d nodes, it is not possible to take %d nodes from worker pool to create a custom pool", len(nodes), numNodes) } @@ -1262,7 +1262,7 @@ func CreateCustomMCPWithStream(oc *exutil.CLI, name, osstream string, numNodes i } if numNodes > len(workerNodes) { - return NewMachineConfigPool(oc, name), fmt.Errorf("A %d nodes custom pool cannot be created because there are only %d nodes in the %s pool", + return NewMachineConfigPool(oc, name), fmt.Errorf("a %d nodes custom pool cannot be created because there are only %d nodes in the %s pool", numNodes, len(workerNodes), wMcp.GetName()) } @@ -1607,7 +1607,7 @@ func (mcp *MachineConfigPool) GetSortedUpdatedNodes(maxUnavailable int) []*Node if degradedstdout != 0 { logger.Errorf("Degraded MC:\n%s", mcp.PrettyString()) - exutil.AssertWaitPollNoErr(fmt.Errorf("Degraded machines"), fmt.Sprintf("mcp %s has degraded %d machines", mcp.name, degradedstdout)) + exutil.AssertWaitPollNoErr(fmt.Errorf("degraded machines"), fmt.Sprintf("mcp %s has degraded %d machines", mcp.name, degradedstdout)) } // Check that there aren't more thatn maxUpdatingNodes updating at the same time diff --git a/test/extended-priv/machineosbuild.go b/test/extended-priv/machineosbuild.go index 917171cabc..5b16618c4c 100644 --- a/test/extended-priv/machineosbuild.go +++ b/test/extended-priv/machineosbuild.go @@ -30,7 +30,7 @@ func NewMachineOSBuildList(oc *exutil.CLI) *MachineOSBuildList { func (mosb MachineOSBuild) GetMachineOSConfig() (*MachineOSConfig, error) { moscName, err := mosb.Get(`{.spec.machineOSConfig.name}`) if moscName == "" { - return nil, fmt.Errorf("Could not get the MachineOSCOnfig name from %s", mosb) + return nil, fmt.Errorf("could not get the MachineOSCOnfig name from %s", mosb) } return NewMachineOSConfig(mosb.GetOC(), moscName), err @@ -58,11 +58,11 @@ func (mosb MachineOSBuild) GetJob() (*Job, error) { } if jobName == "" { - return nil, fmt.Errorf("Could not get the job name from %s", mosb) + return nil, fmt.Errorf("could not get the job name from %s", mosb) } if jobNamespace == "" { - return nil, fmt.Errorf("Could not get the job namespace from %s", mosb) + return nil, fmt.Errorf("could not get the job namespace from %s", mosb) } return NewJob(mosb.GetOC(), jobNamespace, jobName), nil diff --git a/test/extended-priv/machineosconfig.go b/test/extended-priv/machineosconfig.go index 895f7557ac..6f35a00213 100644 --- a/test/extended-priv/machineosconfig.go +++ b/test/extended-priv/machineosconfig.go @@ -111,7 +111,7 @@ func CreateMachineOSConfigUsingInternalRegistry(oc *exutil.CLI, namespace, name, return NewMachineOSConfig(oc, name), err } if !renderedImagePushSecret.Exists() { - return NewMachineOSConfig(oc, name), fmt.Errorf("Rendered image push secret does not exist: %s", renderedImagePushSecret) + return NewMachineOSConfig(oc, name), fmt.Errorf("rendered image push secret does not exist: %s", renderedImagePushSecret) } if namespace != MachineConfigNamespace { // If the secret is not in MCO, we copy it there @@ -123,28 +123,28 @@ func CreateMachineOSConfigUsingInternalRegistry(oc *exutil.CLI, namespace, name, return NewMachineOSConfig(oc, name), err } if !namespacedPullSecret.Exists() { - return NewMachineOSConfig(oc, name), fmt.Errorf("Current image pull secret does not exist: %s", namespacedPullSecret) + return NewMachineOSConfig(oc, name), fmt.Errorf("current image pull secret does not exist: %s", namespacedPullSecret) } namespacedDockerConfig, err := namespacedPullSecret.GetDataValue(".dockerconfigjson") if err != nil { - return NewMachineOSConfig(oc, name), fmt.Errorf("Could not extract dockerConfig from the namespaced pull secret") + return NewMachineOSConfig(oc, name), fmt.Errorf("could not extract dockerConfig from the namespaced pull secret") } pullSecret := GetPullSecret(oc.AsAdmin()) pullSecretDockerConfig, err := pullSecret.GetDataValue(".dockerconfigjson") if err != nil { - return NewMachineOSConfig(oc, name), fmt.Errorf("Could not extract dockerConfig from the cluster's pull secret") + return NewMachineOSConfig(oc, name), fmt.Errorf("could not extract dockerConfig from the cluster's pull secret") } mergedDockerConfig, err := MergeDockerConfigs(pullSecretDockerConfig, namespacedDockerConfig) if err != nil { - return NewMachineOSConfig(oc, name), fmt.Errorf("Could not merge the namespaced pull-secret dockerconfig and the cluster's pull-secret docker config") + return NewMachineOSConfig(oc, name), fmt.Errorf("could not merge the namespaced pull-secret dockerconfig and the cluster's pull-secret docker config") } err = pullSecret.SetDataValue(".dockerconfigjson", mergedDockerConfig) if err != nil { - return NewMachineOSConfig(oc, name), fmt.Errorf("Could not configure the cluster's pull-secret with the merged dockerconfig") + return NewMachineOSConfig(oc, name), fmt.Errorf("could not configure the cluster's pull-secret with the merged dockerconfig") } logger.Infof("Waiting for the secret to be updated in all pools") @@ -302,7 +302,7 @@ func (mosc MachineOSConfig) GetMachineConfigPool() (*MachineConfigPool, error) { } if poolName == "" { logger.Errorf("Empty MachineConfigPool configured in %s", mosc) - return nil, fmt.Errorf("Empty MachineConfigPool configured in %s", mosc) + return nil, fmt.Errorf("empty MachineConfigPool configured in %s", mosc) } return NewMachineConfigPool(mosc.oc, poolName), nil @@ -323,7 +323,7 @@ func (mosc MachineOSConfig) GetCurrentMachineOSBuild() (*MachineOSBuild, error) } if mosbName == "" { - return nil, fmt.Errorf("Cannot find the current MOSB for %s. Annotation empty", mosc) + return nil, fmt.Errorf("cannot find the current MOSB for %s. Annotation empty", mosc) } return NewMachineOSBuild(mosc.GetOC(), mosbName), nil @@ -427,14 +427,14 @@ func CreateInternalRegistrySecretFromSA(oc *exutil.CLI, saName, saNamespace, sec logger.Infof("Use a master node to login to the internal registry using the new token") loginOut, loginErr := masterNode.DebugNodeWithChroot("podman", "login", InternalRegistrySvcURL, "-u", saName, "-p", saToken, "--authfile", tmpDockerConfigFile) if loginErr != nil { - return nil, fmt.Errorf("Error trying to login to internal registry:\nOutput:%s\nError:%s", loginOut, loginErr) + return nil, fmt.Errorf("error trying to login to internal registry:\nOutput:%s\nError:%s", loginOut, loginErr) } logger.Infof("Copy the docker.json file to local") // Because several MOSCs can be applied at the same time, MCDs can be restarted several times and it can cause a failure in the CopyToLocal method. We retry to mitigate this scenario err = Retry(5, 5*time.Second, func() error { return masterNode.CopyToLocal(tmpDockerConfigFile, tmpDockerConfigFile) }) if err != nil { - return nil, fmt.Errorf("Error copying the resulting authorization file to local") + return nil, fmt.Errorf("error copying the resulting authorization file to local") } logger.Infof("OK!") diff --git a/test/extended-priv/machineset.go b/test/extended-priv/machineset.go index 703aeeae95..4f82d781b8 100644 --- a/test/extended-priv/machineset.go +++ b/test/extended-priv/machineset.go @@ -275,7 +275,7 @@ func (ms MachineSet) GetArchitecture() (architecture.Architecture, error) { } if len(nodes) == 0 { - return architecture.UNKNOWN, fmt.Errorf("Machineset %s has no replicas, so we cannot get the architecture from any existing node", ms.GetName()) + return architecture.UNKNOWN, fmt.Errorf("machineset %s has no replicas, so we cannot get the architecture from any existing node", ms.GetName()) } narch, err := nodes[0].GetArchitecture() @@ -393,7 +393,7 @@ func (msl *MachineSetList) GetReplicas(comparison string, replicas int) ([]*Mach } if !validComparisson { - return nil, fmt.Errorf("The provided comparison %s is not in the allowed comparisons list %s", + return nil, fmt.Errorf("the provided comparison %s is not in the allowed comparisons list %s", comparison, allowedComparisson) } @@ -503,7 +503,7 @@ func convertUserDataToNewVersion(userData, newIgnitionVersion string) (string, e currentIgnitionVersionResult := gjson.Get(userData, "ignition.version") if !currentIgnitionVersionResult.Exists() || currentIgnitionVersionResult.String() == "" { logger.Debugf("Could not get ignition version from ignition userData: %s", userData) - return "", fmt.Errorf("Could not get ignition version from ignition userData. Enable debug GINKGO_TEST_ENABLE_DEBUG_LOG to get more info") + return "", fmt.Errorf("could not get ignition version from ignition userData. Enable debug GINKGO_TEST_ENABLE_DEBUG_LOG to get more info") } currentIgnitionVersion := currentIgnitionVersionResult.String() @@ -542,7 +542,7 @@ func ConvertUserDataIgnition3ToIgnition2(ignition3 string) (string, error) { merge := gjson.Get(ignition3, "ignition.config.merge") if !merge.Exists() { logger.Debugf("Could not find the 'merge' information in the ignition3 ignition config: %s", ignition3) - return "", fmt.Errorf("Could not find the 'merge' information in the ignition3 ignition config. Enable debug GINKGO_TEST_ENABLE_DEBUG_LOG to get more info") + return "", fmt.Errorf("could not find the 'merge' information in the ignition3 ignition config. Enable debug GINKGO_TEST_ENABLE_DEBUG_LOG to get more info") } ignition2, err = sjson.SetRaw(ignition2, "ignition.config.append", merge.String()) if err != nil { @@ -630,7 +630,7 @@ func GCPGetMachineSetBootDiskIndex(ms MachineSet) (int, error) { // Get the disks array from the MachineSet spec disksJSON, err := ms.Get(`{.spec.template.spec.providerSpec.value.disks}`) if err != nil { - return -1, fmt.Errorf("Failed to get disks array: %v", err) + return -1, fmt.Errorf("failed to get disks array: %v", err) } // Parse the disks array and find the boot disk @@ -642,7 +642,7 @@ func GCPGetMachineSetBootDiskIndex(ms MachineSet) (int, error) { } } - return -1, fmt.Errorf("No boot disk found in disks array (no disk with boot: true)") + return -1, fmt.Errorf("no boot disk found in disks array (no disk with boot: true)") } // AllNodesUpdated returns true if all nodes in this machineset are updated @@ -673,7 +673,7 @@ func GetScalableMachineSet(oc *exutil.CLI) (*MachineSet, error) { } if len(machinesets) == 0 { - return nil, fmt.Errorf("There is no machineset that can be used to scale nodes safely") + return nil, fmt.Errorf("there is no machineset that can be used to scale nodes safely") } return machinesets[0], nil diff --git a/test/extended-priv/mco_bootimages.go b/test/extended-priv/mco_bootimages.go index aa71dc1321..9320dff952 100644 --- a/test/extended-priv/mco_bootimages.go +++ b/test/extended-priv/mco_bootimages.go @@ -755,7 +755,7 @@ func getCoreOsBootImageFromConfigMap(platform, region string, arch architecture. switch platform { case AWSPlatform: if region == "" { - return "", fmt.Errorf("Region is empty for platform %s. The region is mandatory if we want to get the boot image value", platform) + return "", fmt.Errorf("region is empty for platform %s. The region is mandatory if we want to get the boot image value", platform) } coreOsBootImagePath = fmt.Sprintf(`architectures.%s.images.%s.regions.%s.image`, stringArch, platform, region) case GCPPlatform: diff --git a/test/extended-priv/mco_drain.go b/test/extended-priv/mco_drain.go index 85e5e42143..2e4adca596 100644 --- a/test/extended-priv/mco_drain.go +++ b/test/extended-priv/mco_drain.go @@ -76,7 +76,7 @@ var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/longdurati waitErr := wait.PollUntilContextTimeout(context.TODO(), 1*time.Minute, 15*time.Minute, immediate, func(_ context.Context) (bool, error) { logs, err := mcc.GetFilteredLogsAsList(workerNode.GetName() + ".*Drain failed") if err != nil { - return false, fmt.Errorf("Error getting filtered logs for node %s from %v: %w", workerNode.GetName(), mcc, err) + return false, fmt.Errorf("error getting filtered logs for node %s from %v: %w", workerNode.GetName(), mcc, err) } if len(logs) > 2 { // Get only 3 lines to avoid flooding the test logs, ignore the rest if any. @@ -100,7 +100,7 @@ var _ = g.Describe("[sig-mco][Suite:openshift/machine-config-operator/longdurati lWaitErr := wait.PollUntilContextTimeout(context.TODO(), 1*time.Minute, 15*time.Minute, immediate, func(_ context.Context) (bool, error) { logs, err := mcc.GetFilteredLogsAsList(workerNode.GetName() + ".*Drain has been failing for more than 10 minutes. Waiting 5 minutes") if err != nil { - return false, fmt.Errorf("Error getting filtered logs for node %s from %v: %w", workerNode.GetName(), mcc, err) + return false, fmt.Errorf("error getting filtered logs for node %s from %v: %w", workerNode.GetName(), mcc, err) } if len(logs) > 1 { // Get only 2 lines to avoid flooding the test logs, ignore the rest if any. diff --git a/test/extended-priv/mco_scale.go b/test/extended-priv/mco_scale.go index 4e7a6615a1..412b50236a 100644 --- a/test/extended-priv/mco_scale.go +++ b/test/extended-priv/mco_scale.go @@ -524,7 +524,7 @@ func GetRHCOSHandler(platform string) (RHCOSHandler, error) { case VspherePlatform: return VsphereRHCOSHandler{}, nil default: - return nil, fmt.Errorf("Platform %s is not supported and cannot get RHCOSHandler", platform) + return nil, fmt.Errorf("platform %s is not supported and cannot get RHCOSHandler", platform) } } @@ -548,7 +548,7 @@ func (aws AWSRHCOSHandler) GetBaseImageFromRHCOSImageInfo(version string, arch a } if region == "" { - return "", fmt.Errorf("Region cannot have an empty value when we try to get the base image in platform %s", platform) + return "", fmt.Errorf("region cannot have an empty value when we try to get the base image in platform %s", platform) } if CompareVersions(version, "<", "4.10") { path = `amis.` + region + `.hvm` @@ -561,7 +561,7 @@ func (aws AWSRHCOSHandler) GetBaseImageFromRHCOSImageInfo(version string, arch a baseImage := gjson.Get(rhcosImageInfo, path) if !baseImage.Exists() { logger.Infof("rhcos info:\n%s", rhcosImageInfo) - return "", fmt.Errorf("Could not find the base image for version <%s> in platform <%s> architecture <%s> and region <%s> with path %s", + return "", fmt.Errorf("could not find the base image for version <%s> in platform <%s> architecture <%s> and region <%s> with path %s", version, platform, arch, region, path) } return baseImage.String(), nil @@ -582,7 +582,7 @@ func (gcp GCPRHCOSHandler) GetBaseImageFromRHCOSImageInfo(version string, arch a ) if CompareVersions(version, "=", "4.1") { - return "", fmt.Errorf("There is no image base image supported for platform %s in version %s", platform, version) + return "", fmt.Errorf("there is no image base image supported for platform %s in version %s", platform, version) } rhcosImageInfo, err := getRHCOSImagesInfo(version) @@ -602,7 +602,7 @@ func (gcp GCPRHCOSHandler) GetBaseImageFromRHCOSImageInfo(version string, arch a baseImage := gjson.Get(rhcosImageInfo, imagePath) if !baseImage.Exists() { logger.Infof("rhcos info:\n%s", rhcosImageInfo) - return "", fmt.Errorf("Could not find the base image for version <%s> in platform <%s> architecture <%s> and region <%s> with path %s", + return "", fmt.Errorf("could not find the base image for version <%s> in platform <%s> architecture <%s> and region <%s> with path %s", version, platform, arch, region, imagePath) } @@ -610,7 +610,7 @@ func (gcp GCPRHCOSHandler) GetBaseImageFromRHCOSImageInfo(version string, arch a project := gjson.Get(rhcosImageInfo, projectPath) if !project.Exists() { logger.Infof("rhcos info:\n%s", rhcosImageInfo) - return "", fmt.Errorf("Could not find the project where the base image is stored with version <%s> in platform <%s> architecture <%s> and region <%s> with path %s", + return "", fmt.Errorf("could not find the project where the base image is stored with version <%s> in platform <%s> architecture <%s> and region <%s> with path %s", version, platform, arch, region, projectPath) } @@ -659,7 +659,7 @@ func getBaseImageURLFromRHCOSImageInfo(version, platform, format, stringArch str baseImageURL := gjson.Get(rhcosImageInfo, imagePath) if !baseImageURL.Exists() { logger.Infof("rhcos info:\n%s", rhcosImageInfo) - return "", fmt.Errorf("Could not find the base image for version <%s> in platform <%s> architecture <%s> and format <%s> with path %s", + return "", fmt.Errorf("could not find the base image for version <%s> in platform <%s> architecture <%s> and format <%s> with path %s", version, platform, stringArch, format, imagePath) } @@ -671,7 +671,7 @@ func getBaseImageURLFromRHCOSImageInfo(version, platform, format, stringArch str baseURI := gjson.Get(rhcosImageInfo, baseURIPath) if !baseURI.Exists() { logger.Infof("rhcos info:\n%s", rhcosImageInfo) - return "", fmt.Errorf("Could not find the base URI with version <%s> in platform <%s> architecture <%s> and format <%s> with path %s", + return "", fmt.Errorf("could not find the base URI with version <%s> in platform <%s> architecture <%s> and format <%s> with path %s", version, platform, stringArch, format, baseURIPath) } @@ -700,7 +700,7 @@ func uploadBaseImageToCloud(oc *exutil.CLI, platform, baseImageURL, baseImage st return nil default: - return fmt.Errorf("Platform %s is not supported, base image cannot be updloaded", platform) + return fmt.Errorf("platform %s is not supported, base image cannot be updloaded", platform) } } diff --git a/test/extended-priv/mco_security.go b/test/extended-priv/mco_security.go index 201c06f3e8..58b99e1c93 100644 --- a/test/extended-priv/mco_security.go +++ b/test/extended-priv/mco_security.go @@ -976,11 +976,11 @@ func BundleFileIsCATrusted(bundleFile string, node *Node) (bool, error) { ) if !bundleRemote.Exists() { - return false, fmt.Errorf("File %s does not exist", bundleRemote.GetFullPath()) + return false, fmt.Errorf("file %s does not exist", bundleRemote.GetFullPath()) } if !objsignCABundleRemote.Exists() { - return false, fmt.Errorf("File %s does not exist", objsignCABundleRemote.GetFullPath()) + return false, fmt.Errorf("file %s does not exist", objsignCABundleRemote.GetFullPath()) } err := bundleRemote.Fetch() @@ -1044,7 +1044,7 @@ func splitBundleCertificates(pemBundle []byte) ([]*x509.Certificate, error) { pemBundle = rest continue } - return nil, fmt.Errorf("Error parsing certificate: %s", err) + return nil, fmt.Errorf("error parsing certificate: %s", err) } certsList = append(certsList, cert) diff --git a/test/extended-priv/node.go b/test/extended-priv/node.go index d01de4ef55..6d02a01f9a 100644 --- a/test/extended-priv/node.go +++ b/test/extended-priv/node.go @@ -390,12 +390,12 @@ func (n *Node) GetBootedOsTreeDeployment(asJSON bool) (string, error) { func (n *Node) GetCurrentBootOSImage() (string, error) { deployment, err := n.GetBootedOsTreeDeployment(true) if err != nil { - return "", fmt.Errorf("Error getting the rpm-ostree status value.\n%s", err) + return "", fmt.Errorf("error getting the rpm-ostree status value.\n%s", err) } containerRef, jerr := JSON(deployment).GetSafe("container-image-reference") if jerr != nil { - return "", fmt.Errorf("We cant get 'container-image-reference' from the deployment status. Wrong rpm-ostree status!.\n%s\n%s", jerr, deployment) + return "", fmt.Errorf("we cant get 'container-image-reference' from the deployment status. Wrong rpm-ostree status!.\n%s\n%s", jerr, deployment) } logger.Infof("Current booted container-image-reference: %s", containerRef) @@ -403,7 +403,7 @@ func (n *Node) GetCurrentBootOSImage() (string, error) { imageSplit := strings.Split(containerRef.ToString(), ":") lenImageSplit := len(imageSplit) if lenImageSplit < 2 { - return "", fmt.Errorf("Wrong container-image-reference in deployment:\n%s\n%s", err, deployment) + return "", fmt.Errorf("wrong container-image-reference in deployment:\n%s\n%s", err, deployment) } // remove the "ostree-unverified-registry:" part of the image @@ -1061,7 +1061,7 @@ func (n *Node) GetRHELVersion() (string, error) { if len(match) == 0 { msg := fmt.Sprintf("No RHEL_VERSION available in /etc/os-release file: %s", vContent) logger.Errorf("%s", msg) - return "", fmt.Errorf("Error: %s", msg) + return "", fmt.Errorf("error: %s", msg) } rhelvIndex := r.SubexpIndex("rhel_version") @@ -1099,14 +1099,14 @@ func (n *Node) GetPrimaryPool() (*MachineConfigPool, error) { primaryPool = pool } else if pool.IsCustom() && primaryPool != nil && primaryPool.IsCustom() { // Error condition: the node belongs to 2 custom pools - return nil, fmt.Errorf("Forbidden configuration. The node %s belongs to 2 custom pools: %s and %s", + return nil, fmt.Errorf("forbidden configuration. The node %s belongs to 2 custom pools: %s and %s", node.GetName(), primaryPool.GetName(), pool.GetName()) } } } if primaryPool == nil { - return nil, fmt.Errorf("Could not find the primary pool for %s", n) + return nil, fmt.Errorf("could not find the primary pool for %s", n) } return primaryPool, nil @@ -1251,7 +1251,7 @@ func (n *Node) GetFileSystemSpaceUsage(path string) (*SpaceUsage, error) { lines := strings.Split(stdout, "\n") if len(lines) != 2 { - return nil, fmt.Errorf("Expected 2 lines, and got:\n%s", stdout) + return nil, fmt.Errorf("expected 2 lines, and got:\n%s", stdout) } logger.Debugf("parsing: %s", lines[1]) @@ -1265,21 +1265,21 @@ func (n *Node) GetFileSystemSpaceUsage(path string) (*SpaceUsage, error) { usedIndex := re.SubexpIndex("Used") if usedIndex < 0 { - return nil, fmt.Errorf("Could not parse Used bytes from\n%s", stdout) + return nil, fmt.Errorf("could not parse Used bytes from\n%s", stdout) } used, err := strconv.ParseInt(match[usedIndex], 10, 64) if err != nil { - return nil, fmt.Errorf("Could convert parsed Used data [%s] into float64 from\n%s", match[usedIndex], stdout) + return nil, fmt.Errorf("could convert parsed Used data [%s] into float64 from\n%s", match[usedIndex], stdout) } availIndex := re.SubexpIndex("Avail") if usedIndex < 0 { - return nil, fmt.Errorf("Could not parse Avail bytes from\n%s", stdout) + return nil, fmt.Errorf("could not parse Avail bytes from\n%s", stdout) } avail, err := strconv.ParseInt(match[availIndex], 10, 64) if err != nil { - return nil, fmt.Errorf("Could convert parsed Avail data [%s] into float64 from\n%s", match[availIndex], stdout) + return nil, fmt.Errorf("could convert parsed Avail data [%s] into float64 from\n%s", match[availIndex], stdout) } return &SpaceUsage{Used: used, Avail: avail}, nil @@ -1459,7 +1459,7 @@ func BreakRebaseInNode(node *Node) error { logger.Infof("Breaking rpm-ostree rebase process in node %s", node.GetName()) brokenRpmOstree := generateTemplateAbsolutePath("rpm-ostree-force-pivot-error.sh") if err := node.CopyFromLocal(brokenRpmOstree, "/tmp/rpm-ostree.broken"); err != nil { - return fmt.Errorf("Error copying %s to node %s: %w", brokenRpmOstree, node, err) + return fmt.Errorf("error copying %s to node %s: %w", brokenRpmOstree, node, err) } _, err := node.DebugNodeWithChroot("sh", "-c", "chmod +x /tmp/rpm-ostree.broken; "+ @@ -1488,7 +1488,7 @@ func GetOperatorNode(oc *exutil.CLI) (*Node, error) { } if len(mcoPods) != 1 { - return nil, fmt.Errorf("There should be 1 and only 1 MCO operator pod. Found operator pods: %s", mcoPods) + return nil, fmt.Errorf("there should be 1 and only 1 MCO operator pod. Found operator pods: %s", mcoPods) } nodeName, err := mcoPods[0].Get(`{.spec.nodeName}`) diff --git a/test/extended-priv/remote_images.go b/test/extended-priv/remote_images.go index 56ec2e3ab7..2946c1049f 100644 --- a/test/extended-priv/remote_images.go +++ b/test/extended-priv/remote_images.go @@ -35,7 +35,7 @@ func (ri RemoteImage) IsPinned() (bool, error) { pinned := gjson.Get(stdout, "images.0.pinned") if !pinned.Exists() { logger.Infof("%s:%s", ri, stdout) - return false, fmt.Errorf("Could not get pinned information for %s", ri) + return false, fmt.Errorf("could not get pinned information for %s", ri) } return pinned.Bool(), nil diff --git a/test/extended-priv/remotefile.go b/test/extended-priv/remotefile.go index b8bce45fa8..7fff28e078 100644 --- a/test/extended-priv/remotefile.go +++ b/test/extended-priv/remotefile.go @@ -119,7 +119,7 @@ func (rf *RemoteFile) PushNewContent(newContent []byte) error { return err } if !exists { - return fmt.Errorf("Node %s. file %s. Refuse to modify the content of a file that does not exist", rf.node.GetName(), rf.fullPath) + return fmt.Errorf("node %s. file %s. Refuse to modify the content of a file that does not exist", rf.node.GetName(), rf.fullPath) } tmpFile := filepath.Join(e2e.TestContext.OutputDir, fmt.Sprintf("fetch-%s", exutil.GetRandomString())) diff --git a/test/extended-priv/remotefile_gomegamatchers.go b/test/extended-priv/remotefile_gomegamatchers.go index 24cb1ad1a3..bbf4900a0d 100644 --- a/test/extended-priv/remotefile_gomegamatchers.go +++ b/test/extended-priv/remotefile_gomegamatchers.go @@ -27,7 +27,7 @@ func (matcher *remoteFileMethodMatcher) Match(actual interface{}) (success bool, if !ok { remoteFileObj, ok := actual.(RemoteFile) if !ok { - return false, fmt.Errorf(`Wrong type. Matcher expects a type "RemoteFile" or "*RemoteFile"`) + return false, fmt.Errorf(`wrong type. Matcher expects a type "RemoteFile" or "*RemoteFile"`) } remoteFilePtr = &remoteFileObj } diff --git a/test/extended-priv/resource.go b/test/extended-priv/resource.go index c604470659..f9c88b0b5c 100644 --- a/test/extended-priv/resource.go +++ b/test/extended-priv/resource.go @@ -363,7 +363,7 @@ func (r *Resource) GetLabel(label string) (string, error) { return "", err } if labelsJSON == "" { - return "", fmt.Errorf("Labels not defined. Could not get .metadata.labels attribute") + return "", fmt.Errorf("labels not defined. Could not get .metadata.labels attribute") } if err := json.Unmarshal([]byte(labelsJSON), &labels); err != nil { @@ -467,7 +467,7 @@ func (t *Template) SetTemplate(template string) { // provide the "-p NAMESPACE" argument to this function. func (t *Template) Create(parameters ...string) error { if t.templateFile == "" { - return fmt.Errorf("There is no template configured") + return fmt.Errorf("there is no template configured") } allParams := []string{"--ignore-unknown-parameters=true", "-f", t.templateFile} @@ -482,7 +482,7 @@ func (t *Template) Create(parameters ...string) error { // provide the "-p NAMESPACE" argument to this function. func (t *Template) Apply(parameters ...string) error { if t.templateFile == "" { - return fmt.Errorf("There is no template configured") + return fmt.Errorf("there is no template configured") } allParams := []string{"--ignore-unknown-parameters=true", "-f", t.templateFile} @@ -589,7 +589,7 @@ type existMatcher struct { func (matcher *existMatcher) Match(actual interface{}) (success bool, err error) { resource, ok := actual.(Exister) if !ok { - return false, fmt.Errorf("Exist matcher expects a resource implementing the Exister interface") + return false, fmt.Errorf("exist matcher expects a resource implementing the Exister interface") } return resource.Exists(), nil diff --git a/test/extended-priv/util.go b/test/extended-priv/util.go index 636e3685a9..dfa745f569 100644 --- a/test/extended-priv/util.go +++ b/test/extended-priv/util.go @@ -857,7 +857,7 @@ func GetCertificatesInfoFromPemBundle(bundleName string, pemBundle []byte) ([]Ce var certificatesInfo []CertificateInfo if pemBundle == nil { - return nil, fmt.Errorf("Provided pem bundle is nil") + return nil, fmt.Errorf("provided pem bundle is nil") } if len(pemBundle) == 0 { @@ -873,7 +873,7 @@ func GetCertificatesInfoFromPemBundle(bundleName string, pemBundle []byte) ([]Ce logger.Infof("FOUND: %s", block.Type) if block.Type != "CERTIFICATE" { - return nil, fmt.Errorf("Only CERTIFICATES are expected in the bundle, but a type %s was found in it", block.Type) + return nil, fmt.Errorf("only CERTIFICATES are expected in the bundle, but a type %s was found in it", block.Type) } cert, err := x509.ParseCertificate(block.Bytes) @@ -962,21 +962,21 @@ func getCertsFromKubeconfig(kubeconfig string) (string, error) { currentCtx := gjson.Get(JSONstring, "current-context") logger.Debugf("Context: %s\n", currentCtx) if !currentCtx.Exists() || currentCtx.String() == "" { - return "", fmt.Errorf("No current-contenxt in the provided kubeconfig") + return "", fmt.Errorf("no current-contenxt in the provided kubeconfig") } logger.Debugf("Current context: %s", currentCtx.String()) cluster := gjson.Get(JSONstring, `contexts.#(name=="`+currentCtx.String()+`").context.cluster`) if !cluster.Exists() || cluster.String() == "" { - return "", fmt.Errorf("No current cluster information for context %s in the provided kubeconfig", currentCtx.String()) + return "", fmt.Errorf("no current cluster information for context %s in the provided kubeconfig", currentCtx.String()) } logger.Debugf("Cluster: %s\n", cluster.String()) cert64 := gjson.Get(JSONstring, `clusters.#(name=="`+cluster.String()+`").cluster.certificate-authority-data`) if !cert64.Exists() || cert64.String() == "" { - return "", fmt.Errorf("No current certificate-authority-data information for context %s and cluster %s in the provided kubeconfig", currentCtx.String(), cluster.String()) + return "", fmt.Errorf("no current certificate-authority-data information for context %s and cluster %s in the provided kubeconfig", currentCtx.String(), cluster.String()) } cert, err := b64.StdEncoding.DecodeString(cert64.String()) @@ -1066,7 +1066,7 @@ func waitForAllMCOPodsReady(oc *exutil.CLI, timeout time.Duration) error { if waitErr != nil { _ = oc.AsAdmin().WithoutNamespace().Run("get").Args("pods", "-n", MachineConfigNamespace).Execute() - return fmt.Errorf("MCO pods were deleted in namespace %s, but they did not become ready", MachineConfigNamespace) + return fmt.Errorf("mco pods were deleted in namespace %s, but they did not become ready", MachineConfigNamespace) } return nil @@ -1264,7 +1264,7 @@ func getAlertsByName(oc *exutil.CLI, alertName string) ([]map[string]interface{} // Validate JSON if !gjson.Valid(allAlerts) { - return nil, fmt.Errorf("Cannot parse json string: %s", allAlerts) + return nil, fmt.Errorf("cannot parse json string: %s", allAlerts) } // Use gjson to filter alerts by name - translate JSONPath to gjson syntax @@ -1274,7 +1274,7 @@ func getAlertsByName(oc *exutil.CLI, alertName string) ([]map[string]interface{} filteredAlertsResult := gjson.Get(allAlerts, gjsonPath) if !filteredAlertsResult.IsArray() { - return nil, fmt.Errorf("Expected filtered alerts to be an array, but got: %s", filteredAlertsResult.String()) + return nil, fmt.Errorf("expected filtered alerts to be an array, but got: %s", filteredAlertsResult.String()) } // Convert gjson.Result array to []map[string]interface{} using Value() @@ -1282,7 +1282,7 @@ func getAlertsByName(oc *exutil.CLI, alertName string) ([]map[string]interface{} for _, alert := range filteredAlertsResult.Array() { alertMap, ok := alert.Value().(map[string]interface{}) if !ok { - return nil, fmt.Errorf("Error converting alert to map: %v", alert) + return nil, fmt.Errorf("error converting alert to map: %v", alert) } filteredAlerts = append(filteredAlerts, alertMap) } @@ -1345,7 +1345,7 @@ func UnwrapExecCode(err error) (int, error) { return exitError.ExitCode(), nil } } - return -1, fmt.Errorf("No exit code available in the provided error %s", err) + return -1, fmt.Errorf("no exit code available in the provided error %s", err) } func getTimeDifferenceInMinute(oldTimestamp, newTimestamp string) float64 { @@ -1520,7 +1520,7 @@ func getMachineConfigOperatorPod(oc *exutil.CLI) (string, error) { func WrapWithBracketsIfIpv6(ip string) (string, error) { parsedIP := net.ParseIP(ip) if parsedIP == nil { - return "", fmt.Errorf("The string %s is not a valid IP", ip) + return "", fmt.Errorf("the string %s is not a valid IP", ip) } // If it is an IPV6 address, wrap it diff --git a/test/extended-priv/util/vsphere.go b/test/extended-priv/util/vsphere.go index dc36178648..5ec501436e 100644 --- a/test/extended-priv/util/vsphere.go +++ b/test/extended-priv/util/vsphere.go @@ -307,39 +307,39 @@ func GetVSphereConnectionInfo(oc *CLI) (*VSphereConnectionInfo, error) { var info VSphereConnectionInfo failureDomain, err := oc.AsAdmin().WithoutNamespace().Run("get").Args("infrastructure", "cluster", "-o", "jsonpath={.spec.platformSpec.vsphere.failureDomains[0]}").Output() if err != nil { - return nil, fmt.Errorf("Cannot get the failureDomain from the infrastructure resource: %w", err) + return nil, fmt.Errorf("cannot get the failureDomain from the infrastructure resource: %w", err) } if failureDomain == "" { - return nil, fmt.Errorf("Empty failure domain in the infrastructure resource") + return nil, fmt.Errorf("empty failure domain in the infrastructure resource") } gserver := gjson.Get(failureDomain, "server") if !gserver.Exists() { - return nil, fmt.Errorf("Cannot get the server value from failureDomain") + return nil, fmt.Errorf("cannot get the server value from failureDomain") } info.Server = gserver.String() gdataCenter := gjson.Get(failureDomain, "topology.datacenter") if !gdataCenter.Exists() { - return nil, fmt.Errorf("Cannot get the data center value from failureDomain") + return nil, fmt.Errorf("cannot get the data center value from failureDomain") } info.DataCenter = gdataCenter.String() gdataStore := gjson.Get(failureDomain, "topology.datastore") if !gdataStore.Exists() { - return nil, fmt.Errorf("Cannot get the data store value from failureDomain") + return nil, fmt.Errorf("cannot get the data store value from failureDomain") } info.DataStore = gdataStore.String() gresourcePool := gjson.Get(failureDomain, "topology.resourcePool") if !gresourcePool.Exists() { - return nil, fmt.Errorf("Cannot get the resourcepool value from failureDomain") + return nil, fmt.Errorf("cannot get the resourcepool value from failureDomain") } info.ResourcePool = gresourcePool.String() gnetwork := gjson.Get(failureDomain, "topology.networks.0") if !gnetwork.Exists() { - return nil, fmt.Errorf("Cannot get the network value from failureDomain") + return nil, fmt.Errorf("cannot get the network value from failureDomain") } info.Network = gnetwork.String() @@ -357,7 +357,7 @@ func GetVSphereConnectionInfo(oc *CLI) (*VSphereConnectionInfo, error) { for k, vb64 := range dataMap { v, decErr := base64.StdEncoding.DecodeString(vb64) if decErr != nil { - return nil, fmt.Errorf("Cannot decode secret value for key %s: %w", k, decErr) + return nil, fmt.Errorf("cannot decode secret value for key %s: %w", k, decErr) } if strings.Contains(k, "username") { info.User = string(v) @@ -368,10 +368,10 @@ func GetVSphereConnectionInfo(oc *CLI) (*VSphereConnectionInfo, error) { } if info.User == "" { - return nil, fmt.Errorf("The vsphere user is empty") + return nil, fmt.Errorf("the vsphere user is empty") } if info.Password == "" { - return nil, fmt.Errorf("The vsphere password is empty") + return nil, fmt.Errorf("the vsphere password is empty") } return &info, nil diff --git a/test/helpers/utils.go b/test/helpers/utils.go index d106312d1b..5fa8601904 100644 --- a/test/helpers/utils.go +++ b/test/helpers/utils.go @@ -524,7 +524,7 @@ func GetMonitoringToken(_ *testing.T, cs *framework.ClientSet) (string, error) { metav1.CreateOptions{}, ) if err != nil { - return "", fmt.Errorf("Could not request openshift-monitoring token") + return "", fmt.Errorf("could not request openshift-monitoring token") } return token.Status.Token, nil } @@ -620,12 +620,12 @@ func ForceImageRegistryCertRotationCertificateRotation(cs *framework.ClientSet) func GetKubeletCABundleFromConfigmap(cs *framework.ClientSet) (string, error) { certBundle, err := cs.ConfigMaps("openshift-config-managed").Get(context.TODO(), "kube-apiserver-client-ca", metav1.GetOptions{}) if err != nil { - return "", fmt.Errorf("Could not get in-cluster kube-apiserver-client-ca configmap") + return "", fmt.Errorf("could not get in-cluster kube-apiserver-client-ca configmap") } if cert, ok := certBundle.Data["ca-bundle.crt"]; ok { return cert, nil } - return "", fmt.Errorf("Could not find ca-bundle") + return "", fmt.Errorf("could not find ca-bundle") } // Applies a given label to a node and returns an unlabel function.