mirror of
https://github.com/apple/container.git
synced 2026-10-24 23:58:42 +00:00
K8s image load fix fqn tagging (#2384)
- The k8s load-image CLI command will issue a ctr image tag command in the guest to make the fully qualified name of an image available when the image has a short name (such as when building and testing locally). The ordering of fully qualified name and source image name was backwards, causing the command to silently fail. Signed-off-by: Kathryn Baldauf <k_baldauf@apple.com>
This commit is contained in:
1 parent
7f3697804f
commit
aa8b830745
2 files changed
+24
-1
No files matched your search
@@ -150,7 +150,7 @@ public struct K8sLoadImage: AsyncParsableCommand {
|
||||
log.info("Tagging image for kubelet", metadata: ["short": "\(image)", "fq": "\(fq)", "target": "\(target)"])
|
||||
let tagConfig = ProcessConfiguration(
|
||||
executable: Self.ctrPath,
|
||||
arguments: ["--namespace", "k8s.io", "images", "tag", fq, image],
|
||||
arguments: ["--namespace", "k8s.io", "images", "tag", "--force", image, fq],
|
||||
environment: [],
|
||||
terminal: false
|
||||
)
|
||||
|
||||
@@ -78,4 +78,27 @@ struct TestK8sLoadImageSerial {
|
||||
#expect(try imageExistsInNode(f, node: name, image: "alpine"))
|
||||
}
|
||||
}
|
||||
|
||||
@Test func testLoadShortNameImageIsFullyQualifiedInNode() async throws {
|
||||
try await ContainerFixture.with { f in
|
||||
let name = "k8s-\(f.testID)"
|
||||
let shortName = "short-\(f.testID):latest"
|
||||
f.addCleanup {
|
||||
_ = try? f.run(["k8s", "delete", "--name", name])
|
||||
_ = try? f.run(["image", "delete", shortName])
|
||||
}
|
||||
|
||||
try f.restoreWarmupImage(.kindestNodeV1_35_5)
|
||||
try f.run(["k8s", "create", "--name", name]).check()
|
||||
|
||||
try f.restoreWarmupImage(.alpine320)
|
||||
try f.run(["image", "tag", Self.testImage, shortName]).check()
|
||||
|
||||
let loadResult = try f.run(["k8s", "load-image", "--name", name, shortName])
|
||||
#expect(loadResult.status == 0)
|
||||
|
||||
// kubelet resolves a short name to docker.io/library/<name>.
|
||||
#expect(try imageExistsInNode(f, node: name, image: "docker.io/library/\(shortName)"))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user