Skip to content

Use FilePath for PublishSocket#27

Closed
chrisgeo wants to merge 16 commits into
mainfrom
feat/chaos-1459-publish-socket-filepath
Closed

Use FilePath for PublishSocket#27
chrisgeo wants to merge 16 commits into
mainfrom
feat/chaos-1459-publish-socket-filepath

Conversation

@chrisgeo

@chrisgeo chrisgeo commented May 9, 2026

Copy link
Copy Markdown

Summary

  • Converts PublishSocket from URL to SystemPackage.FilePath for containerPath and hostPath (4 references in the type itself).
  • Public API: init(containerPath: URL, hostPath: URL, …)init(containerPath: FilePath, hostPath: FilePath, …). Stored properties typed accordingly. permissions: FilePermissions? unchanged.
  • Single construction site updated in Sources/Services/ContainerAPIService/Client/Parser.swift: URL(fileURLWithPath: …)FilePath(…) for both arguments. Mounts/volumes parsing in the same file is intentionally untouched — that is CHAOS-1463 territory.
  • One additional caller compile-fix in Sources/Services/ContainerSandboxService/Server/SandboxService.swift: the Containerization.UnixSocketConfiguration initializer takes URL, so we convert at the boundary with URL(filePath: publishedSocket.containerPath.string) (and same for hostPath) and add a comment justifying the leak.

Closes CHAOS-1459. Sibling of #26 (Bundle), part of CHAOS-1448 epic. Unblocks CHAOS-1463.

Codable wire format — preserved

PublishSocket is Codable and embedded inside ContainerConfiguration (also Codable), which is persisted to disk in container bundles (Sources/ContainerResource/Container/Bundle.swift writes config.json via JSONEncoder) and sent over XPC (Sources/Services/ContainerAPIService/Server/Containers/ContainersHarness.swift:195 decodes it). Naively switching the field types would change the JSON wire format two ways:

  1. JSONEncoder special-cases URL to encode as absoluteString"file:///var/run/docker.sock".
  2. FilePath's synthesized Codable conformance uses a keyed container → {"_storage":"…"}.

