Commit Graph
286 Commits
Author SHA1 Message Date
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
J Logan 6f7601e475 Handle EOF on one side of a UnixSocketRelay. (#323)
- Current implementation shuts down everything as soon as EOF is
detected on DispatchSourceRead for the relay. This is problematic for,
say an HTTP request where the client makes a request, and calls
`shutdown(fd, SHUT_WR)` to close the send side, but it expects to be
able to keep calling `recv()` to get the response.
- Changed cancel handlers so that the one that sees that both sources
have been cancelled then closes both the UDS and vsock fds.
- Updated vminitd VsockProxy to also do `shutdown(fd, SHUT_WR)` for read
hangup or EOF, and only close the underlying fds and unwire pollers on
full hangup, broken pipe, error, or when both sides half-close.
2025-10-24 13:13:13 -07:00
Dmitry Kovba 57ad7ad629 Throw an error in StandardIO.resize() (#350)
Throw an error in `StandardIO.resize()`, which is unsupported.
2025-10-24 12:52:58 -07:00
Dmitry Kovba 2dbba786d2 Use a protocol type instead of the concrete type (#353)
Use a protocol type instead of the concrete type.
2025-10-24 12:49:03 -07:00
Dmitry Kovba 9f5aaf247a Remove an unnecessary function (#351)
Remove an unnecessary function to simplify the code.
2025-10-24 11:48:55 -07:00
Dmitry Kovba a405d88e6d Throw an error for an empty array (#349)
Throw an error for an empty array before accessing the first element.
2025-10-24 11:19:25 -07:00
Danny Canter ca657f5009 Always provide a serial console (#346) 2025-10-23 14:32:56 -07:00
Danny Canter dc4284a149 Introduce new experimental LinuxPod type (#343)
Closes #319

Introduces a new type capable of running > 1 container in the guest. The
API mostly follows LinuxContainer, and each individual container can be
addressed via any of the methods that require you to pass the
containerID as the first param. Today there's no support for namespace
sharing, but that shouldn't be terrible to support.
2025-10-23 13:59:58 -07:00
Dmitry Kovba 3d7bb7bb5c Fix log metadata when starting a process (#345) 2025-10-23 13:28:21 -07:00