diff --git a/slo-monitor/Makefile b/slo-monitor/Makefile index ed22e34481..52ff25c162 100644 --- a/slo-monitor/Makefile +++ b/slo-monitor/Makefile @@ -13,7 +13,7 @@ # limitations under the License. PACKAGE = k8s.io/perf-tests/slo-monitor -TAG = 0.14.0 +TAG = 0.15.0 # Image should be pulled from k8s.gcr.io, which will auto-detect # region (us, eu, asia, ...) and pull from the closest. REPOSITORY?=k8s.gcr.io diff --git a/slo-monitor/src/monitors/pod_monitor.go b/slo-monitor/src/monitors/pod_monitor.go index 6be34c1949..10fc64139d 100644 --- a/slo-monitor/src/monitors/pod_monitor.go +++ b/slo-monitor/src/monitors/pod_monitor.go @@ -129,8 +129,20 @@ func (pm *PodStartupLatencyDataMonitor) Run(stopCh chan struct{}) error { controller := NewWatcherWithHandler( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { - // This call is paginated by cache.Reflector. - return pm.kubeClient.CoreV1().Pods(v1.NamespaceAll).List(options) + // slo-monitor is not using the events returned from the list + // (it uses NoStoreQueue implementation of Store which discards them), + // only the resourceVersion is used to instantiate the watch from this point. + // This trick allows us to reduce memory usage on startup and further relists. + o := metav1.ListOptions{ + Limit: 1, + } + result, err := pm.kubeClient.CoreV1().Pods(v1.NamespaceAll).List(o) + if err != nil { + return nil, err + } + result.Continue = "" + result.Items = nil + return result, nil }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { return pm.kubeClient.CoreV1().Pods(v1.NamespaceAll).Watch(options) @@ -175,9 +187,20 @@ func (pm *PodStartupLatencyDataMonitor) Run(stopCh chan struct{}) error { eventController := NewWatcherWithHandler( &cache.ListWatch{ ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { - options.FieldSelector = eventSelector - // This call is paginated by cache.Reflector. - return pm.kubeClient.CoreV1().Events(v1.NamespaceAll).List(options) + // slo-monitor is not using the pods returned from the list + // (it uses NoStoreQueue implementation of Store which discards them), + // only the resourceVersion is used to instantiate the watch from this point. + // This trick allows us to reduce memory usage on startup and further relists. + o := metav1.ListOptions{ + Limit: 1, + } + result, err := pm.kubeClient.CoreV1().Events(v1.NamespaceAll).List(o) + if err != nil { + return nil, err + } + result.Continue = "" + result.Items = nil + return result, nil }, WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { options.FieldSelector = eventSelector diff --git a/slo-monitor/src/monitors/watcher.go b/slo-monitor/src/monitors/watcher.go index c2a941a107..be36dfa6e6 100644 --- a/slo-monitor/src/monitors/watcher.go +++ b/slo-monitor/src/monitors/watcher.go @@ -28,7 +28,6 @@ import ( const ( resyncPeriod = time.Duration(0) - watchListPageSize = 5000 ) // NewWatcherWithHandler creates a simple watcher that will call `h` for all coming objects @@ -41,7 +40,6 @@ func NewWatcherWithHandler(lw cache.ListerWatcher, objType runtime.Object, setHa ObjectType: objType, FullResyncPeriod: resyncPeriod, RetryOnError: false, - WatchListPageSize: watchListPageSize, Process: func(obj interface{}) error { workItem := obj.(workItem)