Skip to content

Commit 2c2c470

Browse files
committed
add time out as a parameter in function
Signed-off-by: w3aman <[email protected]>
1 parent 201c895 commit 2c2c470

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

common/k8stest/util_pod.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -787,8 +787,8 @@ func CheckPodExists(podName string, namespace string) (bool, error) {
787787
return true, nil
788788
}
789789

790-
func WaitForPodDeletion(podName string, namespace string) (bool, error) {
791-
timeout := 90 * time.Second // Set timeout to 90 seconds
790+
func WaitForPodDeletion(podName string, namespace string, podDeletionTimeoutSecs time.Duration) (bool, error) {
791+
792792
startTime := time.Now()
793793

794794
for {
@@ -801,13 +801,13 @@ func WaitForPodDeletion(podName string, namespace string) (bool, error) {
801801
}
802802

803803
// If the timeout is reached, exit the loop
804-
if time.Since(startTime) >= timeout {
804+
if time.Since(startTime) >= podDeletionTimeoutSecs {
805805
break
806806
}
807807
// Sleep for a short interval before retrying
808808
time.Sleep(1 * time.Second)
809809
}
810810

811811
// If the pod still exists after the timeout, return false
812-
return false, fmt.Errorf("timeout reached: pod %s in namespace %s was not deleted within %v", podName, namespace, timeout)
812+
return false, fmt.Errorf("timeout reached: pod %s in namespace %s was not deleted within %v", podName, namespace, podDeletionTimeoutSecs)
813813
}

0 commit comments

Comments
 (0)