Skip to content

Extend functionality to deserialize rootfs upper layer of an arbitrary container to a tar archive.#12415

Merged
copybara-service[bot] merged 1 commit intogoogle:masterfrom
benldrmn:feat/restore-rootfs-specific-container
Jan 16, 2026
Merged

Extend functionality to deserialize rootfs upper layer of an arbitrary container to a tar archive.#12415
copybara-service[bot] merged 1 commit intogoogle:masterfrom
benldrmn:feat/restore-rootfs-specific-container

Conversation

@benldrmn
Copy link
Copy Markdown
Contributor

#12119 implemented rootfs snapshotting deserialization (restore) for single-container sandboxes only.
This PR extends this functionality to any container, including containers that are part of a multi-container sandbox.
builds on top of: #12411

@benldrmn benldrmn changed the title Feat/restore rootfs specific container Extend functionality to deserialize rootfs upper layer of an arbitrary container to a tar archive. Dec 28, 2025
@benldrmn benldrmn force-pushed the feat/restore-rootfs-specific-container branch 5 times, most recently from bb90917 to 6baf6e9 Compare January 1, 2026 11:56
@benldrmn
Copy link
Copy Markdown
Contributor Author

Hi @ayushr2 - just making sure this doesn't fall between the cracks (it is the 2nd part of the already merged container rootfs snapshotting MR you merged).

@ayushr2
Copy link
Copy Markdown
Collaborator

ayushr2 commented Jan 13, 2026

@benldrmn I think rootfs snapshot deserialization is already support for multi-container. 3eb1b76 (the PR you linked) added functionality in tmpfs to deserialize from TAR but did not add any runsc API to utilize that.

In a730d6c, we added the necessary plumbing.

In multi-container setup, like k8s, each container within the Pod has its own container spec. So each container can set its own dev.gvisor.tar.rootfs.upper annotation. It is respected in the codebase for sub-containers:

// StartSubcontainer starts running a sub-container inside the sandbox.
func (s *Sandbox) StartSubcontainer(spec *specs.Spec, conf *config.Config, cid string, stdios, goferFiles, goferFilestores []*os.File, devIOFile *os.File, goferConfs []boot.GoferMountConf) error {
log.Debugf("Start sub-container %q in sandbox %q, PID: %d", cid, s.ID, s.Pid.Load())
if err := s.configureStdios(conf, stdios); err != nil {
return err
}
s.fixPidns(spec)
var rootfsUpperTarFile *os.File
if path := specutils.RootfsTarUpperPath(spec); path != "" {
var err error
rootfsUpperTarFile, err = os.OpenFile(path, os.O_RDONLY, 0644)
if err != nil {
return fmt.Errorf("opening rootfs upper tar file: %v", err)
}
}
defer rootfsUpperTarFile.Close()

This feature already exists.

@benldrmn
Copy link
Copy Markdown
Contributor Author

@benldrmn I think rootfs snapshot deserialization is already support for multi-container. 3eb1b76 (the PR you linked) added functionality in tmpfs to deserialize from TAR but did not add any runsc API to utilize that.

In a730d6c, we added the necessary plumbing.

In multi-container setup, like k8s, each container within the Pod has its own container spec. So each container can set its own dev.gvisor.tar.rootfs.upper annotation. It is respected in the codebase for sub-containers:

// StartSubcontainer starts running a sub-container inside the sandbox.
func (s *Sandbox) StartSubcontainer(spec *specs.Spec, conf *config.Config, cid string, stdios, goferFiles, goferFilestores []*os.File, devIOFile *os.File, goferConfs []boot.GoferMountConf) error {
log.Debugf("Start sub-container %q in sandbox %q, PID: %d", cid, s.ID, s.Pid.Load())
if err := s.configureStdios(conf, stdios); err != nil {
return err
}
s.fixPidns(spec)
var rootfsUpperTarFile *os.File
if path := specutils.RootfsTarUpperPath(spec); path != "" {
var err error
rootfsUpperTarFile, err = os.OpenFile(path, os.O_RDONLY, 0644)
if err != nil {
return fmt.Errorf("opening rootfs upper tar file: %v", err)
}
}
defer rootfsUpperTarFile.Close()

This feature already exists.

Right, I might have "oversold" the deserialize functionality in this PR, I think the main contribution is allowing to specify different rootfs paths for different containers in the pod with the newly added annotationRootfsUpperTarContainer annotation. Without that, when creating a multi-container pod in k8s, it is not possible to pick different snapshot tars for different containers.

@ayushr2
Copy link
Copy Markdown
Collaborator

ayushr2 commented Jan 13, 2026

Ah you are probably using Pod annotations, which are copied across all container's OCI specs.

But theoretically, different containers in a Pod can have different annotations. So you can set dev.gvisor.tar.rootfs.upper on each container in a Pod with different values. We do that sometimes in our shim. But I assume that's not an option for you?

@benldrmn
Copy link
Copy Markdown
Contributor Author

benldrmn commented Jan 13, 2026 via email

Comment thread runsc/container/multi_container_test.go Outdated
Comment thread runsc/container/container_test.go Outdated
Comment thread runsc/container/container_test.go Outdated
Comment thread g3doc/user_guide/rootfs_snapshot.md Outdated
Comment thread runsc/specutils/specutils.go Outdated
Comment thread runsc/specutils/specutils.go Outdated
@benldrmn
Copy link
Copy Markdown
Contributor Author

@ayushr2 thanks - addressed all of your comments in my latest commit. I haven't squashed it yet to ease the review / clearer diff - let me know if you prefer me always squashing to a single commit, even during review.

Copy link
Copy Markdown
Collaborator

@ayushr2 ayushr2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Comment thread runsc/specutils/specutils.go Outdated
Comment thread runsc/container/multi_container_test.go Outdated
@ayushr2
Copy link
Copy Markdown
Collaborator

ayushr2 commented Jan 14, 2026

Also please squash your commits:

gvisor/CONTRIBUTING.md

Lines 95 to 99 in e0a2f60

When iterating on a pull request, please amend your commit rather than creating
new commits on the same branch. Our merge bot applies all commits from the
branch to master and does not yet support squash merging. If you'd like to
submit a pull request with multiple commits, please ensure they are independent,
logical units of work that can be applied separately.

@benldrmn benldrmn force-pushed the feat/restore-rootfs-specific-container branch from db05e64 to bf993c7 Compare January 15, 2026 20:13
copybara-service Bot pushed a commit that referenced this pull request Jan 15, 2026
…y container to a tar archive.

#12119 implemented [rootfs snapshotting](https://gvisor.dev/docs/user_guide/rootfs_snapshot/) deserialization (restore) for single-container sandboxes only.
This PR extends this functionality to any container, including containers that are part of a multi-container sandbox.
builds on top of: #12411

FUTURE_COPYBARA_INTEGRATE_REVIEW=#12415 from benldrmn:feat/restore-rootfs-specific-container bf993c7
PiperOrigin-RevId: 856830229
copybara-service Bot pushed a commit that referenced this pull request Jan 16, 2026
…y container to a tar archive.

#12119 implemented [rootfs snapshotting](https://gvisor.dev/docs/user_guide/rootfs_snapshot/) deserialization (restore) for single-container sandboxes only.
This PR extends this functionality to any container, including containers that are part of a multi-container sandbox.
builds on top of: #12411

FUTURE_COPYBARA_INTEGRATE_REVIEW=#12415 from benldrmn:feat/restore-rootfs-specific-container bf993c7
PiperOrigin-RevId: 856830229
@copybara-service copybara-service Bot merged commit 1d333bf into google:master Jan 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants