diff --git a/pkg/admission/conf/am_conf.go b/pkg/admission/conf/am_conf.go index e78d16699..fd2edf670 100644 --- a/pkg/admission/conf/am_conf.go +++ b/pkg/admission/conf/am_conf.go @@ -19,6 +19,7 @@ package conf import ( + "errors" "fmt" "regexp" "strconv" @@ -117,7 +118,7 @@ func NewAdmissionControllerConf(configMaps []*v1.ConfigMap) *AdmissionController func (acc *AdmissionControllerConf) RegisterHandlers(configMaps informersv1.ConfigMapInformer) error { _, err := configMaps.Informer().AddEventHandler(&configMapUpdateHandler{conf: acc}) if err != nil { - return fmt.Errorf("failed to create register handlers: %w", err) + return errors.Join(errors.New("failed to create register handlers: "), err) } return nil diff --git a/pkg/admission/namespace_cache.go b/pkg/admission/namespace_cache.go index 963ffc27b..3d281f75c 100644 --- a/pkg/admission/namespace_cache.go +++ b/pkg/admission/namespace_cache.go @@ -19,7 +19,7 @@ package admission import ( - "fmt" + "errors" v1 "k8s.io/api/core/v1" informersv1 "k8s.io/client-go/informers/core/v1" @@ -62,7 +62,7 @@ func NewNamespaceCache(namespaces informersv1.NamespaceInformer) (*NamespaceCach if namespaces != nil { _, err := namespaces.Informer().AddEventHandler(&namespaceUpdateHandler{cache: nsc}) if err != nil { - return nil, fmt.Errorf("failed to create namespace cache: %w", err) + return nil, errors.Join(errors.New("failed to create namespace cache: "), err) } } return nsc, nil diff --git a/pkg/admission/priority_class_cache.go b/pkg/admission/priority_class_cache.go index 87a4dd873..94de30172 100644 --- a/pkg/admission/priority_class_cache.go +++ b/pkg/admission/priority_class_cache.go @@ -19,7 +19,7 @@ package admission import ( - "fmt" + "errors" schedulingv1 "k8s.io/api/scheduling/v1" informersv1 "k8s.io/client-go/informers/scheduling/v1" @@ -45,7 +45,7 @@ func NewPriorityClassCache(priorityClasses informersv1.PriorityClassInformer) (* if priorityClasses != nil { _, err := priorityClasses.Informer().AddEventHandler(&priorityClassUpdateHandler{cache: pcc}) if err != nil { - return nil, fmt.Errorf("failed to create a new cache and register the handler: %w", err) + return nil, errors.Join(errors.New("failed to create a new cache and register the handler: "), err) } } return pcc, nil diff --git a/pkg/client/apifactory.go b/pkg/client/apifactory.go index 050b380dc..3f1cb2b76 100644 --- a/pkg/client/apifactory.go +++ b/pkg/client/apifactory.go @@ -19,7 +19,7 @@ package client import ( - "fmt" + "errors" "time" "go.uber.org/zap" @@ -167,7 +167,7 @@ func (s *APIFactory) AddEventHandler(handlers *ResourceEventHandlers) error { log.Log(log.ShimClient).Info("registering event handler", zap.Stringer("type", handlers.Type)) if err := s.addEventHandlers(handlers.Type, h, 0); err != nil { - return fmt.Errorf("failed to initialize event handlers: %w", err) + return errors.Join(errors.New("failed to initialize event handlers: "), err) } return nil } @@ -200,7 +200,7 @@ func (s *APIFactory) addEventHandlers( } if err != nil { - return fmt.Errorf("failed to add event handlers: %w", err) + return errors.Join(errors.New("failed to add event handlers: "), err) } return nil } diff --git a/pkg/plugin/predicates/predicate_manager.go b/pkg/plugin/predicates/predicate_manager.go index d2db4675d..b20af3276 100644 --- a/pkg/plugin/predicates/predicate_manager.go +++ b/pkg/plugin/predicates/predicate_manager.go @@ -222,7 +222,7 @@ func (p *predicateManagerImpl) runPreFilterPlugins(ctx context.Context, state *f zap.String("pluginName", plugin), zap.String("pod", fmt.Sprintf("%s/%s", pod.Namespace, pod.Name)), zap.Error(err)) - return framework.AsStatus(fmt.Errorf("running PreFilter plugin %q: %w", plugin, err)), plugin, skip + return framework.AsStatus(errors.Join(fmt.Errorf("running PreFilter plugin %q: ", plugin), err)), plugin, skip } // Merge is nil safe and returns a new PreFilterResult result if mergedNodes was nil mergedNodes = mergedNodes.Merge(nodes)