vmexec: Remove the logger setup (#469)

We can't write to stderr because it may be the containers stderr, so
this is mostly dead code. We should think about how to do logging from
here as there's a couple spots it'd be nice.
This commit is contained in:
Danny Canter
2026-01-05 13:48:43 -08:00
committed by GitHub
parent ec2ee3e94d
commit fc5399e77e
3 changed files with 7 additions and 26 deletions
+2 -8
View File
@@ -36,16 +36,13 @@ struct ExecCommand: ParsableCommand {
func run() throws {
do {
LoggingSystem.bootstrap(App.standardError)
let log = Logger(label: "vmexec")
let src = URL(fileURLWithPath: processPath)
let processBytes = try Data(contentsOf: src)
let process = try JSONDecoder().decode(
ContainerizationOCI.Process.self,
from: processBytes
)
try execInNamespaces(process: process, log: log)
try execInNamespaces(process: process)
} catch {
App.writeError(error)
throw error
@@ -58,10 +55,7 @@ struct ExecCommand: ParsableCommand {
}
}
private func execInNamespaces(
process: ContainerizationOCI.Process,
log: Logger
) throws {
private func execInNamespaces(process: ContainerizationOCI.Process) throws {
let syncPipe = FileHandle(fileDescriptor: 3)
let ackPipe = FileHandle(fileDescriptor: 4)
+5 -9
View File
@@ -34,9 +34,6 @@ struct RunCommand: ParsableCommand {
mutating func run() throws {
do {
LoggingSystem.bootstrap(App.standardError)
let log = Logger(label: "vmexec")
let spec: ContainerizationOCI.Spec
do {
let bundle = try ContainerizationOCI.Bundle.load(path: URL(filePath: bundlePath))
@@ -44,14 +41,14 @@ struct RunCommand: ParsableCommand {
} catch {
throw App.Failure(message: "failed to load OCI bundle at \(bundlePath): \(error)")
}
try execInNamespace(spec: spec, log: log)
try execInNamespace(spec: spec)
} catch {
App.writeError(error)
throw error
}
}
private func childRootSetup(rootfs: ContainerizationOCI.Root, mounts: [ContainerizationOCI.Mount], log: Logger) throws {
private func childRootSetup(rootfs: ContainerizationOCI.Root, mounts: [ContainerizationOCI.Mount]) throws {
// setup rootfs
try prepareRoot(rootfs: rootfs.path)
try mountRootfs(rootfs: rootfs.path, mounts: mounts)
@@ -90,7 +87,6 @@ struct RunCommand: ParsableCommand {
spec: ContainerizationOCI.Spec,
ackPipe: FileHandle,
syncPipe: FileHandle,
log: Logger
) throws {
guard let process = spec.process else {
throw App.Failure(message: "no process configuration found in runtime spec")
@@ -119,7 +115,7 @@ struct RunCommand: ParsableCommand {
throw App.Errno(stage: "setsid()")
}
try childRootSetup(rootfs: root, mounts: spec.mounts, log: log)
try childRootSetup(rootfs: root, mounts: spec.mounts)
if process.terminal {
let pty = try Console()
@@ -223,7 +219,7 @@ struct RunCommand: ParsableCommand {
return unshareFlags
}
private func execInNamespace(spec: ContainerizationOCI.Spec, log: Logger) throws {
private func execInNamespace(spec: ContainerizationOCI.Spec) throws {
let syncPipe = FileHandle(fileDescriptor: 3)
let ackPipe = FileHandle(fileDescriptor: 4)
@@ -241,7 +237,7 @@ struct RunCommand: ParsableCommand {
}
if processID == 0 { // child
try childSetup(spec: spec, ackPipe: ackPipe, syncPipe: syncPipe, log: log)
try childSetup(spec: spec, ackPipe: ackPipe, syncPipe: syncPipe)
} else { // parent process
// Setup cgroup before child enters cgroup namespace
if let linux = spec.linux {
-9
View File
@@ -41,15 +41,6 @@ struct App: ParsableCommand {
RunCommand.self,
]
)
static let standardErrorLock = NSLock()
@Sendable
static func standardError(label: String) -> StreamLogHandler {
standardErrorLock.withLock {
StreamLogHandler.standardError(label: label)
}
}
}
extension App {