From ae1bcf4c0c6bdbf0113026a0025c367d65e5b6d0 Mon Sep 17 00:00:00 2001 From: RoyUP9 <87927115+RoyUP9@users.noreply.github.com> Date: Sun, 16 Jan 2022 11:48:22 +0200 Subject: [PATCH] Added api server timeout env for install and tap (#647) --- cli/cmd/installRunner.go | 3 ++- cli/cmd/tapRunner.go | 4 +++- cli/config/envConfig.go | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cli/cmd/installRunner.go b/cli/cmd/installRunner.go index b4912e7ce..2802bc011 100644 --- a/cli/cmd/installRunner.go +++ b/cli/cmd/installRunner.go @@ -101,7 +101,8 @@ func watchApiServerPodReady(ctx context.Context, kubernetesProvider *kubernetes. podWatchHelper := kubernetes.NewPodWatchHelper(kubernetesProvider, podExactRegex) eventChan, errorChan := kubernetes.FilteredWatch(ctx, podWatchHelper, []string{config.Config.MizuResourcesNamespace}, podWatchHelper) - timeAfter := time.After(1 * time.Minute) + apiServerTimeoutSec := config.GetIntEnvConfig(config.ApiServerTimeoutSec, 120) + timeAfter := time.After(time.Duration(apiServerTimeoutSec) * time.Second) for { select { case wEvent, ok := <-eventChan: diff --git a/cli/cmd/tapRunner.go b/cli/cmd/tapRunner.go index 3210acc9a..fec222338 100644 --- a/cli/cmd/tapRunner.go +++ b/cli/cmd/tapRunner.go @@ -306,7 +306,9 @@ func watchApiServerPod(ctx context.Context, kubernetesProvider *kubernetes.Provi podWatchHelper := kubernetes.NewPodWatchHelper(kubernetesProvider, podExactRegex) eventChan, errorChan := kubernetes.FilteredWatch(ctx, podWatchHelper, []string{config.Config.MizuResourcesNamespace}, podWatchHelper) isPodReady := false - timeAfter := time.After(25 * time.Second) + + apiServerTimeoutSec := config.GetIntEnvConfig(config.ApiServerTimeoutSec, 120) + timeAfter := time.After(time.Duration(apiServerTimeoutSec) * time.Second) for { select { case wEvent, ok := <-eventChan: diff --git a/cli/config/envConfig.go b/cli/config/envConfig.go index 78f91e00b..acbe5e1ab 100644 --- a/cli/config/envConfig.go +++ b/cli/config/envConfig.go @@ -7,6 +7,7 @@ import ( const ( ApiServerRetries = "API_SERVER_RETRIES" + ApiServerTimeoutSec = "API_SERVER_TIMEOUT_SEC" ) func GetIntEnvConfig(key string, defaultValue int) int {