Skip to content

Commit ef5a821

Browse files
committed
fix pipeline issues
1 parent 951846c commit ef5a821

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

vminitd/Sources/VminitdCore/Server+GRPC.swift

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,9 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContext.SimpleServ
730730
}
731731

732732
let container = try await state.get(container: request.containerID)
733-
let containerPid = container.pid
733+
guard let containerPid = await container.pid else {
734+
throw RPCError(code: .failedPrecondition, message: "container is not running")
735+
}
734736

735737
log.debug(
736738
"filesystemOperation",
@@ -785,21 +787,24 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContext.SimpleServ
785787
} else {
786788
try await self.runOnDedicatedThread {
787789
if unshare(CLONE_FS) != 0 {
788-
let error = swiftErrno("unshare(CLONE_FS)")
790+
let error = self.swiftErrno("unshare(CLONE_FS)")
789791
throw RPCError(code: .internalError, message: "failed to unshare filesystem namespace", cause: error)
790792
}
791793
if setns(containerMountFd, CLONE_NEWNS) != 0 {
792-
let error = swiftErrno("setns(CLONE_NEWNS)")
794+
let error = self.swiftErrno("setns(CLONE_NEWNS)")
793795
throw RPCError(code: .internalError, message: "failed to enter container mount namespace", cause: error)
794796
}
795-
try doFilesystemOperation(path: path, operation: request.operation)
797+
try self.doFilesystemOperation(path: path, operation: request.operation)
796798
}
797799
}
798800

799801
return .init()
800802
}
801803

802-
private func doFilesystemOperation(path: FilePath, operation: Com_Apple_Containerization_Sandbox_V3_FilesystemOperationRequest.Operation) throws {
804+
private func doFilesystemOperation(
805+
path: FilePath,
806+
operation: Com_Apple_Containerization_Sandbox_V3_FilesystemOperationRequest.OneOf_Operation?
807+
) throws {
803808
var finfo = _stat_struct()
804809
let rc = _stat(path.string, &finfo)
805810
if rc != 0 {
@@ -820,18 +825,18 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContext.SimpleServ
820825

821826
do {
822827
switch operation {
823-
case .freeze:
828+
case .freeze(_):
824829
try freezeFilesystem(fd: fd)
825-
case .thaw:
830+
case .thaw(_):
826831
try thawFilesystem(fd: fd)
827832
case .trim(let params):
828833
switch params.schedule {
829-
case .oneShot:
834+
case .oneShot(_):
830835
try trimFilesystem(fd: fd)
831-
case .none:
836+
case nil:
832837
throw RPCError(code: .invalidArgument, message: "trim schedule must be specified")
833838
}
834-
case .none:
839+
case nil:
835840
throw RPCError(code: .invalidArgument, message: "invalid operation")
836841
}
837842
} catch {
@@ -842,8 +847,6 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContext.SimpleServ
842847
])
843848
throw RPCError(code: .internalError, message: "filesystemOperation", cause: error)
844849
}
845-
846-
return .init()
847850
}
848851

849852
private func freezeFilesystem(fd: Int32) throws {
@@ -1717,7 +1720,7 @@ extension Initd: Com_Apple_Containerization_Sandbox_V3_SandboxContext.SimpleServ
17171720
}
17181721

17191722
private func runOnDedicatedThread<T: Sendable>(
1720-
_ work: @escaping () throws -> T
1723+
_ work: @Sendable @escaping () throws -> T
17211724
) async throws -> T {
17221725
try await withCheckedThrowingContinuation { continuation in
17231726
let thread = Thread {

0 commit comments

Comments
 (0)