From ac778e8203e1f6ea43555152c48f130063cc20c2 Mon Sep 17 00:00:00 2001 From: Yu-Ju Hong Date: Mon, 9 Nov 2015 10:01:53 -0800 Subject: [PATCH] Adjust the sync/backoff period Set resyncInterval to one minute now that we rely on the generic pleg to trigger pod syncs on container events. When there is an error during syncing, pod workers need to wake up sooner to retry. Set the sync error backoff period to 10 second in this case. --- cmd/kubelet/app/server.go | 2 +- docs/admin/kubelet.md | 4 ++-- pkg/kubelet/kubelet.go | 16 +++++++++------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cmd/kubelet/app/server.go b/cmd/kubelet/app/server.go index 845dbb1678a..3a6e83e2e25 100644 --- a/cmd/kubelet/app/server.go +++ b/cmd/kubelet/app/server.go @@ -216,7 +216,7 @@ func NewKubeletServer() *KubeletServer { RootDirectory: defaultRootDir, SerializeImagePulls: true, StreamingConnectionIdleTimeout: 5 * time.Minute, - SyncFrequency: 10 * time.Second, + SyncFrequency: 1 * time.Minute, SystemContainer: "", ReconcileCIDR: true, KubeAPIQPS: 5.0, diff --git a/docs/admin/kubelet.md b/docs/admin/kubelet.md index 6f9a99bcd73..4d4f8053241 100644 --- a/docs/admin/kubelet.md +++ b/docs/admin/kubelet.md @@ -131,13 +131,13 @@ kubelet --runonce[=false]: If true, exit after spawning pods from local manifests or remote urls. Exclusive with --api-servers, and --enable-server --serialize-image-pulls[=true]: Pull images one at a time. We recommend *not* changing the default value on nodes that run docker daemon with version < 1.9 or an Aufs storage backend. Issue #10959 has more details. [default=true] --streaming-connection-idle-timeout=5m0s: Maximum time a streaming connection can be idle before the connection is automatically closed. Example: '5m' - --sync-frequency=10s: Max period between synchronizing running containers and config + --sync-frequency=1m0s: Max period between synchronizing running containers and config --system-container="": Optional resource-only container in which to place all non-kernel processes that are not already in a container. Empty for no container. Rolling back the flag requires a reboot. (Default: ""). --tls-cert-file="": File containing x509 Certificate for HTTPS. (CA cert, if any, concatenated after server cert). If --tls-cert-file and --tls-private-key-file are not provided, a self-signed certificate and key are generated for the public address and saved to the directory passed to --cert-dir. --tls-private-key-file="": File containing x509 private key matching --tls-cert-file. ``` -###### Auto generated by spf13/cobra on 10-Nov-2015 +###### Auto generated by spf13/cobra on 11-Nov-2015 diff --git a/pkg/kubelet/kubelet.go b/pkg/kubelet/kubelet.go index 7c7de112e05..1e84ab8d785 100644 --- a/pkg/kubelet/kubelet.go +++ b/pkg/kubelet/kubelet.go @@ -117,10 +117,14 @@ const ( // is a bit arbitrary and may be adjusted in the future. plegChannelCapacity = 1000 - // Relisting is used to discover missing container events. - // Use a shorter period because generic PLEG relies on relisting for - // container events. + // Generic PLEG relies on relisting for discovering container events. + // The period directly affects the response time of kubelet. plegRelistPeriod = time.Second * 3 + + // backOffPeriod is the period to back off when pod syncing resulting in an + // error. It is also used as the base period for the exponential backoff + // container restarts and image pulls. + backOffPeriod = time.Second * 10 ) var ( @@ -437,11 +441,9 @@ func NewMainKubelet( } klet.runtimeCache = runtimeCache klet.workQueue = queue.NewBasicWorkQueue() - // TODO(yujuhong): backoff and resync interval should be set differently - // once we switch to using pod event generator. - klet.podWorkers = newPodWorkers(runtimeCache, klet.syncPod, recorder, klet.workQueue, klet.resyncInterval, klet.resyncInterval) + klet.podWorkers = newPodWorkers(runtimeCache, klet.syncPod, recorder, klet.workQueue, klet.resyncInterval, backOffPeriod) - klet.backOff = util.NewBackOff(resyncInterval, MaxContainerBackOff) + klet.backOff = util.NewBackOff(backOffPeriod, MaxContainerBackOff) klet.podKillingCh = make(chan *kubecontainer.Pod, podKillingChannelCapacity) klet.sourcesSeen = sets.NewString() return klet, nil