This is an automated email from the ASF dual-hosted git repository.

pbacsko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/yunikorn-k8shim.git


The following commit(s) were added to refs/heads/master by this push:
     new b947dcad [YUNIKORN-2759] Replace %w by Errors.join (#884)
b947dcad is described below

commit b947dcad49c6d49ff3730baa6d3d0f9196491efc
Author: Hsien-Cheng(Ryan) Huang <[email protected]>
AuthorDate: Fri Jul 26 14:41:26 2024 +0200

    [YUNIKORN-2759] Replace %w by Errors.join (#884)
    
    Closes: #884
    
    Signed-off-by: Peter Bacsko <[email protected]>
---
 pkg/admission/conf/am_conf.go              | 3 ++-
 pkg/admission/namespace_cache.go           | 4 ++--
 pkg/admission/priority_class_cache.go      | 4 ++--
 pkg/client/apifactory.go                   | 6 +++---
 pkg/plugin/predicates/predicate_manager.go | 2 +-
 5 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/pkg/admission/conf/am_conf.go b/pkg/admission/conf/am_conf.go
index e78d1669..fd2edf67 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 963ffc27..3d281f75 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 87a4dd87..94de3017 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 050b380d..3f1cb2b7 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 d2db4675..b20af327 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)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to