@@ -253,7 +253,7 @@ func (d *ControllerDriver) DeleteVolume(ctx context.Context, req *csi.DeleteVolu
253
253
254
254
// ControllerPublishVolume attaches the given volume to the node
255
255
func (d * ControllerDriver ) ControllerPublishVolume (ctx context.Context , req * csi.ControllerPublishVolumeRequest ) (* csi.ControllerPublishVolumeResponse , error ) {
256
- // startTime := time.Now()
256
+ startTime := time .Now ()
257
257
258
258
if req .VolumeId == "" {
259
259
return nil , status .Error (codes .InvalidArgument , "Volume ID must be provided" )
@@ -272,8 +272,7 @@ func (d *ControllerDriver) ControllerPublishVolume(ctx context.Context, req *csi
272
272
id , err := d .util .lookupNodeID (d .KubeClient , req .NodeId )
273
273
if err != nil {
274
274
log .With (zap .Error (err )).Error ("Failed to lookup node" )
275
- // TODO: Uncomment once we know our T2 limits are not getting breached
276
- // metrics.SendMetricData(d.metricPusher, pvAttachFailureMetric, time.Since(startTime).Seconds(), csiDriver, req.VolumeId)
275
+ metrics .SendMetricData (d .metricPusher , metrics .PVAttachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
277
276
return nil , status .Errorf (codes .InvalidArgument , "failed to get ProviderID by nodeName. error : %s" , err )
278
277
}
279
278
id = client .MapProviderIDToInstanceID (id )
@@ -292,15 +291,15 @@ func (d *ControllerDriver) ControllerPublishVolume(ctx context.Context, req *csi
292
291
compartmentID , err := util .LookupNodeCompartment (d .KubeClient , req .NodeId )
293
292
if err != nil {
294
293
log .With (zap .Error (err )).With ("instanceID" , id ).Errorf ("failed to get compartmentID from node annotation: %s" , util .CompartmentIDAnnotation )
294
+ metrics .SendMetricData (d .metricPusher , metrics .PVAttachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
295
295
return nil , status .Errorf (codes .Unknown , "failed to get compartmentID from node annotation:. error : %s" , err )
296
296
}
297
297
298
298
volumeAttached , err := d .client .Compute ().FindActiveVolumeAttachment (context .Background (), compartmentID , req .VolumeId )
299
299
300
300
if err != nil && ! client .IsNotFound (err ) {
301
301
log .With (zap .Error (err )).Error ("Got error in finding volume attachment: %s" , err )
302
- // TODO: Uncomment once we know our T2 limits are not getting breached
303
- // metrics.SendMetricData(d.metricPusher, pvAttachFailureMetric, time.Since(startTime).Seconds(), csiDriver, req.VolumeId)
302
+ metrics .SendMetricData (d .metricPusher , metrics .PVAttachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
304
303
return nil , err
305
304
}
306
305
@@ -311,15 +310,13 @@ func (d *ControllerDriver) ControllerPublishVolume(ctx context.Context, req *csi
311
310
err = d .client .Compute ().WaitForVolumeDetached (ctx , * volumeAttached .GetId ())
312
311
if err != nil {
313
312
log .With (zap .Error (err )).Error ("Error while waiting for volume to get detached before attaching: %s" , err )
314
- // TODO: Uncomment once we know our T2 limits are not getting breached
315
- // metrics.SendMetricData(d.metricPusher, pvAttachFailureMetric, time.Since(startTime).Seconds(), csiDriver, req.VolumeId)
313
+ metrics .SendMetricData (d .metricPusher , metrics .PVAttachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
316
314
return nil , status .Errorf (codes .Internal , "Error while waiting for volume to get detached before attaching: %s" , err )
317
315
}
318
316
} else {
319
317
if id != * volumeAttached .GetInstanceId () {
320
318
log .Error ("Volume is already attached to another node: %s" , * volumeAttached .GetInstanceId ())
321
- // TODO: Uncomment once we know our T2 limits are not getting breached
322
- // metrics.SendMetricData(d.metricPusher, pvAttachFailureMetric, time.Since(startTime).Seconds(), csiDriver, req.VolumeId)
319
+ metrics .SendMetricData (d .metricPusher , metrics .PVAttachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
323
320
return nil , status .Errorf (codes .Internal , "Failed to attach volume to node. " +
324
321
"The volume is already attached to another node." )
325
322
}
@@ -328,8 +325,7 @@ func (d *ControllerDriver) ControllerPublishVolume(ctx context.Context, req *csi
328
325
volumeAttached , err = d .client .Compute ().WaitForVolumeAttached (ctx , * volumeAttached .GetId ())
329
326
if err != nil {
330
327
log .With (zap .Error (err )).Error ("Error while waiting: failed to attach volume to the node: %s." , err )
331
- // TODO: Uncomment once we know our T2 limits are not getting breached
332
- // metrics.SendMetricData(d.metricPusher, pvAttachFailureMetric, time.Since(startTime).Seconds(), csiDriver, req.VolumeId)
328
+ metrics .SendMetricData (d .metricPusher , metrics .PVAttachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
333
329
return nil , status .Errorf (codes .Internal , "Failed to attach volume to the node: %s" , err )
334
330
}
335
331
log .Info ("Volume is already ATTACHED to node." )
@@ -344,30 +340,26 @@ func (d *ControllerDriver) ControllerPublishVolume(ctx context.Context, req *csi
344
340
volumeAttached , err = d .client .Compute ().AttachParavirtualizedVolume (context .Background (), id , req .VolumeId , volumeAttachmentOptions .enableInTransitEncryption )
345
341
if err != nil {
346
342
log .With (zap .Error (err )).Info ("failed paravirtualized attachment instance to volume." )
347
- // TODO: Uncomment once we know our T2 limits are not getting breached
348
- // metrics.SendMetricData(d.metricPusher, pvAttachFailureMetric, time.Since(startTime).Seconds(), csiDriver, req.VolumeId)
343
+ metrics .SendMetricData (d .metricPusher , metrics .PVAttachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
349
344
return nil , status .Errorf (codes .Internal , "failed paravirtualized attachment instance to volume. error : %s" , err )
350
345
}
351
346
} else {
352
347
volumeAttached , err = d .client .Compute ().AttachVolume (context .Background (), id , req .VolumeId )
353
348
if err != nil {
354
349
log .With (zap .Error (err )).Info ("failed iscsi attachment instance to volume." )
355
- // TODO: Uncomment once we know our T2 limits are not getting breached
356
- // metrics.SendMetricData(d.metricPusher, pvAttachFailureMetric, time.Since(startTime).Seconds(), csiDriver, req.VolumeId)
350
+ metrics .SendMetricData (d .metricPusher , metrics .PVAttachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
357
351
return nil , status .Errorf (codes .Internal , "failed iscsi attachment instance to volume : %s" , err )
358
352
}
359
353
}
360
354
361
355
volumeAttached , err = d .client .Compute ().WaitForVolumeAttached (ctx , * volumeAttached .GetId ())
362
356
if err != nil {
363
357
log .With (zap .Error (err )).Error ("Failed to attach volume to the node." )
364
- // TODO: Uncomment once we know our T2 limits are not getting breached
365
- // metrics.SendMetricData(d.metricPusher, pvAttachFailureMetric, time.Since(startTime).Seconds(), csiDriver, req.VolumeId)
358
+ metrics .SendMetricData (d .metricPusher , metrics .PVAttachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
366
359
return nil , status .Errorf (codes .Internal , "Failed to attach volume to the node %s" , err )
367
360
}
368
361
369
- // TODO: Uncomment once we know our T2 limits are not getting breached
370
- // metrics.SendMetricData(d.metricPusher, pvAttachSuccessMetric, time.Since(startTime).Seconds(), csiDriver, req.VolumeId)
362
+ metrics .SendMetricData (d .metricPusher , metrics .PVAttachSuccess , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
371
363
return generatePublishContext (volumeAttachmentOptions , log , volumeAttached ), nil
372
364
373
365
}
@@ -398,7 +390,7 @@ func generatePublishContext(volumeAttachmentOptions VolumeAttachmentOption, log
398
390
399
391
// ControllerUnpublishVolume deattaches the given volume from the node
400
392
func (d * ControllerDriver ) ControllerUnpublishVolume (ctx context.Context , req * csi.ControllerUnpublishVolumeRequest ) (* csi.ControllerUnpublishVolumeResponse , error ) {
401
- // startTime := time.Now()
393
+ startTime := time .Now ()
402
394
log := d .logger .With ("volumeID" , req .VolumeId )
403
395
404
396
if req .VolumeId == "" {
@@ -408,6 +400,7 @@ func (d *ControllerDriver) ControllerUnpublishVolume(ctx context.Context, req *c
408
400
compartmentID , err := util .LookupNodeCompartment (d .KubeClient , req .NodeId )
409
401
if err != nil {
410
402
log .With (zap .Error (err )).Errorf ("failed to get compartmentID from node annotation: %s" , util .CompartmentIDAnnotation )
403
+ metrics .SendMetricData (d .metricPusher , metrics .PVDetachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
411
404
return nil , status .Errorf (codes .Unknown , "failed to get compartmentID from node annotation:. error : %s" , err )
412
405
}
413
406
@@ -419,28 +412,28 @@ func (d *ControllerDriver) ControllerUnpublishVolume(ctx context.Context, req *c
419
412
return & csi.ControllerUnpublishVolumeResponse {}, nil
420
413
}
421
414
log .With (zap .Error (err )).With ("nodeId" , req .NodeId ).Error ("Volume is not detached from the node." )
422
- // metrics.SendDataMetric (d.metricPusher, pvDetachFailureMetric , time.Since(startTime).Seconds(), csiDriver, req.VolumeId)
415
+ metrics .SendMetricData (d .metricPusher , metrics . PVDetachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
423
416
return nil , err
424
417
}
425
418
426
419
log .With ("volumeAttachedId" , attachedVolume .GetId ()).Info ("Detaching Volume." )
427
420
err = d .client .Compute ().DetachVolume (context .Background (), * attachedVolume .GetId ())
428
421
if err != nil {
429
422
log .With (zap .Error (err )).With ("nodeId" , req .NodeId ).Error ("Volume can not be detached." )
430
- // metrics.SendDataMetric (d.metricPusher, pvDetachFailureMetric , time.Since(startTime).Seconds(), csiDriver, req.VolumeId)
423
+ metrics .SendMetricData (d .metricPusher , metrics . PVDetachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
431
424
return nil , status .Errorf (codes .Unknown , "volume can not be detached %s" , err )
432
425
}
433
426
434
427
err = d .client .Compute ().WaitForVolumeDetached (context .Background (), * attachedVolume .GetId ())
435
428
if err != nil {
436
429
log .With (zap .Error (err )).With ("nodeId" , req .NodeId ).Error ("timed out waiting for volume to be detached." )
430
+ metrics .SendMetricData (d .metricPusher , metrics .PVDetachFailure , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
437
431
return nil , status .Errorf (codes .Unknown , "timed out waiting for volume to be detached %s" , err )
438
432
}
439
433
440
434
log .With ("volumeAttachedId" , attachedVolume .GetId ()).Info ("Un-publishing Volume Completed." )
441
435
442
- // TODO: Uncomment once we know our T2 limits are not getting breached
443
- // metrics.SendMetricData(d.metricPusher, pvDetachSuccessMetric, time.Since(startTime).Seconds(), csiDriver, req.VolumeId)
436
+ metrics .SendMetricData (d .metricPusher , metrics .PVDetachSuccess , time .Since (startTime ).Seconds (), csiDriver , req .VolumeId )
444
437
return & csi.ControllerUnpublishVolumeResponse {}, nil
445
438
}
446
439
0 commit comments