From 3ff03c9de5df77e756ad20ec210421a7504f9c2f Mon Sep 17 00:00:00 2001 From: Rokibul Hasan Date: Thu, 19 Dec 2024 14:43:52 +0600 Subject: [PATCH] Use timeout ctx to get the serviceaccount Signed-off-by: Rokibul Hasan --- pkg/cli/connect_helm.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/cli/connect_helm.go b/pkg/cli/connect_helm.go index 87dd74443..873bb9ec7 100644 --- a/pkg/cli/connect_helm.go +++ b/pkg/cli/connect_helm.go @@ -715,7 +715,11 @@ func checkIfAlreadyConnected(ctx context.Context, vCluster *find.VCluster) (bool return false, err } - _, err = vKubeClient.CoreV1().ServiceAccounts("default").Get(ctx, "default", metav1.GetOptions{}) + timeoutCtx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + // Use the timeout context in the Get call + _, err = vKubeClient.CoreV1().ServiceAccounts("default").Get(timeoutCtx, "default", metav1.GetOptions{}) if err != nil { return false, err }