Skip to content

Build the network interface-strategy table from plugin manifests - #2280

Open
MayCXC wants to merge 3 commits into
apple:mainfrom
MayCXC:interface-strategy
Open

MayCXC wants to merge 3 commits into
apple:mainfrom
MayCXC:interface-strategy

Conversation

@MayCXC

@MayCXC MayCXC commented Sep 16, 2026 •

Copy link
Copy Markdown

Type of Change

  • New feature

Motivation and Context

Fixes #2279.

RuntimeLinuxHelper+Start hardcoded the NetworkInterfaceKey -> InterfaceStrategy table for container-network-vmnet and gated the macOS 26 variant with #available, with a FIXME that supported plugins should be configurable elsewhere.

A network plugin now declares the strategy for each interface variant in its config.toml (PluginConfig.Service.interfaces), decoded into PluginConfig.InterfaceStrategyType, so a misspelled strategy fails the manifest's load and the plugin is not installed. RuntimeService.interfaceStrategies(plugins:log:) in ContainerRuntimeLinuxServer builds the table from the plugins PluginLoader.findPlugins() returns, beside the strategies it constructs. The #available guard stays where the macOS 26 type is instantiated, and the plugins and variants come from the manifests installed.

Testing

  • Tested locally
  • Added/updated tests
  • Added/updated docs

PluginConfigTest decodes a manifest declaring interfaces into the enum, a manifest naming an unknown strategy throws a DecodingError, and a manifest declaring none decodes to nil. The new ContainerRuntimeLinuxServerTests target checks the table: each declared variant maps to its strategy (the nonisolated one on macOS 26), and only network services contribute. make test passes on macOS 26.5.1, and make swift-fmt-check is clean.

The runtime named the network plugin and its variants itself, so adding either meant editing the runtime. A network plugin now declares in its config.toml the strategy each interface variant needs, and the runtime builds its table from the network plugins present, so the supported set is the one installed.

The macOS 26 strategy type is still instantiated behind an availability guard, since the type requires it, but a plugin offers that variant only where it is available, so the runtime no longer repeats the list of which variants exist.

The plugin tests build each service with the new field, and a manifest that declares interfaces decodes to the table while one that declares none decodes to nil.
@MayCXC
MayCXC force-pushed the interface-strategy branch from 40c70d3 to 4d0b15a Compare October 1, 2026 04:48

@resker resker left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tested at 4d0b15a on macOS 27 (Apple silicon): make all and make test pass. A container on the default network and one on a new container network create network both got addresses and reached the internet, so both variants still resolve to the right strategy.

One suggestion: strategy names are only checked at runtime. A typo in a manifest is logged and skipped, and the real failure shows up later when a container can't attach. Decoding interfaces into an enum in PluginConfig would reject it when the manifest loads. It would also let the table builder move out of the executable into a library and get a unit test, like #2477 did for HostStoreServer. Right now the test covers decoding but not the table.

…n ContainerRuntimeLinuxServer

A misspelled strategy name in a network plugin's manifest was logged and skipped,
and failed later when a container attached. Decoding into
PluginConfig.InterfaceStrategyType rejects the manifest when the plugin loads.

The table builder moves beside the strategies it constructs, into
ContainerRuntimeLinuxServer, with a unit test of the table, as apple#2477 moved
HostStoreServer out of its executable.
@MayCXC

MayCXC commented Nov 17, 2026

Copy link
Copy Markdown
Author

Both are in 2bf641a:

  • interfaces decodes into PluginConfig.InterfaceStrategyType, so a misspelled strategy fails the manifest's load, and PluginLoader.findPlugins() skips the plugin with "not installing plugin with invalid configuration" and the decoding error.
  • The table builder is RuntimeService.interfaceStrategies(plugins:log:) in ContainerRuntimeLinuxServer, beside the strategies it constructs, and a new ContainerRuntimeLinuxServerTests target tests the table: each declared variant maps to its strategy, and only network services contribute. The executable keeps only the plugin loading.

make test passes on macOS 26.5.1 (793 tests in 88 suites), and make swift-fmt-check is clean.

…ializer

RuntimeService takes the plugin loader and derives its table from the network
plugins itself, as ContainersService and NetworksService take the loader and
filter its plugins in their initializers. The runtime helper only creates the
loader, the way the API server's initializePluginLoader does.
@MayCXC

MayCXC commented Nov 17, 2026

Copy link
Copy Markdown
Author

One more change: RuntimeService now takes the plugin loader and builds its interface-strategy table in its initializer, as ContainersService and NetworksService take the loader and filter its plugins in theirs. The runtime helper only creates the loader, the way the API server's initializePluginLoader does. make test and make swift-fmt-check pass.

@MayCXC
MayCXC requested a review from resker November 17, 2026 19:46

@resker resker left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for picking up both suggestions. Re-tested at 9029f72 on macOS 27: build, tests and format check pass, and containers on the default and a new network both get addresses and reach the internet. I also plugged a deliberate misspelling into the vmnet manifest's strategy, and it now fails at load, with the path in the error.

Two minor things to consider (neither blocking):

  • On macOS 15, vmnet's manifest still declares reserved = "nonisolated", so every container start will log the unavailable-strategy error. Debug level seems right, since that's expected there. (From reading, not tested on 15.)
  • The runtime helper's initializePluginLoader duplicates the API server's. Could be a shared PluginLoader helper later.

This branch has not been deployed

No deployments
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.

[Request]: Build the network interface-strategy table from plugin manifests

2 participants