From d902c1f9326b0d8d85c4b367754750e02f1051cf Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 15 Jan 2019 14:40:26 +0000 Subject: [PATCH] controller: Add a 5s delay before rendering MCs To reduce churn if MCs are being created rapidly - both on general principle, and also to reduce our exposure to the current bug that a booting node may fail to find a GC'd MachineConfig: https://github.com/openshift/machine-config-operator/issues/301 --- pkg/controller/render/render_controller.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pkg/controller/render/render_controller.go b/pkg/controller/render/render_controller.go index 6b469e943d..7d794e6b6b 100644 --- a/pkg/controller/render/render_controller.go +++ b/pkg/controller/render/render_controller.go @@ -36,6 +36,10 @@ const ( // // 5ms, 10ms, 20ms, 40ms, 80ms, 160ms, 320ms, 640ms, 1.3s, 2.6s, 5.1s, 10.2s, 20.4s, 41s, 82s maxRetries = 15 + + // renderDelay is a pause to avoid churn in MachineConfigs; see + // https://github.com/openshift/machine-config-operator/issues/301 + renderDelay = 5 * time.Second ) var ( @@ -91,7 +95,7 @@ func New( }) ctrl.syncHandler = ctrl.syncMachineConfigPool - ctrl.enqueueMachineConfigPool = ctrl.enqueue + ctrl.enqueueMachineConfigPool = ctrl.enqueueDefault ctrl.mcpLister = mcpInformer.Lister() ctrl.mcLister = mcInformer.Lister() @@ -321,7 +325,7 @@ func (ctrl *Controller) enqueueRateLimited(pool *mcfgv1.MachineConfigPool) { } // enqueueAfter will enqueue a pool after the provided amount of time. -func (ctrl *Controller) enqueueAfter(pool *mcfgv1.MachineConfig, after time.Duration) { +func (ctrl *Controller) enqueueAfter(pool *mcfgv1.MachineConfigPool, after time.Duration) { key, err := cache.DeletionHandlingMetaNamespaceKeyFunc(pool) if err != nil { utilruntime.HandleError(fmt.Errorf("Couldn't get key for object %#v: %v", pool, err)) @@ -331,6 +335,11 @@ func (ctrl *Controller) enqueueAfter(pool *mcfgv1.MachineConfig, after time.Dura ctrl.queue.AddAfter(key, after) } +// enqueueDefault calls a default enqueue function +func (ctrl *Controller) enqueueDefault(pool *mcfgv1.MachineConfigPool) { + ctrl.enqueueAfter(pool, renderDelay) +} + // worker runs a worker thread that just dequeues items, processes them, and marks them done. // It enforces that the syncHandler is never invoked concurrently with the same key. func (ctrl *Controller) worker() {