Skip to content

Add releaseNetwork method to ContainerManager#527

Merged
dcantah merged 2 commits intoapple:mainfrom
DePasqualeOrg:container-release
Feb 12, 2026
Merged

Add releaseNetwork method to ContainerManager#527
dcantah merged 2 commits intoapple:mainfrom
DePasqualeOrg:container-release

Conversation

@DePasqualeOrg
Copy link
Contributor

@DePasqualeOrg DePasqualeOrg commented Feb 10, 2026

I've extracted the network cleanup step from delete into a new public releaseNetwork method. This mirrors the existing release on VmnetNetwork and enables stop-and-restart workflows where the network allocation needs to be freed without removing the container's rootfs.

Changes

  • Add ContainerManager.release(_:) — frees network resources for a container after it has stopped
  • Refactor delete(_:) to call releaseNetwork(_:) before removing files, preserving existing behavior

Motivation

Currently the only way to free a container's network allocation is delete, which also removes its files. This makes it impossible to stop a container (freeing the network so the ID can be re-allocated) and later restart it with its filesystem intact. The new releaseNetwork method fills this gap.

Decompose delete() into release() + file removal. The new release()
method frees network resources for a container without deleting its
files, enabling stop-and-restart workflows that preserve the rootfs.
///
/// - Parameter id: The container ID.
public mutating func delete(_ id: String) throws {
public mutating func release(_ id: String) throws {
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer if this was releaseNetwork honestly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I've renamed it.

@DePasqualeOrg DePasqualeOrg changed the title Add release method to ContainerManager Add releaseNetwork method to ContainerManager Feb 11, 2026
@dcantah dcantah merged commit 9bce347 into apple:main Feb 12, 2026
2 checks passed
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.

2 participants