Skip to content

ENT-14702: Reuse watcher state between policy reload - #6376

Draft
victormlg wants to merge 6 commits into
cfengine:masterfrom
victormlg:cf-reactor.ReusePolicyState
Draft

victormlg wants to merge 6 commits into
cfengine:masterfrom
victormlg:cf-reactor.ReusePolicyState

Conversation

@victormlg

Copy link
Copy Markdown
Contributor

Between each policy reload, the watcher state is discarded, however, if the promise is identitical, we would like to be able to detect the changes that happened during the reload. Thus, we need to pass the watcher states.

Signed-off-by: Victor Moene <victor.moene@northern.tech>
Signed-off-by: Victor Moene <victor.moene@northern.tech>
Promises are skipped to prevent running them several times. However, on event, we want to run them every single time:
- we clear the promise lock cache
- we set the default if_elapsed time for bundles run from an events promise to be 0, so it doesn't skip the promises.

Fixed also connection cache and custom promise prologue and epilogue. Clear function cache before "then" bundle run

Signed-off-by: Victor Moene <victor.moene@northern.tech>
- No need for map anymore, since watcher keeps track of the promise
- No need to keep key as variable anymore, since we do not use a map
- No need to run bundle inside watcher.c
- No risk of running a bundle from a wrong key between policy reads

Signed-off-by: Victor Moene <victor.moene@northern.tech>
Signed-off-by: Victor Moene <victor.moene@northern.tech>
@victormlg victormlg changed the title Reuse watcher state between policy reload ENT-14702: Reuse watcher state between policy reload Oct 5, 2026
Instead of destroying all watchers, it now keeps the state, such that, even if an event
happens during policy reload, it will get detected by comparing the previous state.

Ticket: ENT-14702
Signed-off-by: Victor Moene <victor.moene@northern.tech>
@victormlg
victormlg force-pushed the cf-reactor.ReusePolicyState branch from a982c7d to a63277f Compare October 5, 2026 11:43
VarRefDestroy(ref);
}

static PromiseResult KeepAgentPromise(EvalContext *ctx, const Promise *pp, ARG_UNUSED void *param)
@victormlg
victormlg marked this pull request as draft October 5, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants