Use SystemPath for HostDNSResolver. by jglogan · Pull Request #1480 · apple/container · GitHub
Skip to content

Use SystemPath for HostDNSResolver.#1480

Merged
jglogan merged 2 commits into
apple:mainfrom
jglogan:dns-pathtests
Apr 30, 2026
Merged

Use SystemPath for HostDNSResolver.#1480
jglogan merged 2 commits into
apple:mainfrom
jglogan:dns-pathtests

Conversation

@jglogan

@jglogan jglogan commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

Motivation and Context

See above

Testing

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

- Closes apple#1479.
- Using URL for filesystem paths is bad practice.
  FilePath is safer and more ergonomic.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit. we don't need attributes: nil?

@jglogan jglogan Apr 30, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

You're right, updated.

Comment thread Sources/Services/ContainerAPIService/Client/HostDNSResolver.swift Outdated
@jglogan jglogan merged commit 5ec28cf into apple:main Apr 30, 2026
3 checks passed
@jglogan jglogan deleted the dns-pathtests branch April 30, 2026 22:01
noah-thor pushed a commit to noah-thor/container that referenced this pull request May 6, 2026
- Closes apple#1479.
- Using URL for filesystem paths is bad practice. FilePath is safer and
more ergonomic.
chrisgeo added a commit to full-chaos/container that referenced this pull request May 7, 2026
Replaces URL-based filesystem operations with SystemPackage.FilePath,
mirroring the pattern landed in apple#1480 for HostDNSResolver:

- configURL/anchorsURL → configPath/anchorsPath: FilePath
- defaultConfigPath/defaultAnchorsPath now FilePath
- FileManager calls switch from atPath: url.path to atPath: path.string
- Tests use String(contentsOfFile:) in place of String(contentsOf: URL)

Process.executableURL stays URL since Foundation.Process requires it.
jglogan pushed a commit that referenced this pull request May 8, 2026
- Closes #1517.
- Using URL for filesystem paths is bad practice. FilePath is safer and
more ergonomic.
- Sibling of #1480 (HostDNSResolver), same pattern.
chrisgeo added a commit to full-chaos/container that referenced this pull request May 8, 2026
Replaces URL-based path normalization with SystemPackage.FilePath in
the three Filesystem factory methods (block, volume, virtiofs):

- source: URL(fileURLWithPath: source).absolutePath() → FilePath(source).string

All existing callers (Parser, Utility, SnapshotStore, RuntimeConfigurationTests)
already pass absolute paths; the URL round-trip was a no-op in practice.
FilePath preserves separator normalization equivalent to the URL form.

Following the migration pattern from apple#1480 (HostDNSResolver),
apple#1518 (PacketFilter), and discussion apple#1481.
chrisgeo added a commit to full-chaos/container that referenced this pull request May 8, 2026
Replaces URL-based filesystem path handling with SystemPackage.FilePath,
following the pattern from apple#1480 (HostDNSResolver) and apple#1518 (PacketFilter):

- directoryURL → directoryPath: FilePath (public API)
- startWatching handler signature changes from ([URL]) to ([FilePath])
- LocalhostDNSHandler caller updated; the URL(filePath: configPath.string)
  wrapping shim is no longer needed
- FilePath.lastComponent (returns Optional<Component>) handled in
  LocalhostDNSHandler's filename filter
jglogan pushed a commit that referenced this pull request May 11, 2026
- Closes #1520.
- Using URL for filesystem paths is bad practice. FilePath is safer and
more ergonomic.
- Same pattern as #1480 (HostDNSResolver) and #1518 (PacketFilter).
jglogan pushed a commit that referenced this pull request May 12, 2026
- Closes #1521.
- Using URL for filesystem paths is bad practice. FilePath is safer and
more ergonomic.
- Same pattern as #1480 (HostDNSResolver) and #1518 (PacketFilter).
chrisgeo added a commit to full-chaos/container that referenced this pull request May 13, 2026
Converts RuntimeConfiguration.path, runtimeConfigurationPath, and the
readRuntimeConfiguration(from:) parameter from URL to FilePath. Following
the migration pattern from apple#1480 (HostDNSResolver), apple#1518 (PacketFilter),
and discussion apple#1481.

The two server-side callers (ContainersService, SandboxService) get
minimal URL <-> FilePath bridge calls. Bundle.create still requires URL
(Foundation API) so the bridge stays at that boundary.

Bundle+Log.swift in the same module is intentionally NOT converted in
this PR: all three of its callers use Foundation FileHandle APIs that
require URL, and converting bundle.containerLog without simultaneously
updating those callers (in ContainersService and SandboxService) would
expand the PR scope significantly. Bundle+Log can be converted later as
part of a SandboxService/ContainersService cluster conversion.
chrisgeo added a commit to full-chaos/container that referenced this pull request May 13, 2026
Convert PluginConfig.init from URL to FilePath, following the migration
pattern from apple#1480 (HostDNSResolver), apple#1518 (PacketFilter), and
discussion apple#1481.

- PluginConfig.init?(configURL: URL) → init?(configPath: FilePath)
- DefaultPluginFactory.findConfigURL → findConfigPath (returns FilePath?)
- Both internal call sites (DefaultPluginFactory, AppBundlePluginFactory)
  updated; bridge from URL to FilePath stays at the directory boundary
  since broader PluginFactory conversion is tracked separately.
- Tests updated to derive FilePath from temp URL.
chrisgeo added a commit to full-chaos/container that referenced this pull request May 13, 2026
- Closes CHAOS-1454.
- Internal cluster; URL boundary preserved at `directorySize` for `URLResourceKey.totalFileAllocatedSizeKey`.
- Sibling of apple#1480 (HostDNSResolver) and apple#1518 (PacketFilter), same pattern.
chrisgeo added a commit to full-chaos/container that referenced this pull request May 13, 2026
Converts RuntimeConfiguration.path, runtimeConfigurationPath, and the
readRuntimeConfiguration(from:) parameter from URL to FilePath. Following
the migration pattern from apple#1480 (HostDNSResolver), apple#1518 (PacketFilter),
and discussion apple#1481.

The two server-side callers (ContainersService, SandboxService) get
minimal URL <-> FilePath bridge calls. Bundle.create still requires URL
(Foundation API) so the bridge stays at that boundary.

Bundle+Log.swift in the same module is intentionally NOT converted in
this PR: all three of its callers use Foundation FileHandle APIs that
require URL, and converting bundle.containerLog without simultaneously
updating those callers (in ContainersService and SandboxService) would
expand the PR scope significantly. Bundle+Log can be converted later as
part of a SandboxService/ContainersService cluster conversion.
chrisgeo added a commit to full-chaos/container that referenced this pull request May 13, 2026
Convert PluginConfig.init from URL to FilePath, following the migration
pattern from apple#1480 (HostDNSResolver), apple#1518 (PacketFilter), and
discussion apple#1481.

- PluginConfig.init?(configURL: URL) → init?(configPath: FilePath)
- DefaultPluginFactory.findConfigURL → findConfigPath (returns FilePath?)
- Both internal call sites (DefaultPluginFactory, AppBundlePluginFactory)
  updated; bridge from URL to FilePath stays at the directory boundary
  since broader PluginFactory conversion is tracked separately.
- Tests updated to derive FilePath from temp URL.
chrisgeo added a commit to full-chaos/container that referenced this pull request May 14, 2026
- Closes CHAOS-1454.
- Internal cluster; URL boundary preserved at `directorySize` for `URLResourceKey.totalFileAllocatedSizeKey`.
- Sibling of apple#1480 (HostDNSResolver) and apple#1518 (PacketFilter), same pattern.
chrisgeo added a commit to full-chaos/container that referenced this pull request May 24, 2026
Convert PluginConfig.init from URL to FilePath, following the migration
pattern from apple#1480 (HostDNSResolver), apple#1518 (PacketFilter), and
discussion apple#1481.

- PluginConfig.init?(configURL: URL) → init?(configPath: FilePath)
- DefaultPluginFactory.findConfigURL → findConfigPath (returns FilePath?)
- Both internal call sites (DefaultPluginFactory, AppBundlePluginFactory)
  updated; bridge from URL to FilePath stays at the directory boundary
  since broader PluginFactory conversion is tracked separately.
- Tests updated to derive FilePath from temp URL.
chrisgeo added a commit to full-chaos/container that referenced this pull request May 24, 2026
- Closes CHAOS-1454.
- Internal cluster; URL boundary preserved at `directorySize` for `URLResourceKey.totalFileAllocatedSizeKey`.
- Sibling of apple#1480 (HostDNSResolver) and apple#1518 (PacketFilter), same pattern.
chrisgeo added a commit to full-chaos/container that referenced this pull request May 24, 2026
- Closes CHAOS-1457.
- Adds shared FilePath.absolute(_:relativeTo:) helper.
- Sibling of apple#1480 (HostDNSResolver) and apple#1518 (PacketFilter), same pattern.
chrisgeo added a commit to full-chaos/container that referenced this pull request May 24, 2026
Converts RuntimeConfiguration.path, runtimeConfigurationPath, and the
readRuntimeConfiguration(from:) parameter from URL to FilePath. Following
the migration pattern from apple#1480 (HostDNSResolver), apple#1518 (PacketFilter),
and discussion apple#1481.

The two server-side callers (ContainersService, SandboxService) get
minimal URL <-> FilePath bridge calls. Bundle.create still requires URL
(Foundation API) so the bridge stays at that boundary.

Bundle+Log.swift in the same module is intentionally NOT converted in
this PR: all three of its callers use Foundation FileHandle APIs that
require URL, and converting bundle.containerLog without simultaneously
updating those callers (in ContainersService and SandboxService) would
expand the PR scope significantly. Bundle+Log can be converted later as
part of a SandboxService/ContainersService cluster conversion.
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]: TECH DEBT - Convert HostDNSResolver to use FilePath instead of URL.

2 participants