Control socket follow-ups: inspect rename, collision hard-fail, API narrowing - #171
Open
congwang-mk wants to merge 3 commits into
Open
Control socket follow-ups: inspect rename, collision hard-fail, API narrowing#171congwang-mk wants to merge 3 commits into
congwang-mk wants to merge 3 commits into
Conversation
"config" universally reads as get/set of the tool's own configuration (git config, npm config) and collides conceptually with sandlock's profile management, while the container ecosystem convention for "show me everything about this running instance" is "inspect" (docker, podman). The new name also leaves room to later include runtime state (ports, uptime, pids) alongside policy, which "config" semantically cannot. Renaming is a hard break with no alias, done now while pre-1.0 makes it cheap; the control-socket wire verb stays "config" since it specifically fetches the effective policy. Signed-off-by: Cong Wang <cwang@multikernel.io>
The no_supervisor path warned and continued on AlreadyExists, leaving a second sandbox running invisible to sandlock ps, which is exactly the outcome the supervisor path already hard-fails to prevent. Mirror that arm. The runtime-dir setup also moves after the notif-fd read. An error return from do_spawn relies on Drop killpg to reap the forked child, which only works once the child has setpgid into its own group; the notif-fd write is the child setup-complete signal. Returning before it races killpg against setpgid: killpg loses with ESRCH, and Drop then deadlocks its blocking waitpid against a child parked on the ready pipe whose write end Drop itself still holds. Signed-off-by: Cong Wang <cwang@multikernel.io>
Everything in the control module was public, but setup_runtime_dir, setup_runtime_dir_no_socket, and spawn_control_loop are lifecycle plumbing only sandbox.rs may call; invoking them from outside would corrupt live sandbox state. Demote them and runtime_dir_uid to pub(crate), keeping only the client API (list_live_sandboxes, send_control_request, ControlResponse), the on-disk layout helpers (sandbox_dir, pid_path, sock_path), and cleanup_runtime_dir, which sandlock kill needs because SIGKILL skips the supervisor Drop. Also trim the crate-root re-exports to format_net_rule, the only one the CLI uses; the reverse serializers stay reachable under profile:: and format_http_rule becomes pub(crate). Anything public gets depended on, and pre-1.0 is when narrowing is free. Signed-off-by: Cong Wang <cwang@multikernel.io>
Contributor
Author
|
@sachin2605 Please take a look. Thanks! |
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.
Follow-ups to #153 from its final review round.
Changes
sandlock configrenamed tosandlock inspect"config" universally reads as get/set of the tool's own configuration (git config, npm config) and collides conceptually with sandlock's profile management, while the container ecosystem convention for "show me everything about this running instance" is "inspect" (docker, podman). The new name also leaves room to later include runtime state (ports, uptime, pids) alongside policy. Hard break with no alias, done now while pre-1.0 makes it cheap. The control-socket wire verb stays
configsince it specifically fetches the effective policy.no_supervisorspawn hard-fails on a live name collisionThe
no_supervisorpath warned and continued onAlreadyExists, leaving a second sandbox running invisible tosandlock ps, which is exactly the outcome the supervisor path already hard-fails to prevent. It now mirrors that arm; other runtime-dir errors (e.g. restricted/dev/shmin nested sandboxes) still warn and continue.The runtime-dir setup also moves after the notif-fd read. An error return from
do_spawnrelies onDrop'skillpgto reap the forked child, which only works once the child hassetpgid'd into its own group; the notif-fd write is the child's setup-complete signal. Returning before it raceskillpgagainstsetpgid:killpgloses with ESRCH, andDropthen deadlocks its blockingwaitpidagainst a child parked on the ready pipe whose write endDropitself still holds. Found the hard way: the first version of this fix returned inside that window and hung reliably. A comment now pins the invariant, andtest_control_name_collision_no_supervisorcovers the path.controlAPI narrowed to its external consumersEverything in the control module was public, but
setup_runtime_dir,setup_runtime_dir_no_socket, andspawn_control_loopare lifecycle plumbing onlysandbox.rsmay call; invoking them from outside would corrupt live sandbox state. They andruntime_dir_uidare nowpub(crate). What stays public each has a real consumer: the client API (list_live_sandboxes,send_control_request,ControlResponse), the on-disk layout helpers (sandbox_dir,pid_path,sock_path), andcleanup_runtime_dir(needed bysandlock killbecause SIGKILL skips the supervisor'sDrop). The crate root now re-exports onlyformat_net_rulefrom the profile module; the reverse serializers stay reachable underprofile::andformat_http_rulebecomespub(crate).Test plan