Skip to content

Commit 7159ed3

Browse files
committed
LinuxProcess: Swap from logging in delete
This changes LinuxProcess to not just log errors but return them.
1 parent 3de2933 commit 7159ed3

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

Sources/Containerization/LinuxContainer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ extension LinuxContainer {
566566
}
567567

568568
// Lets free up the init procs resources, as this includes the open agent conn.
569-
try? await startedState.process.delete()
569+
try await startedState.process.delete()
570570

571571
try await startedState.vm.stop()
572572
state = .stopped

Sources/Containerization/LinuxProcess.swift

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -399,12 +399,16 @@ extension LinuxProcess {
399399
containerID: self.owningContainer
400400
)
401401
} catch {
402-
self.logger?.error(
403-
"process deletion",
404-
metadata: [
405-
"id": "\(self.id)",
406-
"error": "\(error)",
407-
])
402+
self.state.withLock {
403+
$0.stdinRelay?.cancel()
404+
try? $0.stdio.close()
405+
}
406+
try? await self.agent.close()
407+
throw ContainerizationError(
408+
.internalError,
409+
message: "failed to delete process",
410+
cause: error,
411+
)
408412
}
409413

410414
do {
@@ -413,12 +417,12 @@ extension LinuxProcess {
413417
try $0.stdio.close()
414418
}
415419
} catch {
416-
self.logger?.error(
417-
"closing process stdio",
418-
metadata: [
419-
"id": "\(self.id)",
420-
"error": "\(error)",
421-
])
420+
try? await self.agent.close()
421+
throw ContainerizationError(
422+
.internalError,
423+
message: "failed to close stdio",
424+
cause: error,
425+
)
422426
}
423427

424428
do {

0 commit comments

Comments
 (0)