Skip to content

Commit fc5399e

Browse files
authored
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.
1 parent ec2ee3e commit fc5399e

File tree

3 files changed

+7
-26
lines changed

3 files changed

+7
-26
lines changed

vminitd/Sources/vmexec/ExecCommand.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,13 @@ struct ExecCommand: ParsableCommand {
3636

3737
func run() throws {
3838
do {
39-
LoggingSystem.bootstrap(App.standardError)
40-
let log = Logger(label: "vmexec")
41-
4239
let src = URL(fileURLWithPath: processPath)
4340
let processBytes = try Data(contentsOf: src)
4441
let process = try JSONDecoder().decode(
4542
ContainerizationOCI.Process.self,
4643
from: processBytes
4744
)
48-
try execInNamespaces(process: process, log: log)
45+
try execInNamespaces(process: process)
4946
} catch {
5047
App.writeError(error)
5148
throw error
@@ -58,10 +55,7 @@ struct ExecCommand: ParsableCommand {
5855
}
5956
}
6057

61-
private func execInNamespaces(
62-
process: ContainerizationOCI.Process,
63-
log: Logger
64-
) throws {
58+
private func execInNamespaces(process: ContainerizationOCI.Process) throws {
6559
let syncPipe = FileHandle(fileDescriptor: 3)
6660
let ackPipe = FileHandle(fileDescriptor: 4)
6761

vminitd/Sources/vmexec/RunCommand.swift

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,21 @@ struct RunCommand: ParsableCommand {
3434

3535
mutating func run() throws {
3636
do {
37-
LoggingSystem.bootstrap(App.standardError)
38-
let log = Logger(label: "vmexec")
39-
4037
let spec: ContainerizationOCI.Spec
4138
do {
4239
let bundle = try ContainerizationOCI.Bundle.load(path: URL(filePath: bundlePath))
4340
spec = try bundle.loadConfig()
4441
} catch {
4542
throw App.Failure(message: "failed to load OCI bundle at \(bundlePath): \(error)")
4643
}
47-
try execInNamespace(spec: spec, log: log)
44+
try execInNamespace(spec: spec)
4845
} catch {
4946
App.writeError(error)
5047
throw error
5148
}
5249
}
5350

54-
private func childRootSetup(rootfs: ContainerizationOCI.Root, mounts: [ContainerizationOCI.Mount], log: Logger) throws {
51+
private func childRootSetup(rootfs: ContainerizationOCI.Root, mounts: [ContainerizationOCI.Mount]) throws {
5552
// setup rootfs
5653
try prepareRoot(rootfs: rootfs.path)
5754
try mountRootfs(rootfs: rootfs.path, mounts: mounts)
@@ -90,7 +87,6 @@ struct RunCommand: ParsableCommand {
9087
spec: ContainerizationOCI.Spec,
9188
ackPipe: FileHandle,
9289
syncPipe: FileHandle,
93-
log: Logger
9490
) throws {
9591
guard let process = spec.process else {
9692
throw App.Failure(message: "no process configuration found in runtime spec")
@@ -119,7 +115,7 @@ struct RunCommand: ParsableCommand {
119115
throw App.Errno(stage: "setsid()")
120116
}
121117

122-
try childRootSetup(rootfs: root, mounts: spec.mounts, log: log)
118+
try childRootSetup(rootfs: root, mounts: spec.mounts)
123119

124120
if process.terminal {
125121
let pty = try Console()
@@ -223,7 +219,7 @@ struct RunCommand: ParsableCommand {
223219
return unshareFlags
224220
}
225221

226-
private func execInNamespace(spec: ContainerizationOCI.Spec, log: Logger) throws {
222+
private func execInNamespace(spec: ContainerizationOCI.Spec) throws {
227223
let syncPipe = FileHandle(fileDescriptor: 3)
228224
let ackPipe = FileHandle(fileDescriptor: 4)
229225

@@ -241,7 +237,7 @@ struct RunCommand: ParsableCommand {
241237
}
242238

243239
if processID == 0 { // child
244-
try childSetup(spec: spec, ackPipe: ackPipe, syncPipe: syncPipe, log: log)
240+
try childSetup(spec: spec, ackPipe: ackPipe, syncPipe: syncPipe)
245241
} else { // parent process
246242
// Setup cgroup before child enters cgroup namespace
247243
if let linux = spec.linux {

vminitd/Sources/vmexec/vmexec.swift

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,6 @@ struct App: ParsableCommand {
4141
RunCommand.self,
4242
]
4343
)
44-
45-
static let standardErrorLock = NSLock()
46-
47-
@Sendable
48-
static func standardError(label: String) -> StreamLogHandler {
49-
standardErrorLock.withLock {
50-
StreamLogHandler.standardError(label: label)
51-
}
52-
}
5344
}
5445

5546
extension App {

0 commit comments

Comments
 (0)