@@ -18,13 +18,14 @@ package controllers
1818
1919import (
2020 "context"
21+ "errors"
2122 "fmt"
2223 "strings"
2324 "time"
2425
2526 "github.com/go-logr/logr"
2627 corev1 "k8s.io/api/core/v1"
27- "k8s.io/apimachinery/pkg/api/errors"
28+ apierrors "k8s.io/apimachinery/pkg/api/errors"
2829 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2930 "k8s.io/apimachinery/pkg/runtime"
3031 ctrl "sigs.k8s.io/controller-runtime"
@@ -105,7 +106,7 @@ func (r *FluentdConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques
105106 var fluentdList fluentdv1alpha1.FluentdList
106107 // List all fluentd instances to bind the generated runtime configuration to each fluentd
107108 if err := r .List (ctx , & fluentdList ); err != nil {
108- if errors .IsNotFound (err ) {
109+ if apierrors .IsNotFound (err ) {
109110 r .Log .Info ("can not find fluentd CR definition." )
110111 return ctrl.Result {Requeue : true , RequeueAfter : time .Duration (1 )}, nil
111112 }
@@ -146,13 +147,13 @@ func (r *FluentdConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques
146147 cfgResouces , errs := gpr .PatchAndFilterNamespacedLevelResources (sl , fmt .Sprintf ("%s-%s-%s" , fd .Kind , fd .Namespace , fd .Name ), inputs , filters , outputs )
147148 if len (errs ) > 0 {
148149 r .Log .Info ("Patch and filter namespace level resources failed" , "config" , "default" , "err" , strings .Join (errs , "," ))
149- return ctrl.Result {}, fmt . Errorf (strings .Join (errs , "," ))
150+ return ctrl.Result {}, errors . New (strings .Join (errs , "," ))
150151 }
151152
152153 err = gpr .IdentifyCopyAndPatchOutput (cfgResouces )
153154 if err != nil {
154155 r .Log .Info ("IdentifyCopy and PatchOutput namespace level resources failed" , "config" , "default" , "err" , strings .Join (errs , "," ))
155- return ctrl.Result {}, fmt . Errorf (strings .Join (errs , "," ))
156+ return ctrl.Result {}, errors . New (strings .Join (errs , "," ))
156157 }
157158
158159 // WithCfgResources will collect all plugins to generate main config
@@ -172,7 +173,7 @@ func (r *FluentdConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques
172173 var clustercfgs fluentdv1alpha1.ClusterFluentdConfigList
173174 // Use fluentd selector to match the cluster config.
174175 if err := r .List (ctx , & clustercfgs , client.MatchingLabelsSelector {Selector : fdSelector }); err != nil {
175- if ! errors .IsNotFound (err ) {
176+ if ! apierrors .IsNotFound (err ) {
176177 return ctrl.Result {}, err
177178 }
178179 }
@@ -184,7 +185,7 @@ func (r *FluentdConfigReconciler) Reconcile(ctx context.Context, req ctrl.Reques
184185 var cfgs fluentdv1alpha1.FluentdConfigList
185186 // Use fluentd selector to match the cluster config
186187 if err := r .List (ctx , & cfgs , client.MatchingLabelsSelector {Selector : fdSelector }); err != nil {
187- if ! errors .IsNotFound (err ) {
188+ if ! apierrors .IsNotFound (err ) {
188189 return ctrl.Result {}, err
189190 }
190191 }
0 commit comments