Skip to content

Commit 3cc173a

Browse files
bpcreechBen Creech
andauthored
Load foreign layers last (#2100)
Co-authored-by: Ben Creech <[email protected]>
1 parent c823a69 commit 3cc173a

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

container/go/pkg/compat/reader.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,9 +314,6 @@ func (r *Reader) ReadImage() (v1.Image, error) {
314314
if err := r.loadMetadata(); err != nil {
315315
return nil, errors.Wrap(err, "unable to load image metadata")
316316
}
317-
if err := r.loadForeignLayers(); err != nil {
318-
return nil, errors.Wrap(err, "unable to load foreign layers specified in the base manifest")
319-
}
320317
if err := r.loadImages(r.Parts.Images); err != nil {
321318
return nil, errors.Wrap(err, "unable to load layers from the images in the given image parts")
322319
}
@@ -326,6 +323,9 @@ func (r *Reader) ReadImage() (v1.Image, error) {
326323
if err := r.loadLayers(); err != nil {
327324
return nil, errors.Wrap(err, "unable to load layers from the given parts")
328325
}
326+
if err := r.loadForeignLayers(); err != nil {
327+
return nil, errors.Wrap(err, "unable to load foreign layers specified in the base manifest")
328+
}
329329
layers := []v1.Layer{}
330330
for _, diffID := range r.config.RootFS.DiffIDs {
331331
layer, ok := r.layerLookup[diffID]

tests/container/BUILD

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,13 @@ container_image(
197197
operating_system = "windows",
198198
)
199199

200+
container_image(
201+
name = "basic_windows_image_from_tar",
202+
base = ":import_windows_base_image.tar",
203+
cmd = ["echo bar"],
204+
operating_system = "windows",
205+
)
206+
200207
container_test(
201208
name = "basic_windows_image_test",
202209
configs = ["//tests/container/configs:windows_image.yaml"],
@@ -960,6 +967,7 @@ TEST_DATA = [
960967
"//testdata:stamped_bundle_test",
961968
"//testdata:stamp_info_file.txt",
962969
"//tests/container:basic_windows_image.tar",
970+
"//tests/container:basic_windows_image_from_tar.tar",
963971
]
964972

965973
py_test(

tests/container/image_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,14 @@ def test_windows_image_manifest_with_foreign_layers(self):
623623
self.assertIn("https://go.microsoft.com/fwlink/?linkid=873595",
624624
img.manifest())
625625

626+
def test_windows_image_manifest_with_foreign_layers_from_tar(self):
627+
imgPath = TestRunfilePath(
628+
"tests", "container", "basic_windows_image_from_tar.tar")
629+
with v2_2_image.FromTarball(imgPath) as img:
630+
# Ensure the image manifest in the tarball includes the foreign layer.
631+
self.assertIn("https://go.microsoft.com/fwlink/?linkid=873595",
632+
img.manifest())
633+
626634
def test_py_image_with_symlinks_in_data(self):
627635
with TestImage('py_image_with_symlinks_in_data') as img:
628636
# Check the application layer, which is on top.

0 commit comments

Comments
 (0)