@@ -76,8 +76,8 @@ func CreateServiceAccount(ctx context.Context, task *tes.Task, conf *config.Conf
7676
7777// isServiceAccountAttachedToPods returns true if any active pod for any active pod
7878// is still using the given ServiceAccount. Pods are skipped if they are terminating (DeletionTimestamp set)
79- func isServiceAccountAttachedToPods (ctx context.Context , saName , namespace string , client kubernetes.Interface , taskID string ) (bool , error ) {
80- fmt . Println ( "DEBUG: Sleeping for 5s before ServiceAccount deletion to avoid Race Conditions..." )
79+ func isServiceAccountAttachedToPods (ctx context.Context , saName , namespace string , client kubernetes.Interface , log * logger. Logger ) (bool , error ) {
80+ log . Debug ( "ServiceAccount" , " Sleeping for 5s before ServiceAccount deletion to avoid Race Conditions..." )
8181 time .Sleep (5 * time .Second )
8282 pods , err := client .CoreV1 ().Pods (namespace ).List (ctx , metav1.ListOptions {
8383 FieldSelector : fmt .Sprintf ("spec.serviceAccountName=%s" , saName ),
@@ -124,7 +124,7 @@ func DeleteServiceAccount(ctx context.Context, taskID, namespace string, client
124124 }
125125
126126 if sharedSA {
127- inUse , err := isServiceAccountAttachedToPods (ctx , saName , namespace , client , taskID )
127+ inUse , err := isServiceAccountAttachedToPods (ctx , saName , namespace , client , log )
128128 if err != nil {
129129 return fmt .Errorf ("checking pod attachment for ServiceAccount %s: %v" , saName , err )
130130 }
0 commit comments