Skip to content

Commit

Permalink
controller: Add a 5s delay before rendering MCs
Browse files Browse the repository at this point in the history
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:
openshift#301
  • Loading branch information
cgwalters committed Jan 15, 2019
1 parent d227bc4 commit d902c1f
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pkg/controller/render/render_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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))
Expand All @@ -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() {
Expand Down

0 comments on commit d902c1f

Please sign in to comment.