From cc0422151611b7fcb9babe64d6236a835d2cc6f4 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Wed, 30 Aug 2023 21:19:04 -0400 Subject: [PATCH] engine: graph: Allow pause/resume while in retry or limit The retry and limit "satellite" event loops didn't allow pausing or resuming, and instead you needed to wait until either was done before you could pause. The downside of this patch is that for very fast graph transitions, we wouldn't be really obeying the limits anymore, however now that we have per resource kind+name uid, we can persist the limits across graph swaps if we want to. Most importantly, this allows us to exit entirely when we're stuck in one of these satellite loops. --- engine/graph/actions.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/engine/graph/actions.go b/engine/graph/actions.go index bad14c78..74bc3b0c 100644 --- a/engine/graph/actions.go +++ b/engine/graph/actions.go @@ -481,6 +481,17 @@ Loop: } // TODO: does this get added in properly? limiter.ReserveN(time.Now(), 1) // one event + + // this pause/resume block is the same as the upper main one + case _, ok := <-obj.state[vertex].pauseSignal: + if !ok { + obj.state[vertex].pauseSignal = nil + break LimitWait + } + select { + case _, closed = <-obj.state[vertex].resumeSignal: // channel closes + // resumed! + } } } timer.Stop() // it's nice to cleanup @@ -526,6 +537,17 @@ Loop: } // TODO: does this get added in properly? limiter.ReserveN(time.Now(), 1) // one event + + // this pause/resume block is the same as the upper main one + case _, ok := <-obj.state[vertex].pauseSignal: + if !ok { + obj.state[vertex].pauseSignal = nil + break RetryWait + } + select { + case _, closed = <-obj.state[vertex].resumeSignal: // channel closes + // resumed! + } } } timer.Stop() // it's nice to cleanup