Repository navigation
feat: a playbook job can be paused and resumed - #47
Merged
Merged
Conversation
The af_events callback plugin and the af_facts cache plugin of the controller's 7.10.0, a job's own key that seals its checkpoints, and the controls that come on a job's stdin after it.
The agent makes or removes the playbook's pause file as the pauses and resumes come on its stdin, says the plugin's pause and resume as items, sends its checkpoints sealed, and starts a playbook again at its first unfinished task with what its checkpoints restore.
Docker, Podman and Kubernetes start a job's container with its stdin left open after the job (StdinOnce false), and Send writes a pause or a resume on it through an attach of its own.
It handles the controller's pause message, says the jobs it holds paused in its hello, keeps them on disk across a restart, and opens a run message's resume for a playbook that starts again from its checkpoints.
Podman closes a container's stdin once its first attach ends, whatever StdinOnce says. On Docker and Podman a pause or a resume is now handed to the job by an exec of the Runner's control command, which writes it on the job's control pipe; the containers keep StdinOnce true. Kubernetes keeps writing it on the pod's stdin.
This was referenced Dec 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of ansibleforms/ansibleforms 7.10.0 pause and resume (ansibleforms/ansibleforms#1625, ansibleforms/ansibleforms#1626).
A playbook job on a Go Runner can now be paused and resumed as on the controller's own Node.js Runner: the playbook finishes the task it runs, holds before its next one with its process alive, and goes on there after a resume. A playbook whose container is lost (its host rebooted) can start again at its first unfinished task from its checkpoints. The socket contract stays 3, so the controller works with it unchanged.
Protocol messages handled
pause(controller to Runner):{ jobId, paused, by }.paused: trueholds the playbook before its next task,falselets it go on;byis who asked (the plugin prints "Paused by" and "Resumed by"). A pause for a job the Runner does not run is left, a pause that comes while the container starts is written once it runs.hellonow sayspaused: the jobs it holds paused, so the controller node that takes its socket resumes the ones it no longer wants paused. The pauses are kept inpauses.jsonbeside the spools, so a restarted Runner says them too and writes them again on the containers it follows.paused(after,next) andresumed: the af_events plugin's pause and resume events, taken out of the events in their place, aswriteEventsAndPausesdoes.checkpoints(sealed): the plugins' facts, variables and progress, sealed for the controller in the job's container with the job's own key (HKDF of the token and the job id, the same key the controller's bundles use). The container never gets the Runner's token.runwithresume: opened like the secrets; the playbook starts at--start-at-task, its failed hosts left out of its limit, its facts (af_facts cache plugin) and variables (af_events) restored. A resume that does not open refuses the job.How it works in each mode
The Runner has no shared disk with a job's container, so the pause travels into it: the agent in the container makes or removes the playbook's pause file, which the af_events plugin polls before each task. How the pause gets to the agent depends on the engine (
Engine.Send):ansibleforms-rte-runner control <line>), which writes the line on the job's control pipe (a named pipe the agent reads). Podman closes a container's stdin once its first attach ends, whateverStdinOncesays, so the stdin cannot carry it there; the exec works the same on both and after a Runner restart.stdinOnce: false). No new permission:pods/attachcreate and get were there already (nopods/exec).Limitations:
Other changes
PAUSED_JOBS_CRONandJOB_PAUSE_MAX_HOURSare kept out of a playbook's environment, as the controller does.controlcommand of the binary (used inside a job's container only).TestRealPause); on Docker and Podman it also starts a playbook again from checkpoints and checks it begins at its second task with the variable they restore.Tests keep statement coverage at 100.0%.