Skip to content

Commit 9f9a7c9

Browse files
authored
Revert "Minimal runtime variant plumbing. (#1239)" (#1255)
- This reverts commit 1942a39. - This approach to getting variant into the runtime helper was fine for proof of concept work but we need a persistent runtime config file so that the variant is available for `container start`.
1 parent 1942a39 commit 9f9a7c9

File tree

6 files changed

+10
-103
lines changed

6 files changed

+10
-103
lines changed

Sources/Services/ContainerAPIService/Client/ContainerClient.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public struct ContainerClient: Sendable {
113113
}
114114

115115
/// Bootstrap the container's init process.
116-
public func bootstrap(id: String, stdio: [FileHandle?], variant: String? = nil) async throws -> ClientProcess {
116+
public func bootstrap(id: String, stdio: [FileHandle?]) async throws -> ClientProcess {
117117
let request = XPCMessage(route: .containerBootstrap)
118118

119119
for (i, h) in stdio.enumerated() {
@@ -132,10 +132,6 @@ public struct ContainerClient: Sendable {
132132
}
133133
}
134134

135-
if let variant {
136-
request.set(key: .variant, value: variant)
137-
}
138-
139135
do {
140136
request.set(key: .id, value: id)
141137
try await xpcClient.send(request)

Sources/Services/ContainerAPIService/Client/Flags.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,9 +293,6 @@ public struct Flags {
293293
)
294294
public var publishSockets: [String] = []
295295

296-
@Flag(name: .long, help: "Mount the container's root filesystem as read-only")
297-
public var readOnly = false
298-
299296
@Flag(name: [.customLong("rm"), .long], help: "Remove the container after it stops")
300297
public var remove = false
301298

@@ -308,15 +305,18 @@ public struct Flags {
308305
@Option(name: .customLong("tmpfs"), help: "Add a tmpfs mount to the container at the given path")
309306
public var tmpFs: [String] = []
310307

308+
@Option(name: [.customLong("volume"), .short], help: "Bind mount a volume into the container")
309+
public var volumes: [String] = []
310+
311311
@Flag(
312312
name: .long,
313313
help:
314314
"Expose virtualization capabilities to the container (requires host and guest support)"
315315
)
316316
public var virtualization: Bool = false
317317

318-
@Option(name: [.customLong("volume"), .short], help: "Bind mount a volume into the container")
319-
public var volumes: [String] = []
318+
@Flag(name: .long, help: "Mount the container's root filesystem as read-only")
319+
public var readOnly = false
320320

321321
@Option(name: .long, help: "Set the runtime handler for the container (default: container-runtime-linux)")
322322
public var runtime: String?

Sources/Services/ContainerAPIService/Client/XPC+.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ public enum XPCKeys: String {
3232
case containerConfig
3333
/// Container options key.
3434
case containerOptions
35-
/// Plugin variant key.
36-
case variant
3735
/// Vsock port number key.
3836
case port
3937
/// Exit code for a process

Sources/Services/ContainerAPIService/Server/Containers/ContainersHarness.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public struct ContainersHarness: Sendable {
5555
)
5656
}
5757
let stdio = message.stdio()
58-
let variant = message.variant()
59-
try await service.bootstrap(id: id, stdio: stdio, variant: variant)
58+
try await service.bootstrap(id: id, stdio: stdio)
6059
return message.reply()
6160
}
6261

Sources/Services/ContainerAPIService/Server/Containers/ContainersService.swift

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public actor ContainersService {
378378
}
379379

380380
/// Bootstrap the init process of the container.
381-
public func bootstrap(id: String, stdio: [FileHandle?], variant: String? = nil) async throws {
381+
public func bootstrap(id: String, stdio: [FileHandle?]) async throws {
382382
log.debug(
383383
"ContainersService: enter",
384384
metadata: [
@@ -424,8 +424,8 @@ public actor ContainersService {
424424
}
425425

426426
try Self.registerService(
427-
loader: self.pluginLoader,
428427
plugin: self.runtimePlugins.first { $0.name == config.runtimeHandler }!,
428+
loader: self.pluginLoader,
429429
configuration: config,
430430
path: path,
431431
debug: self.debugHelpers
@@ -1078,17 +1078,14 @@ public actor ContainersService {
10781078
}
10791079

10801080
private static func registerService(
1081-
loader: PluginLoader,
10821081
plugin: Plugin,
1083-
variant: String? = nil,
1082+
loader: PluginLoader,
10841083
configuration: ContainerConfiguration,
10851084
path: URL,
10861085
debug: Bool
10871086
) throws {
10881087
let args = [
10891088
"start",
1090-
variant != nil ? "--variant" : nil,
1091-
variant,
10921089
"--root", path.path,
10931090
"--uuid", configuration.id,
10941091
debug ? "--debug" : nil,
@@ -1182,8 +1179,4 @@ extension XPCMessage {
11821179
}
11831180
return try JSONDecoder().decode(ProcessConfiguration.self, from: data)
11841181
}
1185-
1186-
func variant() -> String? {
1187-
self.string(key: .variant)
1188-
}
11891182
}

Tests/ContainerPluginTests/PluginLoaderTest.swift

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -176,85 +176,6 @@ struct PluginLoaderTest {
176176
#expect(filtered.isEmpty)
177177
}
178178

179-
@Test
180-
func testRegisterWithLaunchdDefaultArgs() async throws {
181-
let tempURL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
182-
defer { try? FileManager.default.removeItem(at: tempURL) }
183-
let factory = try setupMock(tempURL: tempURL)
184-
let loader = try PluginLoader(
185-
appRoot: tempURL,
186-
installRoot: URL(filePath: "/usr/local/"),
187-
logRoot: nil,
188-
pluginDirectories: [tempURL],
189-
pluginFactories: [factory]
190-
)
191-
192-
let plugin = loader.findPlugin(name: "service")!
193-
let stateRoot = tempURL.appendingPathComponent("test-state")
194-
try loader.registerWithLaunchd(plugin: plugin, pluginStateRoot: stateRoot)
195-
196-
let plistURL = stateRoot.appendingPathComponent("service.plist")
197-
let plistData = try Data(contentsOf: plistURL)
198-
let plist = try PropertyListSerialization.propertyList(from: plistData, format: nil) as! [String: Any]
199-
let programArguments = plist["ProgramArguments"] as! [String]
200-
201-
#expect(programArguments.contains("start"))
202-
}
203-
204-
@Test
205-
func testRegisterWithLaunchdCustomArgs() async throws {
206-
let tempURL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
207-
defer { try? FileManager.default.removeItem(at: tempURL) }
208-
let factory = try setupMock(tempURL: tempURL)
209-
let loader = try PluginLoader(
210-
appRoot: tempURL,
211-
installRoot: URL(filePath: "/usr/local/"),
212-
logRoot: nil,
213-
pluginDirectories: [tempURL],
214-
pluginFactories: [factory]
215-
)
216-
217-
let plugin = loader.findPlugin(name: "service")!
218-
let stateRoot = tempURL.appendingPathComponent("test-state")
219-
try loader.registerWithLaunchd(plugin: plugin, pluginStateRoot: stateRoot, args: ["run", "--verbose"])
220-
221-
let plistURL = stateRoot.appendingPathComponent("service.plist")
222-
let plistData = try Data(contentsOf: plistURL)
223-
let plist = try PropertyListSerialization.propertyList(from: plistData, format: nil) as! [String: Any]
224-
let programArguments = plist["ProgramArguments"] as! [String]
225-
226-
#expect(programArguments.contains("run"))
227-
#expect(programArguments.contains("--verbose"))
228-
#expect(!programArguments.contains("start"))
229-
}
230-
231-
@Test
232-
func testRegisterWithLaunchdCustomArgsAndDebug() async throws {
233-
let tempURL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
234-
defer { try? FileManager.default.removeItem(at: tempURL) }
235-
let factory = try setupMock(tempURL: tempURL)
236-
let loader = try PluginLoader(
237-
appRoot: tempURL,
238-
installRoot: URL(filePath: "/usr/local/"),
239-
logRoot: nil,
240-
pluginDirectories: [tempURL],
241-
pluginFactories: [factory]
242-
)
243-
244-
let plugin = loader.findPlugin(name: "service")!
245-
let stateRoot = tempURL.appendingPathComponent("test-state")
246-
try loader.registerWithLaunchd(plugin: plugin, pluginStateRoot: stateRoot, args: ["run"], debug: true)
247-
248-
let plistURL = stateRoot.appendingPathComponent("service.plist")
249-
let plistData = try Data(contentsOf: plistURL)
250-
let plist = try PropertyListSerialization.propertyList(from: plistData, format: nil) as! [String: Any]
251-
let programArguments = plist["ProgramArguments"] as! [String]
252-
253-
#expect(programArguments.contains("run"))
254-
#expect(programArguments.contains("--debug"))
255-
#expect(!programArguments.contains("start"))
256-
}
257-
258179
@Test
259180
func testRegisterWithLaunchdDebugTrue() async throws {
260181
let tempURL = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)

0 commit comments

Comments
 (0)