Improve log and error messages (#352)

Improved log and error messages.
This commit is contained in:
Dmitry Kovba
2025-10-27 09:21:54 -07:00
committed by GitHub
parent 3897e578c3
commit a829fdcdfd
5 changed files with 17 additions and 15 deletions
+1 -1
View File
@@ -80,7 +80,7 @@ extension App {
// lookup executable
let path = Path.findPath(currentEnv) ?? Path.getCurrentPath()
guard let resolvedExecutable = Path.lookPath(process.args[0], path: path) else {
throw App.Failure(message: "Failed to find target executable \(process.args[0])")
throw App.Failure(message: "failed to find target executable \(process.args[0])")
}
let executable = strdup(resolvedExecutable.path())
+3 -3
View File
@@ -107,14 +107,14 @@ struct Application {
log.logLevel = .debug
log.info("vminitd booting...")
log.info("vminitd booting")
let eg = MultiThreadedEventLoopGroup(numberOfThreads: System.coreCount)
let server = Initd(log: log, group: eg)
do {
log.info("serve vminitd api")
log.info("serving vminitd API")
try await server.serve(port: vsockPort)
log.info("vminitd api returned...")
log.info("vminitd API returned")
} catch {
log.error("vminitd boot error \(error)")
exit(1)
+7 -7
View File
@@ -119,7 +119,7 @@ final class ManagedProcess: Sendable {
var io: IO
if stdio.terminal {
log.info("setting up terminal IO")
log.info("setting up terminal I/O")
let attrs = Command.Attrs(setsid: false, setctty: false)
command.attrs = attrs
io = try TerminalIO(
@@ -134,7 +134,7 @@ final class ManagedProcess: Sendable {
)
}
log.info("starting io")
log.info("starting I/O")
// Setup IO early. We expect the host to be listening already.
try io.start(process: &command)
@@ -172,7 +172,7 @@ extension ManagedProcess {
let size = MemoryLayout<Int32>.size
guard let piddata = try syncPipe.fileHandleForReading.read(upToCount: size) else {
throw ContainerizationError(.internalError, message: "no pid data from sync pipe")
throw ContainerizationError(.internalError, message: "no PID data from sync pipe")
}
guard piddata.count == size else {
@@ -206,7 +206,7 @@ extension ManagedProcess {
if self.terminal {
log.info(
"wait for pty fd",
"wait for PTY FD",
metadata: [
"id": "\(id)"
])
@@ -215,14 +215,14 @@ extension ManagedProcess {
guard let ptyFd = try self.syncPipe.fileHandleForReading.read(upToCount: size) else {
throw ContainerizationError(
.internalError,
message: "no pty data from sync pipe"
message: "no PTY data from sync pipe"
)
}
let fd = ptyFd.withUnsafeBytes { ptr in
ptr.load(as: Int32.self)
}
log.info(
"received pty fd from container, attaching",
"received PTY FD from container, attaching",
metadata: [
"id": "\(id)"
])
@@ -259,7 +259,7 @@ extension ManagedProcess {
do {
try $0.io.close()
} catch {
self.log.error("failed to close io for process: \(error)")
self.log.error("failed to close I/O for process: \(error)")
}
for waiter in $0.waiters {
+2 -1
View File
@@ -429,6 +429,7 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContextAsyncProvid
"stdin": "Port: \(request.stdin)",
"stdout": "Port: \(request.stdout)",
"stderr": "Port: \(request.stderr)",
"configuration": "\(request.configuration.count)",
])
if !request.hasContainerID {
@@ -508,7 +509,7 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContextAsyncProvid
if error is GRPCStatus {
throw error
}
throw GRPCStatus(code: .internalError, message: "create managed process: \(error)")
throw GRPCStatus(code: .internalError, message: "createProcess: \(error)")
}
}
+4 -3
View File
@@ -93,8 +93,8 @@ final class Initd: Sendable {
await ProcessSupervisor.default.setLog(self.log)
await ProcessSupervisor.default.ready()
log.debug(
"booting grpc server on vsock",
log.info(
"booting gRPC server on vsock",
metadata: [
"port": "\(port)"
])
@@ -105,7 +105,7 @@ final class Initd: Sendable {
serviceProviders: [self])
).get()
log.info(
"grpc api serving on vsock",
"gRPC API serving on vsock",
metadata: [
"port": "\(port)"
])
@@ -114,6 +114,7 @@ final class Initd: Sendable {
try await server.onClose.get()
}
try await group.next()
log.info("closing gRPC server")
group.cancelAll()
}
}