From fc5399e77e5735f59d9eb73b8332af7a3bf0836f Mon Sep 17 00:00:00 2001 From: Danny Canter Date: Mon, 5 Jan 2026 13:48:43 -0800 Subject: [PATCH] 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. --- vminitd/Sources/vmexec/ExecCommand.swift | 10 ++-------- vminitd/Sources/vmexec/RunCommand.swift | 14 +++++--------- vminitd/Sources/vmexec/vmexec.swift | 9 --------- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/vminitd/Sources/vmexec/ExecCommand.swift b/vminitd/Sources/vmexec/ExecCommand.swift index 13fe4715..701d82c6 100644 --- a/vminitd/Sources/vmexec/ExecCommand.swift +++ b/vminitd/Sources/vmexec/ExecCommand.swift @@ -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) diff --git a/vminitd/Sources/vmexec/RunCommand.swift b/vminitd/Sources/vmexec/RunCommand.swift index d6b1973b..ccd89fd2 100644 --- a/vminitd/Sources/vmexec/RunCommand.swift +++ b/vminitd/Sources/vmexec/RunCommand.swift @@ -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 { diff --git a/vminitd/Sources/vmexec/vmexec.swift b/vminitd/Sources/vmexec/vmexec.swift index 2d4b9339..3286d4e7 100644 --- a/vminitd/Sources/vmexec/vmexec.swift +++ b/vminitd/Sources/vmexec/vmexec.swift @@ -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 {