@@ -63,14 +63,14 @@ type SyncController struct {
63
63
// The SyncController will requeue the Request to be processed again if an error is non-nil or
64
64
// Result.Requeue is true, otherwise upon completion it will remove the work from the queue.
65
65
func (c * SyncController ) Reconcile (ctx context.Context , req controllerruntime.Request ) (controllerruntime.Result , error ) {
66
- klog .V (4 ).Infof ("FederatedResourceQuota sync controller reconciling %s " , req .NamespacedName .String ())
66
+ klog .V (4 ).InfoS ("FederatedResourceQuota sync controller reconciling" , "namespacedName " , req .NamespacedName .String ())
67
67
68
68
quota := & policyv1alpha1.FederatedResourceQuota {}
69
69
if err := c .Client .Get (ctx , req .NamespacedName , quota ); err != nil {
70
70
if apierrors .IsNotFound (err ) {
71
- klog .V (4 ).Infof ("Begin to cleanup works created by federatedResourceQuota(%s) " , req .NamespacedName .String ())
71
+ klog .V (4 ).InfoS ("Begin to cleanup works created by federatedResourceQuota" , "namespacedName " , req .NamespacedName .String ())
72
72
if err = c .cleanUpWorks (ctx , req .Namespace , req .Name ); err != nil {
73
- klog .Errorf ( "Failed to cleanup works created by federatedResourceQuota(%s) " , req .NamespacedName .String ())
73
+ klog .ErrorS ( err , "Failed to cleanup works created by federatedResourceQuota" , "namespacedName " , req .NamespacedName .String ())
74
74
return controllerruntime.Result {}, err
75
75
}
76
76
return controllerruntime.Result {}, nil
@@ -79,18 +79,18 @@ func (c *SyncController) Reconcile(ctx context.Context, req controllerruntime.Re
79
79
}
80
80
81
81
if err := c .cleanUpOrphanWorks (ctx , quota ); err != nil {
82
- klog .Errorf ( "Failed to cleanup orphan works for federatedResourceQuota(%s), error: %v" , req .NamespacedName .String (), err )
82
+ klog .ErrorS ( err , "Failed to cleanup orphan works for federatedResourceQuota" , "namespacedName" , req .NamespacedName .String ())
83
83
return controllerruntime.Result {}, err
84
84
}
85
85
86
86
clusterList := & clusterv1alpha1.ClusterList {}
87
87
if err := c .Client .List (ctx , clusterList ); err != nil {
88
- klog .Errorf ( "Failed to list clusters, error: %v" , err )
88
+ klog .ErrorS ( err , "Failed to list clusters" )
89
89
return controllerruntime.Result {}, err
90
90
}
91
91
92
92
if err := c .buildWorks (ctx , quota , clusterList .Items ); err != nil {
93
- klog .Errorf ( "Failed to build works for federatedResourceQuota(%s), error: %v" , req .NamespacedName .String (), err )
93
+ klog .ErrorS ( err , "Failed to build works for federatedResourceQuota" , "namespacedName" , req .NamespacedName .String ())
94
94
c .EventRecorder .Eventf (quota , corev1 .EventTypeWarning , events .EventReasonSyncFederatedResourceQuotaFailed , err .Error ())
95
95
return controllerruntime.Result {}, err
96
96
}
@@ -114,7 +114,7 @@ func (c *SyncController) SetupWithManager(mgr controllerruntime.Manager) error {
114
114
115
115
FederatedResourceQuotaList := & policyv1alpha1.FederatedResourceQuotaList {}
116
116
if err := c .Client .List (ctx , FederatedResourceQuotaList ); err != nil {
117
- klog .Errorf ( "Failed to list FederatedResourceQuota, error: %v" , err )
117
+ klog .ErrorS ( err , "Failed to list FederatedResourceQuota" )
118
118
}
119
119
120
120
for _ , federatedResourceQuota := range FederatedResourceQuotaList .Items {
@@ -189,14 +189,14 @@ func (c *SyncController) cleanUpWorks(ctx context.Context, namespace, name strin
189
189
util .FederatedResourceQuotaNamespaceLabel : namespace ,
190
190
util .FederatedResourceQuotaNameLabel : name ,
191
191
}); err != nil {
192
- klog .Errorf ( "Failed to list works, err: %v" , err )
192
+ klog .ErrorS ( err , "Failed to list works" )
193
193
return err
194
194
}
195
195
196
196
for index := range workList .Items {
197
197
work := & workList .Items [index ]
198
198
if err := c .Delete (ctx , work ); err != nil && ! apierrors .IsNotFound (err ) {
199
- klog .Errorf ( "Failed to delete work(%s): %v" , klog .KObj (work ).String (), err )
199
+ klog .ErrorS ( err , "Failed to delete work" , "work" , klog .KObj (work ).String ())
200
200
errs = append (errs , err )
201
201
}
202
202
}
@@ -211,7 +211,7 @@ func (c *SyncController) cleanUpOrphanWorks(ctx context.Context, quota *policyv1
211
211
util .FederatedResourceQuotaNamespaceLabel : quota .GetNamespace (),
212
212
util .FederatedResourceQuotaNameLabel : quota .GetName (),
213
213
}); err != nil {
214
- klog .Errorf ( "Failed to list works, err: %v" , err )
214
+ klog .ErrorS ( err , "Failed to list works" )
215
215
return err
216
216
}
217
217
@@ -221,7 +221,7 @@ func (c *SyncController) cleanUpOrphanWorks(ctx context.Context, quota *policyv1
221
221
continue
222
222
}
223
223
if err := c .Delete (ctx , work ); err != nil && ! apierrors .IsNotFound (err ) {
224
- klog .Errorf ( "Failed to delete work(%s): %v" , klog .KObj (work ).String (), err )
224
+ klog .ErrorS ( err , "Failed to delete work" , "work" , klog .KObj (work ).String ())
225
225
errs = append (errs , err )
226
226
}
227
227
}
@@ -246,7 +246,7 @@ func (c *SyncController) buildWorks(ctx context.Context, quota *policyv1alpha1.F
246
246
247
247
resourceQuotaObj , err := helper .ToUnstructured (resourceQuota )
248
248
if err != nil {
249
- klog .Errorf ( "Failed to transform resourceQuota(%s), error: %v" , klog .KObj (resourceQuota ).String (), err )
249
+ klog .ErrorS ( err , "Failed to transform resourceQuota" , "resourceQuota" , klog .KObj (resourceQuota ).String ())
250
250
errs = append (errs , err )
251
251
continue
252
252
}
0 commit comments