Skip to content

Commit 1e17cea

Browse files
authored
Merge branch 'main' into issue-383
2 parents a4e5aad + 0733a81 commit 1e17cea

File tree

28 files changed

+242
-171
lines changed

28 files changed

+242
-171
lines changed

CONTRIBUTORS.txt

Lines changed: 0 additions & 16 deletions
This file was deleted.

MAINTAINERS.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Maintainers
2+
3+
See [MAINTAINERS](https://github.com/apple/containerization/blob/main/MAINTAINERS.txt) for the list of current and former maintainers of this project. Thank you for all your contributions!

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ integration: init-block
183183
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIVolumes || exit_code=1 ; \
184184
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIKernelSet || exit_code=1 ; \
185185
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIAnonymousVolumes || exit_code=1 ; \
186+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --no-parallel --filter TestCLINoParallelCases || exit_code=1 ; \
186187
echo Ensuring apiserver stopped after the CLI integration tests ; \
187188
scripts/ensure-container-stopped.sh ; \
188189
exit $${exit_code} ; \

Package.resolved

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import PackageDescription
2323
let releaseVersion = ProcessInfo.processInfo.environment["RELEASE_VERSION"] ?? "0.0.0"
2424
let gitCommit = ProcessInfo.processInfo.environment["GIT_COMMIT"] ?? "unspecified"
2525
let builderShimVersion = "0.7.0"
26-
let scVersion = "0.16.0"
26+
let scVersion = "0.16.1"
2727

2828
let package = Package(
2929
name: "container",

Sources/ContainerClient/Core/ClientImage.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,13 @@ extension ClientImage {
220220
})
221221
}
222222

223-
public static func pull(reference: String, platform: Platform? = nil, scheme: RequestScheme = .auto, progressUpdate: ProgressUpdateHandler? = nil) async throws -> ClientImage {
223+
public static func pull(
224+
reference: String, platform: Platform? = nil, scheme: RequestScheme = .auto, progressUpdate: ProgressUpdateHandler? = nil, maxConcurrentDownloads: Int = 3
225+
) async throws -> ClientImage {
226+
guard maxConcurrentDownloads > 0 else {
227+
throw ContainerizationError(.invalidArgument, message: "maximum number of concurrent downloads must be greater than 0, got \(maxConcurrentDownloads)")
228+
}
229+
224230
let client = newXPCClient()
225231
let request = newRequest(.imagePull)
226232

@@ -234,6 +240,7 @@ extension ClientImage {
234240

235241
let insecure = try scheme.schemeFor(host: host) == .http
236242
request.set(key: .insecureFlag, value: insecure)
243+
request.set(key: .maxConcurrentDownloads, value: Int64(maxConcurrentDownloads))
237244

238245
var progressUpdateClient: ProgressUpdateClient?
239246
if let progressUpdate {
@@ -313,8 +320,9 @@ extension ClientImage {
313320
return (totalCount: total, activeCount: active, totalSize: size, reclaimableSize: reclaimable)
314321
}
315322

316-
public static func fetch(reference: String, platform: Platform? = nil, scheme: RequestScheme = .auto, progressUpdate: ProgressUpdateHandler? = nil) async throws -> ClientImage
317-
{
323+
public static func fetch(
324+
reference: String, platform: Platform? = nil, scheme: RequestScheme = .auto, progressUpdate: ProgressUpdateHandler? = nil, maxConcurrentDownloads: Int = 3
325+
) async throws -> ClientImage {
318326
do {
319327
let match = try await self.get(reference: reference)
320328
if let platform {
@@ -327,7 +335,7 @@ extension ClientImage {
327335
guard err.isCode(.notFound) else {
328336
throw err
329337
}
330-
return try await Self.pull(reference: reference, platform: platform, scheme: scheme, progressUpdate: progressUpdate)
338+
return try await Self.pull(reference: reference, platform: platform, scheme: scheme, progressUpdate: progressUpdate, maxConcurrentDownloads: maxConcurrentDownloads)
331339
}
332340
}
333341
}

Sources/ContainerClient/Core/ClientVolume.swift

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,13 @@ public struct ClientVolume {
8181
return try JSONDecoder().decode(Volume.self, from: responseData)
8282
}
8383

84-
public static func prune() async throws -> ([String], UInt64) {
84+
public static func volumeDiskUsage(name: String) async throws -> UInt64 {
8585
let client = XPCClient(service: serviceIdentifier)
86-
let message = XPCMessage(route: .volumePrune)
86+
let message = XPCMessage(route: .volumeDiskUsage)
87+
message.set(key: .volumeName, value: name)
8788
let reply = try await client.send(message)
8889

89-
guard let responseData = reply.dataNoCopy(key: .volumes) else {
90-
return ([], 0)
91-
}
92-
93-
let volumeNames = try JSONDecoder().decode([String].self, from: responseData)
9490
let size = reply.uint64(key: .volumeSize)
95-
return (volumeNames, size)
91+
return size
9692
}
97-
9893
}

Sources/ContainerClient/Core/Filesystem.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public struct Filesystem: Sendable, Codable {
8787
/// A block based filesystem.
8888
public static func block(
8989
format: String, source: String, destination: String, options: MountOptions, cache: CacheMode = .auto,
90-
sync: SyncMode = .full
90+
sync: SyncMode = .fsync
9191
) -> Filesystem {
9292
.init(
9393
type: .block(format: format, cache: cache, sync: sync),
@@ -100,7 +100,7 @@ public struct Filesystem: Sendable, Codable {
100100
/// A named volume filesystem.
101101
public static func volume(
102102
name: String, format: String, source: String, destination: String, options: MountOptions,
103-
cache: CacheMode = .auto, sync: SyncMode = .full
103+
cache: CacheMode = .auto, sync: SyncMode = .fsync
104104
) -> Filesystem {
105105
.init(
106106
type: .volume(name: name, format: format, cache: cache, sync: sync),

Sources/ContainerClient/Core/XPC+.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,8 @@ public enum XPCRoute: String {
157157
case volumeDelete
158158
case volumeList
159159
case volumeInspect
160-
case volumePrune
161160

161+
case volumeDiskUsage
162162
case systemDiskUsage
163163

164164
case ping

Sources/ContainerClient/Flags.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,11 @@ public struct Flags {
215215
@Option(name: .long, help: ArgumentHelp("Progress type (format: none|ansi)", valueName: "type"))
216216
public var progress: ProgressType = .ansi
217217
}
218+
219+
public struct ImageFetch: ParsableArguments {
220+
public init() {}
221+
222+
@Option(name: .long, help: "Maximum number of concurrent downloads (default: 3)")
223+
public var maxConcurrentDownloads: Int = 3
224+
}
218225
}

0 commit comments

Comments
 (0)