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.
This commit is contained in:
James Shubin
2023-08-30 21:19:04 -04:00
parent f9bc50e262
commit cc04221516

View File

@@ -481,6 +481,17 @@ Loop:
} }
// TODO: does this get added in properly? // TODO: does this get added in properly?
limiter.ReserveN(time.Now(), 1) // one event 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 timer.Stop() // it's nice to cleanup
@@ -526,6 +537,17 @@ Loop:
} }
// TODO: does this get added in properly? // TODO: does this get added in properly?
limiter.ReserveN(time.Now(), 1) // one event 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 timer.Stop() // it's nice to cleanup