Skip to content

Commit

Permalink
[YUNIKORN-2759] Replace %w by Errors.join (#884)
Browse files Browse the repository at this point in the history
Closes: #884

Signed-off-by: Peter Bacsko <[email protected]>
  • Loading branch information
ryankert01 authored and pbacsko committed Jul 26, 2024
1 parent 97b29d6 commit b947dca
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion pkg/admission/conf/am_conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package conf

import (
"errors"
"fmt"
"regexp"
"strconv"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/admission/namespace_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package admission

import (
"fmt"
"errors"

v1 "k8s.io/api/core/v1"
informersv1 "k8s.io/client-go/informers/core/v1"
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/admission/priority_class_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package admission

import (
"fmt"
"errors"

schedulingv1 "k8s.io/api/scheduling/v1"
informersv1 "k8s.io/client-go/informers/scheduling/v1"
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pkg/client/apifactory.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package client

import (
"fmt"
"errors"
"time"

"go.uber.org/zap"
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugin/predicates/predicate_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b947dca

Please sign in to comment.