From fbd2a0250ad86c3be0f71ed89bc84ec0fa6e1426 Mon Sep 17 00:00:00 2001 From: Max Xu Date: Sun, 20 Apr 2025 00:16:06 +0800 Subject: [PATCH] fix: set default request timeout to 120 seconds (#3253) Signed-off-by: Max Xu Co-authored-by: Fernand Galiana --- cmd/root.go | 13 +++++++------ internal/client/config.go | 4 ++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index d68a83a1..f7ab52b5 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -12,17 +12,18 @@ import ( "strings" "time" + "github.com/lmittmann/tint" + "github.com/mattn/go-colorable" + "github.com/spf13/cobra" + "k8s.io/cli-runtime/pkg/genericclioptions" + "k8s.io/client-go/tools/clientcmd/api" + "github.com/derailed/k9s/internal/client" "github.com/derailed/k9s/internal/color" "github.com/derailed/k9s/internal/config" "github.com/derailed/k9s/internal/config/data" "github.com/derailed/k9s/internal/slogs" "github.com/derailed/k9s/internal/view" - "github.com/lmittmann/tint" - "github.com/mattn/go-colorable" - "github.com/spf13/cobra" - "k8s.io/cli-runtime/pkg/genericclioptions" - "k8s.io/client-go/tools/clientcmd/api" ) const ( @@ -269,7 +270,7 @@ func initK8sFlags() { rootCmd.Flags().StringVar( k8sFlags.Timeout, "request-timeout", - "5s", + "", "The length of time to wait before giving up on a single server request", ) diff --git a/internal/client/config.go b/internal/client/config.go index 0d539f74..bfe02f3a 100644 --- a/internal/client/config.go +++ b/internal/client/config.go @@ -14,12 +14,12 @@ import ( "k8s.io/cli-runtime/pkg/genericclioptions" restclient "k8s.io/client-go/rest" - clientcmd "k8s.io/client-go/tools/clientcmd" + "k8s.io/client-go/tools/clientcmd" "k8s.io/client-go/tools/clientcmd/api" ) const ( - defaultCallTimeoutDuration time.Duration = 10 * time.Second + defaultCallTimeoutDuration = 120 * time.Second // UsePersistentConfig caches client config to avoid reloads. UsePersistentConfig = true