perf(tfork): inject small clone files before publication - #12
Open
yiying-zhang wants to merge 69 commits into
Open
perf(tfork): inject small clone files before publication#12yiying-zhang wants to merge 69 commits into
yiying-zhang wants to merge 69 commits into
Conversation
Stabilize live tfork source freezing
…-main Stabilize single-copy tfork clone path
Rewrite tclone setup for Gensee Crate
Clarify Gensee tclone host setup
Initialize temporary CRIU process UIDs
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.
What this changes
This PR adds a repeatable live-clone option:
It copies a small host file into one selected tfork child after CRIU restores the
child and before that child is registered in libpod. This lets a single live
fork produce children with different contexts, credentials, capability
descriptions, or other small per-child configuration files without a later
podman cporpodman exec.COPY_INDEXis zero-based. The option may be repeated to inject multiple filesinto one child or different files into different children.
Example
Both children receive the file at
/run/gensee/context.json, but child 0 getschild-0.jsonand child 1 getschild-1.json.Lifecycle and failure semantics
For a live clone, Podman now:
/proc/<pid>/root;Injection is part of the existing clone transaction. If any source open,
destination lookup, file creation, or copy fails, the operation returns an error
and transactional rollback cleans up the incomplete clone batch. Earlier
children are not published as a partial success.
“Before publication” specifically means before libpod registration. The child
process has already been restored and is running when injection occurs. This PR
therefore prevents Podman clients from observing an unconfigured child, but it
does not prevent an internal child process from racing with the injection and
reading the destination first. Workloads that require the file to exist before
any child instruction executes would additionally need the child held frozen
until injection finishes.
Path, ownership, and file safety
Each injection must satisfy the following contract:
O_NOFOLLOW;pathrs.OpenInRoot;openat(O_NOFOLLOW);which normally means
root:rootfor rootful Podman;0600.This interface does not provide ownership or mode overrides. Consequently, a
non-root child process normally cannot read a newly created injected file. To
serve a non-root process with the current interface, the image or source
filesystem must pre-create the destination with the desired ownership; injection
preserves that owner while truncating the file and forcing mode
0600.The destination parent directory must already exist. Only file contents are
copied; source ownership, timestamps, permissions, and extended attributes are
not preserved.
Performance impact
This does not shorten CRIU Phase A or Phase B. Its benefit is eliminating a
separate post-clone setup operation and keeping per-child initialization inside
the transactional fork workflow.
Injection is on the publication critical path and currently runs sequentially
per child. Added latency is therefore approximately the secure path lookup and
copy time for the total injected data. The 1 MiB per-file limit bounds the most
common use case, but many files or many children will increase fork completion
latency roughly linearly.
Patch scope
The file-injection behavior is implemented by
f9e0a8b5d8be28ebf2d8946145297f307f8c6d66; follow-up commit7989e55afmakes its ownership and mode contract explicit in CLI help and code.This branch is stacked on earlier tfork transaction, synchronization, readiness,
and metadata work, so the full diff against
gensee-tclonealso contains thoseprerequisite commits.
Validation
indices, and relative paths;
go test ./cmd/podman/containers ./pkg/domain/infra/abi;expected child process trees.