mirror of
https://github.com/rancher/steve.git
synced 2025-04-27 19:05:09 +00:00
Make watch timeout configurable
By default, a watch times out after 30 minutes. For debugging purposes, it's convenient if this can be decreased. Add an environment variable CATTLE_WATCH_TIMEOUT_SECONDS to enable setting the timeout in seconds.
This commit is contained in:
parent
ada5b33d98
commit
11fe86ab7e
@ -7,8 +7,10 @@ import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"github.com/rancher/apiserver/pkg/types"
|
||||
@ -32,6 +34,8 @@ import (
|
||||
"k8s.io/client-go/kubernetes"
|
||||
)
|
||||
|
||||
const watchTimeoutEnv = "CATTLE_WATCH_TIMEOUT_SECONDS"
|
||||
|
||||
var (
|
||||
lowerChars = regexp.MustCompile("[a-z]+")
|
||||
paramScheme = runtime.NewScheme()
|
||||
@ -291,6 +295,15 @@ func (s *Store) listAndWatch(apiOp *types.APIRequest, client dynamic.ResourceInt
|
||||
}
|
||||
|
||||
timeout := int64(60 * 30)
|
||||
timeoutSetting := os.Getenv(watchTimeoutEnv)
|
||||
if timeoutSetting != "" {
|
||||
userSetTimeout, err := strconv.Atoi(timeoutSetting)
|
||||
if err != nil {
|
||||
logrus.Debugf("could not parse %s environment variable, error: %v", watchTimeoutEnv, err)
|
||||
} else {
|
||||
timeout = int64(userSetTimeout)
|
||||
}
|
||||
}
|
||||
k8sClient, _ := metricsStore.Wrap(client, nil)
|
||||
watcher, err := k8sClient.Watch(apiOp, metav1.ListOptions{
|
||||
Watch: true,
|
||||
|
Loading…
Reference in New Issue
Block a user