Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions cmd/apiserver-watcher/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment thread
anandram2 marked this conversation as resolved.
}

c := make(chan os.Signal, 1)
Expand All @@ -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)
}
}
}
Expand All @@ -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())
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion devex/cmd/mco-sanitize/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/bootimage/boot_image_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/bootimage/cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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)
}
}

Expand All @@ -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
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/bootimage/cpms_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/bootimage/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions pkg/controller/bootimage/ms_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/bootimage/vsphere_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/bootstrap/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/build/buildrequest/buildrequest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/build/osbuildcontroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/certrotation/certrotation_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

}

Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/certrotation/hostnames.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller/common/featuregates.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/common/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
8 changes: 4 additions & 4 deletions pkg/controller/container-runtime-config/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
Loading