Skip to content

Commit 3e5fe44

Browse files
committed
Merge remote-tracking branch 'oss/main' into fix-directory-watcher-tmp
2 parents c31419d + 5ae887c commit 3e5fe44

33 files changed

Lines changed: 738 additions & 136 deletions

.github/labeler.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,15 @@ cli:
22
- changed-files:
33
- any-glob-to-any-file:
44
- 'Sources/CLI/**'
5-
- 'Sources/ContainerCommands/**'
5+
- 'Sources/ContainerCommands/**'
6+
7+
documentation:
8+
- changed-files:
9+
- any-glob-to-any-file:
10+
- '**/*.md'
11+
- 'docs/**'
12+
13+
ci:
14+
- changed-files:
15+
- any-glob-to-any-file:
16+
- '.github/**'

.github/workflows/common.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,38 @@ jobs:
7171
- name: Test the container project
7272
run: |
7373
APP_ROOT=$(mktemp -d -p "${RUNNER_TEMP}")
74+
LOG_ROOT="${APP_ROOT}/logs"
7475
trap 'rm -rf "${APP_ROOT}"; echo Removing data directory ${APP_ROOT}' EXIT
75-
echo "Created data directory ${APP_ROOT}"
76+
echo "created data directory: ${APP_ROOT}"
77+
echo "hostname: $(hostname)"
7678
export NO_PROXY="${NO_PROXY},192.168.0.0/16,fe80::/10"
7779
echo NO_PROXY=${NO_PROXY}
7880
export no_proxy="${no_proxy},192.168.0.0/16,fe80::/10"
7981
echo no_proxy=${no_proxy}
80-
make APP_ROOT="${APP_ROOT}" test install-kernel integration
82+
echo "APP_ROOT=${APP_ROOT}" >> $GITHUB_ENV
83+
echo "LOG_ROOT=${LOG_ROOT}" >> $GITHUB_ENV
84+
make APP_ROOT="${APP_ROOT}" LOG_ROOT="${LOG_ROOT}" test install-kernel integration || status=$?
85+
if [ -d "${LOG_ROOT}" ] ; then
86+
echo "Collecting logs from ${LOG_ROOT}..."
87+
tar czf container-logs.tar.gz -C "$(dirname "${LOG_ROOT}")" "$(basename "${LOG_ROOT}")"
88+
echo "Log archive created: container-logs.tar.gz"
89+
fi
90+
if [ "${status:-0}" -ne "0" ] ; then
91+
echo "Tests failed with status: ${status}"
92+
exit ${status}
93+
fi
8194
env:
8295
DEVELOPER_DIR: "/Applications/Xcode-latest.app/Contents/Developer"
8396

97+
- name: Upload logs if present
98+
if: always()
99+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
100+
with:
101+
name: container-test-logs
102+
path: container-logs.tar.gz
103+
retention-days: 14
104+
if-no-files-found: ignore
105+
84106
- name: Save documentation artifact
85107
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
86108
with:

Makefile

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ SYSTEM_START_OPTS :=
3737
ifneq ($(strip $(APP_ROOT)),)
3838
SYSTEM_START_OPTS += --app-root "$(strip $(APP_ROOT))"
3939
endif
40+
ifneq ($(strip $(LOG_ROOT)),)
41+
SYSTEM_START_OPTS += --log-root "$(strip $(LOG_ROOT))"
42+
endif
4043