Either change would break decoding of existing on-disk container configs. To avoid that, this PR adds an explicit Codable implementation on PublishSocket:

  • Encode: emits the path as a plain JSON string (containerPath.string, hostPath.string). New writes are clean: "hostPath":"/var/run/docker.sock".
  • Decode: accepts both forms — new (plain path) and legacy (URL.absoluteString like "file:///var/run/docker.sock", detected by file:// prefix and parsed as a URL to recover the path).

Net result: existing container bundles persisted before this migration still decode; new bundles produce a cleaner string-only wire format.

Test plan

  • swift build — full project, 3107/3107 artifacts, no warnings.
  • swift test --filter ContainerAPIClient — 182 tests pass (covers Parser test suite).
  • swift test --filter ContainerResource — 36 tests pass (covers PublishPort/sockets-adjacent types).
  • lsp_diagnostics clean on all three changed files.
  • Manual: launch a container with --publish-socket and confirm config.json round-trips on disk.
  • Manual: load a container bundle persisted on a pre-migration build (legacy "file:///…" strings) and confirm it still decodes.

Files changed

  • Sources/ContainerResource/Container/PublishSocket.swift — types + explicit Codable.
  • Sources/Services/ContainerAPIService/Client/Parser.swiftSystemPackage import + the two PublishSocket constructor arguments. No other changes (volumes/mounts parsing is left for CHAOS-1463).
  • Sources/Services/ContainerSandboxService/Server/SandboxService.swift — boundary conversion to URL for UnixSocketConfiguration (Containerization SDK still takes URL).

@linear

linear Bot commented May 9, 2026

Copy link
Copy Markdown

CHAOS-1459

CHAOS-1448

@chrisgeo chrisgeo force-pushed the feat/chaos-1459-publish-socket-filepath branch 2 times, most recently from f8ec45a to b7299a8 Compare May 23, 2026 19:52
dkovba and others added 5 commits May 26, 2026 12:56
- Closes apple#1557.
- Replaces `executableURL` utility function for getting app executable
path with `executablePath`.
- Adds `FilePath.resolvingSymlinks()` extension.
- Also converts for FilePath for types in `ContainerVersion` target.
…ple#1600)

## Type of Change
- [x] Bug fix

## Motivation and Context
Many CLI commands need to reference the system configurations for
`container`. Previously, CLI commands would try to load the system
configurations from the default application root location, regardless of
if `container` had been started with a custom application root location.
This PR fixes that issue by having each CLI command ping the APIServer's
health check service to get the correct app root path.

Closes apple#1576

## Testing
- [x] Tested locally

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
## Type of Change
- [x] Bug fix

## Motivation and Context
Ensure all fields are initialized in the management flags' init
function. Without this change, if someone calls init() on this set of
flags, they will get an error like

```
Can't read a value from a parsable argument definition.

This error indicates that a property declared with an `@Argument`,
`@Option`, `@Flag`, or `@OptionGroup` property wrapper was neither
initialized to a value nor decoded from command-line arguments.

To get a valid value, either call one of the static parsing methods
(`parse`, `parseAsRoot`, or `main`) or define an initializer that
initializes _every_ property of your parsable type.
```

## Testing
- [x] Tested locally

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
- Fixes apple#1509. The CLI's own help text tells users to
  run `container help <subcommand>`, but every form
  of that results in an error.
- Added a captured subcommand path, walked 
  Application`'s `subcommands` + `groupedSubcommands`
  tree (matching `commandName` and `aliases`), and
  printed `Application.helpMessage(for:)` for the resolved
  target. Empty path keeps existing plugin-aware top-level
  help; unknown path throws `ValidationError`.
@chrisgeo chrisgeo force-pushed the feat/chaos-1459-publish-socket-filepath branch from b7299a8 to 1e7f495 Compare May 27, 2026 18:55
katiewasnothere and others added 7 commits May 27, 2026 17:36
…#1608)

## Type of Change
- [x] New feature  

## Motivation and Context
When developing, there are times when I want to run a specific set of
CLI tests. This PR allows users to set what integration tests they want
to run by setting the makefile variable `INTEGRATION_TEST_SUITES`.

Example usage: 
```
% INTEGRATION_TEST_SUITES="TestCLIVolumes TestCLIAnonymousVolumes"  make all integration
```

## Testing
- [x] Tested locally

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
- Part of apple#1404.
- Use `configuration` for configuration properties, `state` for current
state label, `status` for status properties.
## Type of Change
- [x] New feature  

## Motivation and Context
Related to apple#1404.

This PR adds the initial work to have volume resources conform to
ManagedResource, in alignment with other resources such as networks (see
[here](apple#1421)). Further work is
necessary to move the use of `VolumeResource` down to the APIServer (in
the VolumesService) and in the volume client. Volumes do not currently
have any plugin or runtime state, so that information is not included in
the `VolumeResource`, but could be added later if needed.

## Testing
- [x] Tested locally

Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
- Closes apple#1610.
- Discovered, and originally filed as a security advisory, by:
PresidentL <131139636+liyander@users.noreply.github.com>.
- `PublishPort` currently can store invalid combinations of starting
port and range that can overflow UInt16 values when summed, crashing the
process.
- Updates `PublishPort` to validate inputs on initialization.
Closes CHAOS-1459. Unblocks CHAOS-1463 (Parser).
- PublishSocket.init now throws and validates absolute paths so objects
  are correct by construction; adds DocC for parameters and constraints
  (addresses comment on PublishSocket.swift:33 and :72).
- Adds deprecation/migration note on the struct documenting that the
  decoder accepts both new `FilePath` and legacy `URL` forms for one
  release (addresses comment on PublishSocket.swift:21).
- Wire format pre-1.0 breaking change: encoder now emits the plain
  absolute path (e.g. "/var/run/docker.sock") instead of the legacy
  file-URL form ("file:///var/run/docker.sock"). The decoder still
  accepts both forms so persisted bundles from earlier releases
  continue to load; that compatibility will be removed in a later
  release (addresses comment on PublishSocket.swift:58).
- Bumps containerization to 0.33.2 and replaces
  URL(fileURLWithPath:).absoluteURL.path with
  ContainerizationOS.FilePathOps.absolutePath in Parser.publishSocket,
  removing the duplicate "must be absolute" check now that init()
  enforces it (addresses comments on Parser.swift:754 and :762).
Enforce absoluteness directly in the decode helper (in addition to the
by-construction check in init) so decoded PublishSocket paths are
lexically correct even when read from manually edited or corrupt
persisted configs. Non-absolute decoded paths now throw
DecodingError.dataCorrupted at the decode layer.

Adds testDecodeRelativeHostPathThrows covering a relative hostPath on
decode and clarifies the existing relative-containerPath test.

Addresses PR apple#1594 review comments on PublishSocket.swift:90 and
PublishSocketTests.swift:99.
@chrisgeo chrisgeo force-pushed the feat/chaos-1459-publish-socket-filepath branch from 01ec891 to 605408b Compare May 28, 2026 21:37
jglogan and others added 4 commits May 28, 2026 15:26
- Part of apple#1404.
- Updates containerization to 0.33.2.
- Reorganizes network plugin targets into:
  - `ContainerNetworkClient` - network plugin client and default types
- `ContainerNetworkServer` - separate protocols for `Network` which
manages the underlying virtual network, `NetworkService`, which takes a
network and implements the API, and an actor `NetworkHarness` that
marshals between the API and the XPC protocol. The service-harness
separation will help us ensure XPC protocol compatibility in both
directions as we evolve the plugin APIs.
- Removes `disableAllocator()` which is no longer used since apple#1545
switched over to using XPC connections between runtime and network
plugin instances to track whether a network has attached containers.
- Refactor network model types: replace `NetworkState` enum and
phase-based NetworkStatus with a flat `NetworkStatus` struct.
- Simplify API server ↔ plugin protocol: plugin `status()` returns
runtime status only, API server owns configuration.
- `NetworksService` `list()`/`create()` now return `NetworkResource`
directly.
- Remove lifecycle phase checks and state machine guards throughout CLI
and API server.
- `variant` is plugin-specific, it's not a required property. This PR
replaces `NetworkPluginInfo` with a `plugin` name property on
`NetworkConfiguration` and an `options` list similar to that for
volumes.
- Moved `variant` to the option list.
@chrisgeo chrisgeo closed this Jun 2, 2026
@chrisgeo chrisgeo deleted the feat/chaos-1459-publish-socket-filepath branch June 2, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants