Skip to content

Commit a829fdc

Browse files
authored
Improve log and error messages (#352)
Improved log and error messages.
1 parent 3897e57 commit a829fdc

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

vminitd/Sources/vmexec/vmexec.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ extension App {
8080
// lookup executable
8181
let path = Path.findPath(currentEnv) ?? Path.getCurrentPath()
8282
guard let resolvedExecutable = Path.lookPath(process.args[0], path: path) else {
83-
throw App.Failure(message: "Failed to find target executable \(process.args[0])")
83+
throw App.Failure(message: "failed to find target executable \(process.args[0])")
8484
}
8585

8686
let executable = strdup(resolvedExecutable.path())

vminitd/Sources/vminitd/Application.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ struct Application {
107107

108108
log.logLevel = .debug
109109

110-
log.info("vminitd booting...")
110+
log.info("vminitd booting")
111111
let eg = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
112112
let server = Initd(log: log, group: eg)
113113

114114
do {
115-
log.info("serve vminitd api")
115+
log.info("serving vminitd API")
116116
try await server.serve(port: vsockPort)
117-
log.info("vminitd api returned...")
117+
log.info("vminitd API returned")
118118
} catch {
119119
log.error("vminitd boot error \(error)")
120120
exit(1)

vminitd/Sources/vminitd/ManagedProcess.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ final class ManagedProcess: Sendable {
119119

120120
var io: IO
121121
if stdio.terminal {
122-
log.info("setting up terminal IO")
122+
log.info("setting up terminal I/O")
123123
let attrs = Command.Attrs(setsid: false, setctty: false)
124124
command.attrs = attrs
125125
io = try TerminalIO(
@@ -134,7 +134,7 @@ final class ManagedProcess: Sendable {
134134
)
135135
}
136136

137-
log.info("starting io")
137+
log.info("starting I/O")
138138

139139
// Setup IO early. We expect the host to be listening already.
140140
try io.start(process: &command)
@@ -172,7 +172,7 @@ extension ManagedProcess {
172172

173173
let size = MemoryLayout<Int32>.size
174174
guard let piddata = try syncPipe.fileHandleForReading.read(upToCount: size) else {
175-
throw ContainerizationError(.internalError, message: "no pid data from sync pipe")
175+
throw ContainerizationError(.internalError, message: "no PID data from sync pipe")
176176
}
177177

178178
guard piddata.count == size else {
@@ -206,7 +206,7 @@ extension ManagedProcess {
206206

207207
if self.terminal {
208208
log.info(
209-
"wait for pty fd",
209+
"wait for PTY FD",
210210
metadata: [
211211
"id": "\(id)"
212212
])
@@ -215,14 +215,14 @@ extension ManagedProcess {
215215
guard let ptyFd = try self.syncPipe.fileHandleForReading.read(upToCount: size) else {
216216
throw ContainerizationError(
217217
.internalError,
218-
message: "no pty data from sync pipe"
218+
message: "no PTY data from sync pipe"
219219
)
220220
}
221221
let fd = ptyFd.withUnsafeBytes { ptr in
222222
ptr.load(as: Int32.self)
223223
}
224224
log.info(
225-
"received pty fd from container, attaching",
225+
"received PTY FD from container, attaching",
226226
metadata: [
227227
"id": "\(id)"
228228
])
@@ -259,7 +259,7 @@ extension ManagedProcess {
259259
do {
260260
try $0.io.close()
261261
} catch {
262-
self.log.error("failed to close io for process: \(error)")
262+
self.log.error("failed to close I/O for process: \(error)")
263263
}
264264

265265
for waiter in $0.waiters {

vminitd/Sources/vminitd/Server+GRPC.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContextAsyncProvid
429429
"stdin": "Port: \(request.stdin)",
430430
"stdout": "Port: \(request.stdout)",
431431
"stderr": "Port: \(request.stderr)",
432+
"configuration": "\(request.configuration.count)",
432433
])
433434

434435
if !request.hasContainerID {
@@ -508,7 +509,7 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContextAsyncProvid
508509
if error is GRPCStatus {
509510
throw error
510511
}
511-
throw GRPCStatus(code: .internalError, message: "create managed process: \(error)")
512+
throw GRPCStatus(code: .internalError, message: "createProcess: \(error)")
512513
}
513514
}
514515

vminitd/Sources/vminitd/Server.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ final class Initd: Sendable {
9393
await ProcessSupervisor.default.setLog(self.log)
9494
await ProcessSupervisor.default.ready()
9595

96-
log.debug(
97-
"booting grpc server on vsock",
96+
log.info(
97+
"booting gRPC server on vsock",
9898
metadata: [
9999
"port": "\(port)"
100100
])
@@ -105,7 +105,7 @@ final class Initd: Sendable {
105105
serviceProviders: [self])
106106
).get()
107107
log.info(
108-
"grpc api serving on vsock",
108+
"gRPC API serving on vsock",
109109
metadata: [
110110
"port": "\(port)"
111111
])
@@ -114,6 +114,7 @@ final class Initd: Sendable {
114114
try await server.onClose.get()
115115
}
116116
try await group.next()
117+
log.info("closing gRPC server")
117118
group.cancelAll()
118119
}
119120
}

0 commit comments

Comments
 (0)