Skip to content

Commit 9276e71

Browse files
committed
Add cluster logging to CnsFileAccessConfig admission handler
Enhance debugging capabilities by adding comprehensive cluster logging in the CnsFileAccessConfig validation process. Logs display the total number of clusters found and detailed information for each cluster including name and namespace. This logging will help diagnose cluster detection issues during CnsFileAccessConfig operations and improve troubleshooting capabilities for file share access validation scenarios. Signed-off-by: ab002488 <anuj.bansal@broadcom.com>
1 parent e12cbba commit 9276e71

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

pkg/syncer/admissionhandler/validate_cnsfileaccessconfig.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,13 @@ func getExpectedProviderServiceAccountName(ctx context.Context) (string, error)
345345
return "", err
346346
}
347347

348+
// Log cluster information for debugging
349+
log := logger.GetLogger(ctx)
350+
log.Infof("Found %d clusters in clusterList", len(clusterList.Items))
351+
for i, cluster := range clusterList.Items {
352+
log.Infof("Cluster %d: Name=%s, Namespace=%s", i+1, cluster.Name, cluster.Namespace)
353+
}
354+
348355
// If there's exactly one cluster, use it (typical in guest cluster scenario)
349356
if len(clusterList.Items) == 1 {
350357
cluster := clusterList.Items[0]
@@ -369,6 +376,13 @@ func validateAgainstAllClusters(ctx context.Context, serviceAccountName string)
369376
return false, fmt.Errorf("failed to list clusters: %w", err)
370377
}
371378

379+
// Log cluster information for debugging
380+
log := logger.GetLogger(ctx)
381+
log.Infof("Found %d clusters in clusterList for service account validation", len(clusterList.Items))
382+
for i, cluster := range clusterList.Items {
383+
log.Infof("Cluster %d: Name=%s, Namespace=%s", i+1, cluster.Name, cluster.Namespace)
384+
}
385+
372386
// Check if the service account name matches any cluster's expected ProviderServiceAccount name
373387
for _, cluster := range clusterList.Items {
374388
// Following reference: fmt.Sprintf("%s-%s", vsphereCluster.Name, "pvcsi")

0 commit comments

Comments
 (0)