Visitar URL original
Postpone the cancellation of authenticator to the very last moment by nolar · Pull Request #1286 · nolar/kopf · GitHub
Skip to content

Postpone the cancellation of authenticator to the very last moment - #1286

Merged
nolar merged 1 commit into
mainfrom
late-tasks-special-treatment
Mar 23, 2026
Merged

nolar merged 1 commit into
mainfrom
late-tasks-special-treatment

Conversation

@nolar

@nolar nolar commented Mar 22, 2026 •

Copy link
Copy Markdown
Owner

Problem: We now cancel all tasks at once (as soon as any task exits, e.g. the exit-flag waiter). However, some tasks require other tasks to properly terminate. For instance, the peering shutdown in the orchestrator requires the authenticator to continue working. With the current approach, the authenticator exits soon, and the peering cannot shut down and de-register itself properly.

Solution: With the new approach, some tasks are made special —the "core" tasks— and we postpone their cancellation to the very last moment, which happens strictly after all the regular ("root") tasks exit, but before the cleanup activities as before.

Backwards compatibility: This way, we keep all the interfaces intact: spawn_tasks and run_tasks() are a part of the public interface (though I regret this move), their change would require semantic v2, which is not planned. Only the internal relations between tasks change, and one task —the authenticator— disappears from the returned list, though remains controlled internally.

Extensibility: When and if needed, some other tasks can be grouped into several layers (exiting priorities) the same way — all hidden from the public interface.

Benefit: a plain and elegant solution to a very specific problem, no over-engineering or over-generalisation (as in the superseded PRs).

Fixes #1033. Supersedes #1110. Supersedes #1282.

@nolar nolar added the enhancement New feature or request label Mar 22, 2026
@nolar
nolar force-pushed the late-tasks-special-treatment branch 2 times, most recently from 29317ed to 1eb001d Compare March 23, 2026 11:43
@nolar
nolar marked this pull request as ready for review March 23, 2026 11:46
@nolar
nolar force-pushed the late-tasks-special-treatment branch 3 times, most recently from 0c8f2cb to 4958dbb Compare March 23, 2026 12:28
**Problem:** We now cancel all tasks at once (as soon as any task exits, e.g. the exit-flag waiter). However, some tasks require other tasks to properly terminate. For instance, the peering shutdown in the orchestrator requires the authenticator to continue working. With the current approach, the authenticator exits soon, and the peering cannot shut down and de-register itself properly.

**Solution:** With the new approach, some tasks are made special —the "core" tasks— and we postpone their cancellation to the very last moment, which happens strictly after all the regular ("root") tasks exit, but before the cleanup activities as before.

**Backwards compatibility:** This way, we keep all the interfaces intact: `spawn_tasks` and `run_tasks()` are a part of the public interface (though I regret this move), their change would require semantic v2, which is not planned. Only the internal relations between tasks change, and one task —the authenticator— disappears from the returned list, though remains controlled internally.

**Extensibility:** When and if needed, some other tasks can be grouped into several layers (exiting priorities) the same way — all hidden from the public interface.

Signed-off-by: Sergey Vasilyev <nolar@nolar.info>
@nolar
nolar force-pushed the late-tasks-special-treatment branch from 4958dbb to 4756455 Compare March 23, 2026 13:55
@nolar
nolar merged commit b99d8bb into main Mar 23, 2026
25 checks passed
@nolar
nolar deleted the late-tasks-special-treatment branch March 23, 2026 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

peering depends on 'Credentials retriever' task but on shutdown that is stopped sooner

1 participant