1
1
/*
2
- Copyright 2019 The Kubernetes Authors.
2
+ Copyright 2025 The Kubernetes Authors.
3
3
4
4
Licensed under the Apache License, Version 2.0 (the "License");
5
5
you may not use this file except in compliance with the License.
@@ -26,10 +26,9 @@ import (
26
26
"sync"
27
27
"time"
28
28
29
- "github.com/go-logr/logr"
30
- "github.com/google/uuid"
31
29
vmoperatorv1alpha4 "github.com/vmware-tanzu/vm-operator/api/v1alpha4"
32
30
cnstypes "github.com/vmware/govmomi/cns/types"
31
+ "go.uber.org/zap"
33
32
corev1 "k8s.io/api/core/v1"
34
33
35
34
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -38,7 +37,6 @@ import (
38
37
"k8s.io/client-go/kubernetes/scheme"
39
38
typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
40
39
"k8s.io/client-go/tools/record"
41
- ctrl "sigs.k8s.io/controller-runtime"
42
40
"sigs.k8s.io/controller-runtime/pkg/client"
43
41
"sigs.k8s.io/controller-runtime/pkg/controller"
44
42
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
@@ -90,7 +88,7 @@ func Add(mgr manager.Manager, clusterFlavor cnstypes.CnsClusterFlavor,
90
88
coCommonInterface , err = commonco .GetContainerOrchestratorInterface (ctx ,
91
89
common .Kubernetes , clusterFlavor , & syncer .COInitParams )
92
90
if err != nil {
93
- log .Errorf ("failed to create CO agnostic interface. Er r : %v" , err )
91
+ log .Errorf ("failed to create CO agnostic interface. error : %v" , err )
94
92
return err
95
93
}
96
94
var err error
@@ -102,7 +100,7 @@ func Add(mgr manager.Manager, clusterFlavor cnstypes.CnsClusterFlavor,
102
100
log .Info ("Creating CnsVolumeInfo Service to persist mapping for VolumeID to storage policy info" )
103
101
volumeInfoService , err = cnsvolumeinfo .InitVolumeInfoService (ctx )
104
102
if err != nil {
105
- return logger .LogNewErrorf (log , "error initializing volumeInfoService. Error : %+v" , err )
103
+ return logger .LogNewErrorf (log , "error initializing volumeInfoService. error : %+v" , err )
106
104
}
107
105
log .Info ("Successfully initialized VolumeInfoService" )
108
106
} else {
@@ -112,18 +110,18 @@ func Add(mgr manager.Manager, clusterFlavor cnstypes.CnsClusterFlavor,
112
110
// Initializes kubernetes client.
113
111
k8sclient , err := k8s .NewClient (ctx )
114
112
if err != nil {
115
- log .Errorf ("Creating Kubernetes client failed. Err : %v" , err )
113
+ log .Errorf ("Creating Kubernetes client failed. error : %v" , err )
116
114
return err
117
115
}
118
116
restClientConfig , err := k8s .GetKubeConfig (ctx )
119
117
if err != nil {
120
- msg := fmt .Sprintf ("Failed to initialize rest clientconfig. Error : %+v" , err )
118
+ msg := fmt .Sprintf ("Failed to initialize rest clientconfig. error : %+v" , err )
121
119
log .Error (msg )
122
120
return err
123
121
}
124
122
vmOperatorClient , err := k8s .NewClientForGroup (ctx , restClientConfig , vmoperatorv1alpha4 .GroupName )
125
123
if err != nil {
126
- msg := fmt .Sprintf ("Failed to initialize vmOperatorClient. Error : %+v" , err )
124
+ msg := fmt .Sprintf ("Failed to initialize vmOperatorClient. error : %+v" , err )
127
125
log .Error (msg )
128
126
return err
129
127
}
@@ -136,16 +134,15 @@ func Add(mgr manager.Manager, clusterFlavor cnstypes.CnsClusterFlavor,
136
134
Interface : k8sclient .CoreV1 ().Events ("" ),
137
135
},
138
136
)
139
- logger := ctrl .Log .WithName ("controllers" ).WithName ("VirtualMachineSnapshot" )
140
137
recorder := eventBroadcaster .NewRecorder (scheme .Scheme , corev1.EventSource {Component : apis .GroupName })
141
138
return add (mgr , newReconciler (mgr , configInfo , volumeManager ,
142
- recorder , vmOperatorClient , volumeInfoService , logger ))
139
+ recorder , vmOperatorClient , volumeInfoService ))
143
140
}
144
141
145
142
// newReconciler returns a new reconcile.Reconciler.
146
143
func newReconciler (mgr manager.Manager , configInfo * commonconfig.ConfigurationInfo ,
147
144
volumeManager volumes.Manager , recorder record.EventRecorder , vmOperatorClient client.Client ,
148
- volumeInfoService cnsvolumeinfo.VolumeInfoService , logger logr. Logger ) reconcile.Reconciler {
145
+ volumeInfoService cnsvolumeinfo.VolumeInfoService ) reconcile.Reconciler {
149
146
return & ReconcileVirtualMachineSnapshot {
150
147
client : mgr .GetClient (),
151
148
scheme : mgr .GetScheme (),
@@ -154,7 +151,6 @@ func newReconciler(mgr manager.Manager, configInfo *commonconfig.ConfigurationIn
154
151
recorder : recorder ,
155
152
vmOperatorClient : vmOperatorClient ,
156
153
volumeInfoService : volumeInfoService ,
157
- Logger : logger ,
158
154
}
159
155
}
160
156
@@ -196,7 +192,6 @@ type ReconcileVirtualMachineSnapshot struct {
196
192
recorder record.EventRecorder
197
193
volumeInfoService cnsvolumeinfo.VolumeInfoService
198
194
vmOperatorClient client.Client
199
- Logger logr.Logger
200
195
}
201
196
202
197
// Reconcile reads that state of the cluster for a VirtualMachineSnapshot object and
@@ -207,24 +202,24 @@ type ReconcileVirtualMachineSnapshot struct {
207
202
// will remove the work from the queue.
208
203
func (r * ReconcileVirtualMachineSnapshot ) Reconcile (ctx context.Context ,
209
204
request reconcile.Request ) (reconcile.Result , error ) {
210
- traceId := uuid .NewString ()
211
- logger := r .Logger .WithValues ("name" , request .NamespacedName , "trace" , traceId )
205
+ _ , log := logger .GetNewContextWithLogger ()
212
206
now := time .Now ()
213
- logger . Info ("Reconcile Started" )
207
+ log . Infof ("Reconcile Started for VirtualMachineSnapshot %s/%s" , request . Namespace , request . Name )
214
208
defer func () {
215
- logger .Info ("Reconcile Completed" , "Time Taken" , time .Since (now ))
209
+ log .Infof ("Reconcile Completed for virtualmachinesnapshot %s/%s Time Taken %v" ,
210
+ request .Namespace , request .Name , time .Since (now ))
216
211
}()
217
212
// Fetch the VirtualMachineSnapshot instance.
218
213
vmSnapshot := & vmoperatorv1alpha4.VirtualMachineSnapshot {}
219
214
err := r .client .Get (ctx , request .NamespacedName , vmSnapshot )
220
215
if err != nil {
221
216
if apierrors .IsNotFound (err ) {
222
- logger . Info ("resource not found. Ignoring since object must be deleted" ,
223
- "VMSnapshotName" , request .Name , "VMSnapshotNamespace" , request .Namespace )
217
+ log . Infof ("resource not found. Ignoring since object must be deleted for vmsnapshot %s/%s " ,
218
+ request .Namespace , request .Name )
224
219
return reconcile.Result {}, nil
225
220
}
226
- logger . Error ( err , "error while fetch the VirtualMachineSnapshot " ,
227
- "VMSnapshotName" , request .Name , "VMSnapshotNamespace" , request . Namespace )
221
+ log . Errorf ( "error while fetch the virtualmachinesnapshot %s/%s. error: %v " ,
222
+ request . Namespace , request .Name , err )
228
223
// Error reading the object - return with err.
229
224
return reconcile.Result {}, err
230
225
}
@@ -238,9 +233,9 @@ func (r *ReconcileVirtualMachineSnapshot) Reconcile(ctx context.Context,
238
233
timeout = backOffDuration [request .NamespacedName ]
239
234
backOffDurationMapMutex .Unlock ()
240
235
241
- logger . Info ("Reconciling virtualmachinesnapshot" ,
242
- "VMSnapshotName" , request .Name , "VMSnapshotNamespace" , request .Namespace )
243
- err = r .reconcileNormal (ctx , logger , vmSnapshot )
236
+ log . Infof ("Reconciling virtualmachinesnapshot %s/%s " ,
237
+ request .Namespace , request .Name )
238
+ err = r .reconcileNormal (ctx , log , vmSnapshot )
244
239
if err != nil {
245
240
return reconcile.Result {RequeueAfter : timeout }, err
246
241
}
@@ -249,19 +244,19 @@ func (r *ReconcileVirtualMachineSnapshot) Reconcile(ctx context.Context,
249
244
backOffDurationMapMutex .Unlock ()
250
245
return reconcile.Result {}, nil
251
246
}
252
- func (r * ReconcileVirtualMachineSnapshot ) reconcileNormal (ctx context.Context , logger logr. Logger ,
247
+ func (r * ReconcileVirtualMachineSnapshot ) reconcileNormal (ctx context.Context , log * zap. SugaredLogger ,
253
248
vmsnapshot * vmoperatorv1alpha4.VirtualMachineSnapshot ) error {
254
249
deleteVMSnapshot := false
255
250
if vmsnapshot .DeletionTimestamp .IsZero () {
256
251
// If the finalizer is not present, add it.
257
- logger . Info ("reconcileNormal: Adding finalizer on virtualmachinesnapshot cr" , "VMSnapshotName" , vmsnapshot . Name ,
258
- "VMSnapshotNamespace" , vmsnapshot .Namespace , "Finalizer" , SyncVolumeFinalizer )
252
+ log . Infof ("reconcileNormal: Adding finalizer %s on virtualmachinesnapshot cr %s/%s" ,
253
+ SyncVolumeFinalizer , vmsnapshot .Namespace , vmsnapshot . Name )
259
254
vmSnapshotPatch := client .MergeFrom (vmsnapshot .DeepCopy ())
260
255
if controllerutil .AddFinalizer (vmsnapshot , SyncVolumeFinalizer ) {
261
256
err := r .client .Patch (ctx , vmsnapshot , vmSnapshotPatch )
262
257
if err != nil {
263
- logger . Error ( err , "reconcileNormal: error while add finalizer to virtualmachinesnapshot CR" ,
264
- "VMSnapshotName " , vmsnapshot .Name , "VMSnapshotNamespace" , vmsnapshot .Name )
258
+ log . Errorf ( "reconcileNormal: error while add finalizer to " +
259
+ "virtualmachinesnapshot %s/%s. error: %v " , vmsnapshot .Name , vmsnapshot .Name , err )
265
260
return err
266
261
}
267
262
return nil
@@ -270,13 +265,13 @@ func (r *ReconcileVirtualMachineSnapshot) reconcileNormal(ctx context.Context, l
270
265
if ! vmsnapshot .DeletionTimestamp .IsZero () &&
271
266
controllerutil .ContainsFinalizer (vmsnapshot , SyncVolumeFinalizer ) {
272
267
if ! controllerutil .ContainsFinalizer (vmsnapshot , VMSnapshotFinalizer ) {
273
- logger . Info ("reconcileNormal: virtualmachinesnapshot is set to delete" ,
274
- "VMSnapshotName" , vmsnapshot .Name , "VMSnapshotNamespace" , vmsnapshot .Namespace )
268
+ log . Infof ("reconcileNormal: virtualmachinesnapshot %s/%s is set to delete" ,
269
+ vmsnapshot .Namespace , vmsnapshot .Name )
275
270
deleteVMSnapshot = true
276
271
} else {
277
- logger . Info ("reconcileNormal: virtualmachinesnapshot is set to delete, " +
278
- "expecting to remove VMSnapshotFinalizer first" , "VMSnapshotName" , vmsnapshot .Name ,
279
- "VMSnapshotNamespace" , vmsnapshot . Namespace )
272
+ log . Infof ("reconcileNormal: virtualmachinesnapshot %s/%s is set to delete, " +
273
+ "expecting to remove %s first" , vmsnapshot . Namespace , vmsnapshot .Name ,
274
+ VMSnapshotFinalizer )
280
275
return nil
281
276
}
282
277
}
@@ -290,52 +285,52 @@ func (r *ReconcileVirtualMachineSnapshot) reconcileNormal(ctx context.Context, l
290
285
Namespace : vmsnapshot .Namespace ,
291
286
Name : vmsnapshot .Spec .VMRef .Name ,
292
287
}
293
- logger .Info ("reconcileNormal: get virtulal machine" , "VirtualMachineName" , vmKey .Name ,
294
- "VirtualMachineNamespace" , vmKey .Namespace )
288
+ log .Infof ("reconcileNormal: get virtulal machine %s/%s" , vmKey .Namespace , vmKey .Name )
295
289
virtualMachine , _ , err := utils .GetVirtualMachineAllApiVersions (ctx , vmKey ,
296
290
r .vmOperatorClient )
297
291
if err != nil {
298
- logger . Error ( err , " could not get VirtualMachine" , "VirtualMachineName" , vmKey . Name ,
299
- "VirtualMachineNamespace" , vmKey .Namespace )
292
+ log . Errorf ( "reconcileNormal: could not get VirtualMachine %s/%s. error: %v" ,
293
+ vmKey . Namespace , vmKey .Name , err )
300
294
return err
301
295
}
302
- logger . Info ("reconcileNormal: sync and update storage quota for vmsnapshot" ,
303
- "VMSnapshotName" , vmsnapshot .Name , "VMSnapshotNamespace" , vmsnapshot .Namespace )
304
- err = r .syncVolumesAndUpdateCNSVolumeInfo (ctx , logger , virtualMachine )
296
+ log . Infof ("reconcileNormal: sync and update storage quota for vmsnapshot %s/%s " ,
297
+ vmsnapshot .Namespace , vmsnapshot .Name )
298
+ err = r .syncVolumesAndUpdateCNSVolumeInfo (ctx , log , virtualMachine )
305
299
if err != nil {
306
- logger . Error ( err , "Failed to validate VirtualMachineSnapshot" , "VMSnapshotName" , vmsnapshot . Name ,
307
- "VMSnapshotNamespace" , vmsnapshot .Namespace )
300
+ log . Errorf ( "reconcileNormal: failed to validate VirtualMachineSnapshot %s/%s. error: %v" ,
301
+ vmsnapshot . Namespace , vmsnapshot .Name , err )
308
302
return err
309
303
}
310
- logger . Info ("reconcileNormal: successfully synced and updated storage quota for vmsnapshot" ,
311
- "VMSnapshotName" , vmsnapshot .Name , "VMSnapshotNamespace" , vmsnapshot .Namespace )
304
+ log . Infof ("reconcileNormal: successfully synced and updated storage quota for vmsnapshot %s/%s " ,
305
+ vmsnapshot .Namespace , vmsnapshot .Name )
312
306
if deleteVMSnapshot {
313
- logger . Info ( "deleting virtualmachinesnapshot" , "VMSnapshotName" , vmsnapshot . Name ,
314
- "VMSnapshotNamespace" , vmsnapshot .Namespace , "SyncVolumeFinalizer" , SyncVolumeFinalizer )
307
+ log . Infof ( "reconcileNormal: remove finalizer %s for virtualmachinesnapshot %s/%s" ,
308
+ SyncVolumeFinalizer , vmsnapshot .Namespace , vmsnapshot . Name )
315
309
vmSnapshotPatch := client .MergeFrom (vmsnapshot .DeepCopy ())
316
310
if controllerutil .RemoveFinalizer (vmsnapshot , SyncVolumeFinalizer ) {
317
311
err = r .client .Patch (ctx , vmsnapshot , vmSnapshotPatch )
318
312
if err != nil {
319
- logger .Error (err , "failed to remove finalizer for VirtualMachineSnapshot CR" ,
320
- "VMSnapshotName" , vmsnapshot .Name , "VMSnapshotNamespace" , vmsnapshot .Namespace )
313
+ log .Errorf ("reconcileNormal: failed to remove finalizer for " +
314
+ "virtualmachinesnapshot %s/%s. error: %v" , vmsnapshot .Namespace ,
315
+ vmsnapshot .Name , err )
321
316
return err
322
317
}
323
318
return nil
324
319
}
325
320
}
326
321
// Update VMSnapshot CR annotation to "csi.vsphere.volume.sync: completed"
327
- logger . Info ("reconcileNormal: update vmsnapshot annotation value to completed" ,
328
- "VMSnapshotName" , vmsnapshot .Name , "VMSnapshotNamespace" , vmsnapshot .Namespace )
322
+ log . Infof ("reconcileNormal: update annotation value for vmsnapshot %s/%s to ' completed' " ,
323
+ vmsnapshot .Namespace , vmsnapshot .Name )
329
324
vmSnapshotPatch := client .MergeFrom (vmsnapshot .DeepCopy ())
330
325
vmsnapshot .Annotations ["csi.vsphere.volume.sync" ] = "completed"
331
326
err = r .client .Patch (ctx , vmsnapshot , vmSnapshotPatch )
332
327
if err != nil {
333
- logger . Error ( err , " could not update VirtualMachineSnapshot CR " ,
334
- "VMSnapshotName" , vmsnapshot .Name , "VMSnapshotNamespace" , vmsnapshot . Namespace )
328
+ log . Errorf ( "reconcileNormal: could not update virtualmachinesnapshot %s/%s. error: %v " ,
329
+ vmsnapshot . Namespace , vmsnapshot .Name , err )
335
330
return err
336
331
}
337
- logger . Info ("reconcileNormal: successfully updated vmsnapshot" ,
338
- "VMSnapshotName" , vmsnapshot .Name , "VMSnapshotNamespace" , vmsnapshot .Namespace )
332
+ log . Infof ("reconcileNormal: successfully updated vmsnapshot %s/%s " ,
333
+ vmsnapshot .Namespace , vmsnapshot .Name )
339
334
}
340
335
return nil
341
336
}
@@ -377,7 +372,7 @@ func getMaxWorkerThreadsToReconcileVirtualMachineSnapshot(ctx context.Context) i
377
372
// after volume sync is successful it will fetch the aggregated size of all related volumes
378
373
// will update the relevant CNSVolumeInfo for each volume which will update the storage policy usage.
379
374
func (r * ReconcileVirtualMachineSnapshot ) syncVolumesAndUpdateCNSVolumeInfo (ctx context.Context ,
380
- logger logr. Logger , vm * vmoperatorv1alpha4.VirtualMachine ) error {
375
+ log * zap. SugaredLogger , vm * vmoperatorv1alpha4.VirtualMachine ) error {
381
376
var err error
382
377
cnsVolumeIds := []cnstypes.CnsVolumeId {}
383
378
syncMode := []string {string (cnstypes .CnsSyncVolumeModeSPACE_USAGE )}
@@ -389,8 +384,8 @@ func (r *ReconcileVirtualMachineSnapshot) syncVolumesAndUpdateCNSVolumeInfo(ctx
389
384
pvc := & corev1.PersistentVolumeClaim {}
390
385
err = r .client .Get (ctx , pvcKey , pvc , & client.GetOptions {})
391
386
if err != nil {
392
- logger . Error ( err , "syncVolumesAndUpdateCNSVolumeInfo: error get pvc" ,
393
- "PVCName" , vmVolume .Name , "PVCNamespace" , vm . Namespace )
387
+ log . Errorf ( "syncVolumesAndUpdateCNSVolumeInfo: failed get pvc %s/%s. error: %v " ,
388
+ vm . Namespace , vmVolume .Name , err )
394
389
return err
395
390
}
396
391
if pvc .Spec .VolumeName != "" {
@@ -400,8 +395,8 @@ func (r *ReconcileVirtualMachineSnapshot) syncVolumesAndUpdateCNSVolumeInfo(ctx
400
395
pv := & corev1.PersistentVolume {}
401
396
err = r .client .Get (ctx , pvKey , pv , & client.GetOptions {})
402
397
if err != nil {
403
- logger . Error ( err , "syncVolumesAndUpdateCNSVolumeInfo: could not get the volume for pvc" ,
404
- "PVCName " , pvc .Name , "PVCNamespace" , vm .Namespace )
398
+ log . Errorf ( "syncVolumesAndUpdateCNSVolumeInfo: could not get the volume " +
399
+ "for pvc %s/%s error: %v " , pvc .Namespace , vm .Name , err )
405
400
return err
406
401
}
407
402
if pv .Spec .CSI != nil && pv .Spec .CSI .VolumeHandle != "" {
@@ -414,19 +409,19 @@ func (r *ReconcileVirtualMachineSnapshot) syncVolumesAndUpdateCNSVolumeInfo(ctx
414
409
},
415
410
}
416
411
// Trigger CNS VolumeSync API for identified volume-lds and Fetch Latest Aggregated snapshot size
417
- logger . Info ("syncVolumesAndUpdateCNSVolumeInfo: Trigger CNS VolumeSync API for volume" ,
418
- "VolumeId" , cnsVolId )
412
+ log . Infof ("syncVolumesAndUpdateCNSVolumeInfo: Trigger CNS VolumeSync API for volume %s " ,
413
+ cnsVolId )
419
414
syncVolumeFaultType , err := r .volumeManager .SyncVolume (ctx , syncVolumeSpecs )
420
415
if err != nil {
421
- logger . Error ( err , "syncVolumesAndUpdateCNSVolumeInfo: error while sync volume" ,
422
- "cnsfault" , syncVolumeFaultType , "VolumeId" , cnsVolId )
416
+ log . Errorf ( "syncVolumesAndUpdateCNSVolumeInfo: error while sync volume %s " +
417
+ "cnsfault %s. error: %v " , cnsVolId , syncVolumeFaultType , err )
423
418
return err
424
419
}
425
420
}
426
421
} else {
427
422
err = fmt .Errorf ("could not find the PV associated with PVC %s/%s" ,
428
423
vm .Namespace , vmVolume .Name )
429
- logger . Error ( err , "syncVolumesAndUpdateCNSVolumeInfo: pv not found" )
424
+ log . Errorf ( "syncVolumesAndUpdateCNSVolumeInfo: pv not found error: %v" , err )
430
425
return err
431
426
}
432
427
}
@@ -436,40 +431,41 @@ func (r *ReconcileVirtualMachineSnapshot) syncVolumesAndUpdateCNSVolumeInfo(ctx
436
431
}
437
432
queryResult , err := r .volumeManager .QueryVolume (ctx , queryFilter )
438
433
if err != nil {
439
- logger . Error ( err , "syncVolumesAndUpdateCNSVolumeInfo: error while query volumes from cns" )
434
+ log . Errorf ( "syncVolumesAndUpdateCNSVolumeInfo: error while query volumes from cns. error: %v" , err )
440
435
return err
441
436
}
442
437
if queryResult != nil && len (queryResult .Volumes ) > 0 {
443
438
for _ , cnsvolume := range queryResult .Volumes {
444
439
val , ok := cnsvolume .BackingObjectDetails .(* cnstypes.CnsBlockBackingDetails )
445
440
if ok {
446
- logger . Info ("syncVolumesAndUpdateCNSVolumeInfo: fetched aggregated capacity for volume" ,
447
- "AggregatedSnapshotCapacityInMb" , val .AggregatedSnapshotCapacityInMb ,
448
- "VolumeId" , cnsvolume . VolumeId . Id )
441
+ log . Infof ("syncVolumesAndUpdateCNSVolumeInfo: fetched aggregated capacity for volume %s " +
442
+ "AggregatedSnapshotCapacityInMb %s " , cnsvolume . VolumeId . Id , val .AggregatedSnapshotCapacityInMb )
443
+
449
444
// Update CNSVolumeInfo with latest aggregated Size and Update SPU used value.
450
445
patch , err := common .GetCNSVolumeInfoPatch (ctx , val .AggregatedSnapshotCapacityInMb ,
451
446
cnsvolume .VolumeId .Id ) // TODO: UDPATE to value returned
452
447
if err != nil {
453
- logger .Error (err , "syncVolumesAndUpdateCNSVolumeInfo: failed to get cnsvolumeinfo patch" )
448
+ log .Errorf ("syncVolumesAndUpdateCNSVolumeInfo: failed to get cnsvolumeinfo patch for " +
449
+ "volume %s, error: %v" , cnsvolume .VolumeId .Id , err )
454
450
return err
455
451
}
456
452
patchBytes , err := json .Marshal (patch )
457
453
if err != nil {
458
- logger . Error ( err , "syncVolumesAndUpdateCNSVolumeInfo: error while json marshal" )
454
+ log . Errorf ( "syncVolumesAndUpdateCNSVolumeInfo: error while json marshal. error: %v" , err )
459
455
return err
460
456
}
461
457
err = r .volumeInfoService .PatchVolumeInfo (ctx , cnsvolume .VolumeId .Id ,
462
458
patchBytes , allowedRetriesToPatchCNSVolumeInfo )
463
459
if err != nil {
464
- logger . Error ( err , "syncVolumesAndUpdateCNSVolumeInfo: " +
465
- "failed to patch cnsvolumeinfo" )
460
+ log . Errorf ( "syncVolumesAndUpdateCNSVolumeInfo: failed to patch cnsvolumeinfo for volume " +
461
+ "volume %s, error: %v" , cnsvolume . VolumeId . Id , err )
466
462
return err
467
463
}
468
464
} else {
469
465
err = fmt .Errorf ("unable to retrieve CnsBlockBackingDetails for volumeID %s" ,
470
466
cnsvolume .VolumeId .Id )
471
- logger . Error ( err , "syncVolumesAndUpdateCNSVolumeInfo: " +
472
- "could not retrieve CnsBlockBackingDetails" )
467
+ log . Errorf ( "syncVolumesAndUpdateCNSVolumeInfo: could not retrieve CnsBlockBackingDetails. " +
468
+ "error: %v" , err )
473
469
return err
474
470
}
475
471
}
0 commit comments