4144
MACOS_VERSION := $(shell sw_vers -productVersion)
4245
MACOS_MAJOR := $(shell echo $(MACOS_VERSION) | cut -d. -f1)
@@ -182,24 +185,25 @@ integration: init-block
182185
echo "Starting CLI integration tests" && \
183186
{ \
184187
exit_code=0; \
185-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLINetwork || exit_code=1 ; \
186-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunLifecycle || exit_code=1 ; \
187-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIExecCommand || exit_code=1 ; \
188-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLICreateCommand || exit_code=1 ; \
189-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunCommand1 || exit_code=1 ; \
190-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunCommand2 || exit_code=1 ; \
191-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunCommand3 || exit_code=1 ; \
192-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIPruneCommand || exit_code=1 ; \
193-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRegistry || exit_code=1 ; \
194-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIStatsCommand || exit_code=1 ; \
195-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIImagesCommand || exit_code=1 ; \
196-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunBase || exit_code=1 ; \
197-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunInitImage || exit_code=1 ; \
198-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIBuildBase || exit_code=1 ; \
199-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIVolumes || exit_code=1 ; \
200-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIKernelSet || exit_code=1 ; \
201-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIAnonymousVolumes || exit_code=1 ; \
202-
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLINoParallelCases || exit_code=1 ; \
188+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLINetwork || exit_code=1 ; \
189+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunLifecycle || exit_code=1 ; \
190+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIExecCommand || exit_code=1 ; \
191+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLICreateCommand || exit_code=1 ; \
192+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunCommand1 || exit_code=1 ; \
193+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunCommand2 || exit_code=1 ; \
194+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunCommand3 || exit_code=1 ; \
195+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIPruneCommand || exit_code=1 ; \
196+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRegistry || exit_code=1 ; \
197+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIStatsCommand || exit_code=1 ; \
198+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIImagesCommand || exit_code=1 ; \
199+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunBase || exit_code=1 ; \
200+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIRunInitImage || exit_code=1 ; \
201+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIBuildBase || exit_code=1 ; \
202+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIExportCommand || exit_code=1 ; \
203+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIVolumes || exit_code=1 ; \
204+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIKernelSet || exit_code=1 ; \
205+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLIAnonymousVolumes || exit_code=1 ; \
206+
$(SWIFT) test -c $(BUILD_CONFIGURATION) $(SWIFT_CONFIGURATION) --filter TestCLINoParallelCases || exit_code=1 ; \
203207
echo Ensuring apiserver stopped after the CLI integration tests ; \
204208
scripts/ensure-container-stopped.sh ; \
205209
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: 20 additions & 12 deletions
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.8.0"
26-
let scVersion = "0.26.1"
26+
let scVersion = "0.26.2"
2727

2828
let package = Package(
2929
name: "container",
@@ -47,17 +47,18 @@ let package = Package(
4747
.library(name: "TerminalProgress", targets: ["TerminalProgress"]),
4848
],
4949
dependencies: [
50-
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
50+
.package(url: "https://github.com/Bouke/DNS.git", from: "1.2.0"),
51+
.package(url: "https://github.com/apple/containerization.git", exact: Version(stringLiteral: scVersion)),
5152
.package(url: "https://github.com/apple/swift-argument-parser.git", from: "1.3.0"),
5253
.package(url: "https://github.com/apple/swift-collections.git", from: "1.2.0"),
53-
.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.26.0"),
54-
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.29.0"),
54+
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
5555
.package(url: "https://github.com/apple/swift-nio.git", from: "2.80.0"),
56-
.package(url: "https://github.com/swiftlang/swift-docc-plugin.git", from: "1.1.0"),
57-
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.20.1"),
56+
.package(url: "https://github.com/apple/swift-protobuf.git", from: "1.29.0"),
57+
.package(url: "https://github.com/apple/swift-system.git", from: "1.4.0"),
58+
.package(url: "https://github.com/grpc/grpc-swift.git", from: "1.26.0"),
5859
.package(url: "https://github.com/orlandos-nl/DNSClient.git", from: "2.4.1"),
59-
.package(url: "https://github.com/Bouke/DNS.git", from: "1.2.0"),
60-
.package(url: "https://github.com/apple/containerization.git", exact: Version(stringLiteral: scVersion)),
60+
.package(url: "https://github.com/swift-server/async-http-client.git", from: "1.20.1"),
61+
.package(url: "https://github.com/swiftlang/swift-docc-plugin.git", from: "1.1.0"),
6162
],
6263
targets: [
6364
.executableTarget(
@@ -155,6 +156,7 @@ let package = Package(
155156
.product(name: "ContainerizationExtras", package: "containerization"),
156157
.product(name: "ContainerizationOS", package: "containerization"),
157158
.product(name: "Logging", package: "swift-log"),
159+
.product(name: "SystemPackage", package: "swift-system"),
158160
"CVersion",
159161
"ContainerAPIClient",
160162
"ContainerNetworkServiceClient",
@@ -172,13 +174,14 @@ let package = Package(
172174
name: "ContainerAPIClient",
173175
dependencies: [
174176
.product(name: "ArgumentParser", package: "swift-argument-parser"),
175-
.product(name: "Logging", package: "swift-log"),
176-
.product(name: "NIOCore", package: "swift-nio"),
177-
.product(name: "NIOPosix", package: "swift-nio"),
178177
.product(name: "Containerization", package: "containerization"),
179178
.product(name: "ContainerizationArchive", package: "containerization"),
180179
.product(name: "ContainerizationOCI", package: "containerization"),
181180
.product(name: "ContainerizationOS", package: "containerization"),
181+
.product(name: "Logging", package: "swift-log"),
182+
.product(name: "NIOCore", package: "swift-nio"),
183+
.product(name: "NIOPosix", package: "swift-nio"),
184+
.product(name: "SystemPackage", package: "swift-system"),
182185
"ContainerImagesServiceClient",
183186
"ContainerPersistence",
184187
"ContainerPlugin",
@@ -202,6 +205,7 @@ let package = Package(
202205
.product(name: "ArgumentParser", package: "swift-argument-parser"),
203206
.product(name: "Logging", package: "swift-log"),
204207
.product(name: "Containerization", package: "containerization"),
208+
.product(name: "SystemPackage", package: "swift-system"),
205209
"ContainerImagesService",
206210
"ContainerLog",
207211
"ContainerPlugin",
@@ -251,6 +255,7 @@ let package = Package(
251255
"ContainerLog",
252256
"ContainerNetworkService",
253257
"ContainerNetworkServiceClient",
258+
"ContainerPlugin",
254259
"ContainerResource",
255260
"ContainerVersion",
256261
"ContainerXPC",
@@ -297,6 +302,7 @@ let package = Package(
297302
.product(name: "GRPC", package: "grpc-swift"),
298303
.product(name: "Containerization", package: "containerization"),
299304
"ContainerLog",
305+
"ContainerPlugin",
300306
"ContainerResource",
301307
"ContainerSandboxService",
302308
"ContainerSandboxServiceClient",
@@ -352,7 +358,8 @@ let package = Package(
352358
.target(
353359
name: "ContainerLog",
354360
dependencies: [
355-
.product(name: "Logging", package: "swift-log")
361+
.product(name: "Logging", package: "swift-log"),
362+
.product(name: "SystemPackage", package: "swift-system"),
356363
]
357364
),
358365
.target(
@@ -369,6 +376,7 @@ let package = Package(
369376
dependencies: [
370377
.product(name: "Logging", package: "swift-log"),
371378
.product(name: "ContainerizationOS", package: "containerization"),
379+
.product(name: "SystemPackage", package: "swift-system"),
372380
"ContainerVersion",
373381
]
374382
),

Sources/ContainerCommands/Application.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ public struct Application: AsyncLoggableCommand {
172172
return try PluginLoader(
173173
appRoot: systemHealth.appRoot,
174174
installRoot: systemHealth.installRoot,
175+
logRoot: systemHealth.logRoot,
175176
pluginDirectories: pluginDirectories,
176177
pluginFactories: pluginFactories,
177178
log: bootstrapLogger

Sources/ContainerCommands/Image/ImageInspect.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,13 @@ extension Application {
6363
}
6464

6565
if !allErrors.isEmpty {
66-
let logger = Logger(label: "ImageInspect", factory: { _ in StderrLogHandler() })
6766
for (name, error) in allErrors {
68-
logger.error("\(name): \(error.localizedDescription)")
67+
log.error(
68+
"image inspect failed",
69+
metadata: [
70+
"name": "\(name)",
71+
"error": "\(error.localizedDescription)",
72+
])
6973
}
7074

7175
throw InspectError(succeeded: succeededImages, failed: allErrors)

Sources/ContainerCommands/Network/NetworkDelete.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ extension Application {
8989
}
9090

9191
var failed = [String]()
92-
let logger = log
92+
let _log = log
9393
try await withThrowingTaskGroup(of: NetworkState?.self) { group in
9494
for network in networks {
9595
group.addTask {
@@ -100,7 +100,12 @@ extension Application {
100100
print(network.id)
101101
return nil
102102
} catch {
103-
logger.error("failed to delete network \(network.id): \(error)")
103+
_log.error(
104+
"failed to delete network",
105+
metadata: [
106+
"id": "\(network.id)",
107+
"error": "\(error)",
108+
])
104109
return network
105110
}
106111
}

Sources/ContainerCommands/Network/NetworkPrune.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ extension Application.NetworkCommand {
5555
// Note: This failure may occur due to a race condition between the network/
5656
// container collection above and a container run command that attaches to a
5757
// network listed in the networksToPrune collection.
58-
log.error("failed to prune network", metadata: ["id": "\(network.id)", "error": "\(error)"])
58+
log.error(
59+
"failed to prune network",
60+
metadata: [
61+
"id": "\(network.id)",
62+
"error": "\(error)",
63+
])
5964
}
6065
}
6166

Sources/ContainerCommands/System/SystemStart.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import ContainerPlugin
2121
import ContainerXPC
2222
import ContainerizationError
2323
import Foundation
24+
import SystemPackage
2425
import TerminalProgress
2526

2627
extension Application {
@@ -42,6 +43,12 @@ extension Application {
4243
transform: { URL(filePath: $0) })
4344
var installRoot = InstallRoot.defaultURL
4445

46+
@Option(
47+
name: .long,
48+
help: "Path to the root directory for log data, using macOS log facility if not set",
49+
transform: { FilePath($0) })
50+
var logRoot: FilePath? = nil
51+
4552
@Flag(
4653
name: .long,
4754
inversion: .prefixedEnableDisable,
@@ -85,7 +92,12 @@ extension Application {
8592
var env = PluginLoader.filterEnvironment()
8693
env[ApplicationRoot.environmentName] = appRoot.path(percentEncoded: false)
8794
env[InstallRoot.environmentName] = installRoot.path(percentEncoded: false)
88-
95+
if let logRoot {
96+
env[LogRoot.environmentName] =
97+
logRoot.isAbsolute
98+
? logRoot.string
99+
: FilePath(FileManager.default.currentDirectoryPath).appending(logRoot.components).string
100+
}
89101
let plist = LaunchPlist(
90102
label: "com.apple.container.apiserver",
91103
arguments: args,

0 commit comments

Comments
 (0)