Repository navigation
Add PID namespaces and jobs to the broker core - #1818
Draft
Weidong Cui (wdcui) wants to merge 8 commits into
Draft
Weidong Cui (wdcui) wants to merge 8 commits into
Weidong Cui (wdcui) wants to merge 8 commits into
Conversation
Weidong Cui (wdcui)
force-pushed
the
wdcui/ulitebox/pid-namespaces
branch
from
November 7, 2026 03:49
4820676 to
cfb493f
Compare
A `PidNamespace` owns the ID allocator, process and thread registries and controlling-terminal table that `BrokerCore` used to hold, so each namespace numbers its processes from 1 and confines lookups, signals, process groups, sessions and `kill(-1)` to itself. `BrokerCore::with_pid_namespace` returns a view whose root processes, and so their descendants, are in a given namespace; several views can share one, as with `shareProcessNamespace`. - `max_processes` is enforced broker-wide through a `live_processes` count. - `SignalTarget::All` spares the caller and the namespace's init (its first process created with its initial thread, by `ProcessKey`) instead of every process without a creator. - Terminals belong to one namespace: `TerminalEndpoint::owner_namespace` (PTY owners set by `Devices::with_owner_namespace`, otherwise the broker's first namespace), and `associate` refuses a terminal another namespace owns. A new namespace view starts without the broker's terminal. Nothing in production creates a second namespace yet. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5406de6-bab4-4f3b-b232-ae238032c2c2
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5406de6-bab4-4f3b-b232-ae238032c2c2
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5406de6-bab4-4f3b-b232-ae238032c2c2
Replace `BrokerCore::with_terminal` and `with_pid_namespace` with `with_container(pid_namespace, terminal)`, which creates a container with its own terminal slot, and add `pid_namespace()`. A terminal now belongs to the first PID namespace whose session acquires it, through `TerminalEndpoint::claim`, instead of to an owner set on its devices or to the broker's first namespace. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5406de6-bab4-4f3b-b232-ae238032c2c2
BrokerKernel now holds the broker-wide state and enforces one kernel per process; BrokerCore is a container handle with its own PID namespace, file service, and terminal slot, created only by BrokerCore::new. Root processes in a PID namespace are created one at a time, so the first root registered is the first started and becomes init. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5406de6-bab4-4f3b-b232-ae238032c2c2
Each container handle now shares a `Container` with its terminal, its process and thread counts, and a terminating flag. `has_processes` reads the container's process count, so containers sharing a PID namespace drain independently. `terminate_container` refuses new processes in the container and requests an expected shutdown of each of its runners. `ResourceKind::Tasks` counts the threads of the creator's container, while `max_threads` still bounds the whole broker. A child is in its parent's container, whichever handle creates it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5406de6-bab4-4f3b-b232-ae238032c2c2
The `dev_tests` ratchets limit `pub use` and global statics in `litebox_broker_core`. `pid_namespace` is now a public module, like `terminal`, instead of being re-exported, and the next namespace ID is a `BrokerKernel` counter instead of a global, so `PidNamespace::new` takes the kernel. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5406de6-bab4-4f3b-b232-ae238032c2c2
Weidong Cui (wdcui)
force-pushed
the
wdcui/ulitebox/pid-namespaces
branch
from
November 8, 2026 03:14
eacadde to
ad783d9
Compare
BrokerCore is now the once-per-process kernel, independent of any PID namespace, file service or job. A public Job replaces the per-container handle as the lifecycle and accounting scope, and ProcessContext (namespace, file service, job) says where a root runs; children inherit their parent's. Hosts create each root explicitly with BrokerCore::create_process, and setup_connection only attaches it, checking the peer's credential. Whoever creates a process retires it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: f5406de6-bab4-4f3b-b232-ae238032c2c2
|
🤖 SemverChecks 🤖 Click for details |
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.
This PR adds PID namespaces and jobs to the broker core, the second step toward running every container of a pod in one broker.
BrokerCorebecomes a once-per-process kernel holding broker-wide state. Each root process is created explicitly in aProcessContext(PID namespace, file service,Job); children inherit it, andsetup_connectiononly attaches an existing process. Namespaces number processes from 1 and confine lookups, signals, groups, sessions andkill(-1). Jobs drain and terminate independently, andTaskscounts the job's threads. Single-container behavior is unchanged.