Skip to content

Commit 9aa5525

Browse files
authored
LinuxContainer: Try and stop vm on start failure (#281)
If start fails today the vm stays running.
1 parent 9319eec commit 9aa5525

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

Sources/Containerization/LinuxContainer.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -481,8 +481,9 @@ extension LinuxContainer {
481481
config.interfaces
482482
}
483483

484-
/// Create the underlying container's virtual machine
485-
/// and set up the runtime environment.
484+
/// Create and start the underlying container's virtual machine
485+
/// and set up the runtime environment. The container's init process
486+
/// is NOT running afterwards.
486487
public func create() async throws {
487488
try self.state.withLock { try $0.setCreating() }
488489

@@ -538,7 +539,7 @@ extension LinuxContainer {
538539
}
539540
}
540541

541-
/// Start the container container's initial process.
542+
/// Start the container's initial process.
542543
public func start() async throws {
543544
let vm = try self.state.withLock { try $0.setStarting() }
544545

@@ -569,6 +570,7 @@ extension LinuxContainer {
569570
try self.state.withLock { try $0.setStarted(process: process) }
570571
} catch {
571572
try? await agent.close()
573+
try? await vm.stop()
572574
self.state.withLock { $0.errored(error: error) }
573575
throw error
574576
}

0 commit comments

Comments
 (0)