Commit Graph
294 Commits
Author SHA1 Message Date
RahulThennarasu 4d47c58a3d Fix: Allow OCI archives without manifest annotations (#397)
Fixes #369

Per the OCI Image Spec, manifest descriptor annotations are optional.
Previously, archives without annotations would fail to import with
"Failed to import image".

**Changes:**
- Modified `getImageReferencefromDescriptor` to return digest-based
references (`untagged@sha256:...`) when annotations are missing
- Removed guard that skipped manifests without annotations
- Added test case with `scratch_no_annotations.tar`

**Testing:**
All 167 tests pass, including new test for images without annotations.
2025-11-15 00:32:15 -03:00
Danny Canter 4c761d50c6 Add new FileHandle option for serial console output (#410)
Taking in a filehandle gives the user quite a bit more freedom on how to
handle boot log output. They can set up a kqueue watch on it and
redirect output somewhere else etc etc. The implementation for this has
us take in a new BootLog type that has two options:

1. .file, which is analogous to what we had prior. Just provide a URL
and a true by default append field.
2. .fileHandle which is the new addition. Can pass any fd that is
writable, and the VMM should write serial console output to it.
2025-11-14 10:40:32 -08:00
Danny Canter b501931267 Integration: Actually run testContainerStopIdempotency (#409)
We (I) forgot to add it :)
2025-11-13 14:37:42 -08:00
Danny Canter c8549315ed LinuxContainer: Keep reference to vended execs (#408)
This change is aimed at making forgetting to call .delete() on a
LinuxProcess less destructive than it can be. Because Virt.framework
invalidates any vsock fds it vended if the vm is stopped, trying to
perform some operations on the grpc client through any of the process
methods could trigger an ebadf, which NIO asserts on. This keeps a
reference to the execs and deletes all of them for you once the
container dies. I still think leaving .delete a public method is useful
as otherwise the stdio fds are left open, but cleanup should occur all
in one place now if you don't care about this.

This additionally:

1. Fixes two of our tests that forgot to delete() an exec.
2. Adds two new tests to verify that process.delete() is now idempotent,
and we don't need to call delete().
2025-11-13 02:13:09 -08:00
Danny Canter 322a724024 VZVirtualMachineInstance: Remove tracking agent conns (#403)
This was added to try and see if it alleviated the infrequent ebadf nio
panics, but they still occur, so back to the drawing board :)
2025-11-12 14:37:04 -08:00
Ihor Dvoretskyi 6b8fe3b43f Update example documentation (#406)
- Added README.md for examples directory to provide an overview and
instructions.
- Updated ctr-example README.md with clearer build and run instructions.
- Improved lab.md with a dynamic command to fetch the latest kernel.

Signed-off-by: Ihor Dvoretskyi <ihor@linux.com>
2025-11-12 14:30:01 -08:00
Raj 3ef0002a46 docs: add guidelines for AI contributions (#407)
Adds AI Contribution guidelines to `CONTRIBUTING.md`.
2025-11-12 14:09:24 -08:00
Dmitry Kovba b94be374ae Set the default PATH and fix the bug in retrieving the PATH value (#383)
- We're already setting the default `HOME` and `TERM`. Setting the
default `PATH` as well seems reasonable.
- This PR also fixes the bug in retrieving the `PATH` value (`PATH=` has
to be removed, and `=` should be allowed in folder names).
2025-11-12 15:48:02 -03:00
J Logan 6bf00ad796 Make socket proxy logging less chatty. (#405)
- Move data transfers to trace level.
- Move shutdown errors to warning.
- Only log listen, connect, and cleanup at info.
2025-11-12 09:45:30 -08:00
Danny Canter 01437a44a2 Vminitd: Sync(2) on shutdown (#400) 2025-11-12 09:39:46 -08:00
Danny Canter bbe9ebd8fa TimeSyncer: Amend some bits (#404) 2025-11-12 09:39:26 -08:00
Danny Canter a31abd73a4 Vminitd: Remove unused method (#401) 2025-11-12 09:39:00 -08:00
Danny Canter 8a9b0deb82 LinuxProcess: Swap from logging in delete (#386)
This changes LinuxProcess to not just log errors but return them.
2025-11-11 14:42:41 -08:00
Danny Canter cfe4fd77cb Socket: Return Int32 and not FileHandle for uds receives (#398)
Gives more flexibility. The caller doesn't need to carry around this
FileHandle object if they don't really need it.
2025-11-10 15:48:06 -08:00
Kathryn Baldauf 055b697037 Update the cp kernel command to not use quotes (#396)
Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-11-10 14:07:13 -05:00
Kathryn Baldauf 0061af6d81 Update ctr-example (#395)
Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-11-10 12:11:56 -05:00
Eric Ernst 13e6de0169 Update lab.md (#393) 2025-11-10 11:25:39 -05:00
Eric Ernst 6f2eb093aa Create lab.md (#392) 2025-11-10 10:31:43 -05:00
Aditya Ramani 2e93381de3 Pull initfs from repository when running ctr-example (#391)
Use the initial filesystem image from a remote repository when brining
up the ctr-example
2025-11-09 20:54:59 -08:00
Kathryn Baldauf 2c4c044060 Update ctr-example to 0.13.0 and clean readme (#390)
Update containerization dependency in ctr-example to the latest tag of
containerization. Additionally make README for ctr-example more clear.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-11-09 13:50:00 -08:00
AJ Emory b512617dc4 Updating ctr-example to make setup easier (#389)
- Example Makefile now supports fetch-default-kernel for easier setup
- added 'make all' to build Containerization and ctr-example in one step
- Updated README to add build and run instructions
2025-11-07 18:18:26 -08:00
Danny Canter 4855310dca OCI: Don't umount the rootfs path if it's not a mountpoint (#387)
Given this package is generic, and we use it in the guest where today we
actually umount via an rpc, just skip this if it's not a mountpoint.
2025-11-07 14:25:34 -08:00
Danny Canter 3de29338e1 Integration: Add stdio ingest test (#385)
Add a test to ingest 200MiB of data across stdout/stderr. Useful to test
how fast we can ingest stdio. The timing will always be a tad off as it
times between start and wait returning, and there's quite a lot in the
way.. but it's a good enough metric.
2025-11-07 11:08:01 -08:00
Danny Canter 619354ef74 Don't ignore possible errors from dup(2) (#382)
Everytime we grab a vsock connection we dup the conn and close the
original, otherwise we'd need to carry around the vsock connection type
everywhere as it closes the fd in its destructor. We weren't checking
the return value of dup however, so if it did fail we'd have a useless
filehandle with an fd of -1.
2025-11-06 15:48:02 -08:00
Raj 52ed5b542c Revert "Add filesystem notification (FSNotify) support" (#384)
Reverts apple/containerization#294. This is causing the CI to break
because of concurrency issues with tests. Let's revert while we
investigate.
2025-11-05 15:06:24 -08:00
Raj 80e84a9ce1 Add filesystem notification (FSNotify) support (#294)
Addresses apple/container#141, where containers don't receive filesystem
events on mounted volumes, preventing incremental rebuilds and other
file-watching features. This PR implements the guest-side components for
FSNotify. Host-side implementation in the container repo will complete
the pipeline.

Summary:
- Add gRPC protocol definitions for filesystem event notifications
- Implement guest-side event handler that generates Linux inotify events
- Add CLI testing tool (`cctl fsnotify`) and integration test
infrastructure
2025-11-05 12:20:15 -08:00
Danny Canter bec1008f4d VsockConnectionStream: Conform to AsyncSequence (#380)
I didn't like how we expose the asyncstream via a public connections
field. We should have the type conform to AsyncSequence and then hide
the underlying stream. This also stops listening on the stdio ports
after we get the initial connection.
2025-11-03 14:09:56 -08:00
Danny Canter 8b39713a00 EXT4: Optimize unpack (#378)
Optimize unpack a little by trying to reduce allocations in the hot
path. Today for every file we read the entire file into memory and then
pass the data blob to the ext4 writer to eventually be written to the
sparse file. Before being written to the sparse file the data is copied
*again* to a temp buffer before finally hitting write(2) in FileHandle.

This change moves things around such that we can pass an optional buffer
to the ext4 create() (so we can reuse a buffer for file writes), as well
as stops reading entire files into memory by passing the archive entry
itself (wrapped in a ReaderStream object albeit) down to the writer.

Testing with unpacking every platform for
`docker.io/jenkins/jenkins:lts` on an M1 Max:

Old Avg (5 runs): 7.43s
New Avg (5 runs): 5.31s
2025-11-03 12:22:38 -08:00
Danny Canter f3d998975c LinuxContainer: Add new constructor (#377)
Add a constructor that allows just passing in a configuration without
doing the closure dance.
2025-10-31 14:27:39 -07:00
Dmitry Kovba 0177505c58 Improvements to Protobuf.Makefile (#356)
Improvements to `Protobuf.Makefile`. Also see
https://github.com/apple/container/pull/821.
2025-10-30 11:13:31 -07:00
Danny Canter 07325561f3 Integration: Add UDS test (#374) 2025-10-30 01:00:54 -07:00
Danny Canter df8b97a9f7 Chore: Use guestVsockPorts (#373)
This was a funny oversight. We have two port spaces, one for listening
sockets on the host, and one for vsock proxies in the guest, but only
the host "allocator" was being used. This didn't really matter as the
ports in the guest would still be unique, but would still be good to
fix.
2025-10-29 16:44:28 -07:00
Dmitry Kovba 8682365800 Make pid an optional (#372)
Makes `pid` an optional to avoid killing the process with pid 0.
2025-10-29 16:31:06 -07:00
Dmitry Kovba 5696732315 Improvements to the logs (#371)
Improvements to the logs.
2025-10-29 15:39:17 -07:00
Dmitry Kovba aa591a4801 Improvements to Makefile (#370)
Improvement to `Makefile`. Also see
https://github.com/apple/container/pull/822.
2025-10-29 15:38:49 -07:00
Mark Baseggio d7814e4421 Make Index.mediaType optional to comply with OCI spec (#368)
The `mediaType` field in the `Index` struct was defined as a required
field, but according to the [OCI Image Index
Specification](https://github.com/opencontainers/image-spec/blob/main/image-index.md),
this field is optional.

This caused failures when loading OCI archives where the `index.json`
omits the top-level `mediaType` field, which is valid per the spec.
Tools like skopeo can generate such archives.

## Error before fix
```
keyNotFound(CodingKeys(stringValue: "mediaType", intValue: nil))
```

## Changes
- Changed `Index.mediaType` from `String` to `String?`
- Updated initializer to accept optional `mediaType` parameter
- Added comment documenting that field is optional per OCI spec

## Testing
Verified that OCI archives without a top-level `mediaType` field in
`index.json` now load successfully.

Fixes https://github.com/apple/container/issues/330
2025-10-29 01:46:16 -07:00
Danny Canter cc66529b59 VirtualMachineManager: Take in EventLoopGroup directly (#367) 2025-10-28 02:24:53 -07:00
Danny Canter 02fa190aeb Always close agent connections (#365) 2025-10-27 21:19:48 -07:00
Danny Canter eb1b8741b5 LinuxContainer/Pod: Remove pause/resume (#366) 2025-10-27 17:33:49 -07:00
Danny Canter 939108b27a VZVirtualMachineInstance: Move some extensions around (#364)
Move the implemention of VirtualMachineInstance to a standalone
extension and all the other helper methods outside of this.
2025-10-27 09:28:25 -07:00
Danny Canter 1b10836c41 VZVirtualMachineInstance: Remove sandbox references (#363)
This type used to be named Sandbox iirc. Remove these references now
that this is no longer the case.
2025-10-27 09:26:05 -07:00
Dmitry Kovba 9623b4b6d3 Position nested types and initializers on top (#355)
Position nested types and constructors on top in the parent types.
2025-10-27 09:22:47 -07:00
Dmitry Kovba a829fdcdfd Improve log and error messages (#352)
Improved log and error messages.
2025-10-27 09:21:54 -07:00
J Logan 3897e578c3 Use exact permissions for socket mount into guest. (#362)
- Closes #361.
2025-10-25 22:19:06 -07:00
Kathryn Baldauf 1165faabd8 Use correct flag size in Mount for glibc (#360)
The mount flags are defined as `Int`s for musl but as `Int32`s for
glibc, despite the mount methods expecting `Int32` for both. This was
leading to build errors when building with glibc like:

```
 |         "async": .init(true, MS_SYNCHRONOUS),
 |                              `- error: cannot convert value of type 'Int' to expected type 'Int32'
```

This PR allows for different Int sizes based on if we're building for
glibc or not to avoid this build error.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-10-24 17:32:35 -07:00
Kathryn Baldauf 41eda106e3 Only load epoll file if we can import musl (#359)
This class does not work for glibc due to missing flags and methods.
This PR removes the ability to load the `Epoll` class when using glibc
for now.

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-10-24 16:48:25 -07:00
Kathryn Baldauf a27fefbb59 Add custom decoder inits for various oci types that use omitempty (#347)
Many fields on the various OCI types use "omitempty" for encoding and
decoding the json representation in golang. This PR adds custom json
decoder functions to allow for behavior similar to "omitempty".

---------

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
2025-10-24 15:05:40 -07:00
Danny Canter 0297605ef8 Bump ctr-example to 0.12.0 (#357)
It takes a pinned dependency on cz and was quite a bit behind.
2025-10-24 14:48:39 -07:00
Danny Canter f697215e54 LinuxContainer: Stop all relays on create failure (#358)
If create fails we don't cleanup the relays we may have setup.
2025-10-24 14:48:26 -07:00
Dmitry Kovba c7af5b8222 Rename process to command (#354)
Rename `process` to `command` (assuming we agree on the change).
2025-10-24 13:27:56 -07:00