@@ -22,6 +22,7 @@ import (
22
22
"context"
23
23
"io"
24
24
"strings"
25
+ "time"
25
26
26
27
objectdriverv1alpha1 "github.com/IBM/ibm-object-csi-driver-operator/api/v1alpha1"
27
28
"github.com/IBM/ibm-object-csi-driver-operator/controllers/constants"
@@ -143,7 +144,7 @@ func (r *RecoverStaleVolumeReconciler) Reconcile(ctx context.Context, req ctrl.R
143
144
144
145
if len (csiApplications ) == 0 {
145
146
reqLogger .Info ("No Deployment found in requested namespace" )
146
- return ctrl. Result { RequeueAfter : constants . ReconcilationTime }, nil
147
+ continue
147
148
}
148
149
149
150
var csiNodeServerPods = map [string ]string {} // {nodeName1: csiNodePod1, nodeName2: csiNodePod2, ...}
@@ -229,7 +230,7 @@ func (r *RecoverStaleVolumeReconciler) Reconcile(ctx context.Context, req ctrl.R
229
230
230
231
// If CSI Driver Node Pods not found, reconcile
231
232
if len (csiNodeServerPods ) == 0 {
232
- return ctrl. Result { RequeueAfter : constants . ReconcilationTime }, nil
233
+ continue
233
234
}
234
235
235
236
for nodeName , volumesData := range nodeVolumePodMapping {
@@ -281,6 +282,8 @@ func (r *RecoverStaleVolumeReconciler) SetupWithManager(mgr ctrl.Manager) error
281
282
}
282
283
283
284
func fetchCSIPVCAndPVNames (k8sOps * crutils.K8sResourceOps , log logr.Logger ) (map [string ]string , error ) {
285
+ defer LogFunctionDuration (log , "fetchCSIPVCAndPVNames" , time .Now ())
286
+
284
287
pvcList , err := k8sOps .ListPVC ()
285
288
if err != nil {
286
289
log .Error (err , "failed to get pvc list" )
@@ -314,6 +317,8 @@ func fetchCSIPVCAndPVNames(k8sOps *crutils.K8sResourceOps, log logr.Logger) (map
314
317
315
318
func fetchDeploymentsUsingCSIVolumes (k8sOps * crutils.K8sResourceOps , log logr.Logger , depNames []string ,
316
319
reqPVCNames []string ) ([]string , error ) {
320
+ defer LogFunctionDuration (log , "fetchDeploymentsUsingCSIVolumes" , time .Now ())
321
+
317
322
var reqDeploymentNames []string
318
323
319
324
for _ , name := range depNames {
@@ -361,6 +366,8 @@ func createK8sClient() (*KubernetesClient, error) {
361
366
362
367
func fetchVolumeStatsFromNodeServerPodLogs (ctx context.Context , nodeServerPod , namespace string , logTailLines int64 ,
363
368
isTest bool ) (map [string ]string , error ) {
369
+ defer LogFunctionDuration (staleVolLog , "fetchVolumeStatsFromNodeServerPodLogs" , time .Now ())
370
+
364
371
staleVolLog .Info ("Input Parameters: " , "nodeServerPod" , nodeServerPod , "namespace" , namespace , "isTest" , isTest )
365
372
podLogOpts := & corev1.PodLogOptions {
366
373
Container : constants .NodeContainerName ,
@@ -392,3 +399,9 @@ func fetchVolumeStatsFromNodeServerPodLogs(ctx context.Context, nodeServerPod, n
392
399
393
400
return parseLogs (nodeServerPodLogs ), nil
394
401
}
402
+
403
+ // LogFunctionDuration calculates time taken by a method
404
+ func LogFunctionDuration (logger logr.Logger , methodName string , start time.Time ) {
405
+ duration := time .Since (start )
406
+ logger .Info ("Time to complete" , methodName , duration .Seconds ())
407
+ }
0 commit comments