Skip to content

Commit 2ec4515

Browse files
Merge pull request kubernetes#18340 from sjenning/pick-58955
Automatic merge from submit-queue (batch tested with PRs 18225, 18351, 18331, 18340, 18326). UPSTREAM: 58955: pkg: kubelet: do not assume anything about images names kubernetes#58955 removes the need for openshift/origin#18020 see history: kubernetes#51751 kubernetes#52110 kubernetes#53161 @liggitt @derekwaynecarr @frobware @mrunalp @runcom Origin-commit: d91de347457d7f6f3d1859c671c7355cc193d038
2 parents 1765c4c + 8725517 commit 2ec4515

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

pkg/kubelet/images/image_manager.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,12 @@ func applyDefaultImageTag(image string) (string, error) {
154154
_, isTagged := named.(dockerref.Tagged)
155155
_, isDigested := named.(dockerref.Digested)
156156
if !isTagged && !isDigested {
157-
named, err := dockerref.WithTag(named, parsers.DefaultImageTag)
158-
if err != nil {
159-
return "", fmt.Errorf("failed to apply default image tag %q: %v", image, err)
160-
}
161-
image = named.String()
157+
// we just concatenate the image name with the default tag here instead
158+
// of using dockerref.WithTag(named, ...) because that would cause the
159+
// image to be fully qualified as docker.io/$name if it's a short name
160+
// (e.g. just busybox). We don't want that to happen to keep the CRI
161+
// agnostic wrt image names and default hostnames.
162+
image = image + ":" + parsers.DefaultImageTag
162163
}
163164
return image, nil
164165
}

pkg/kubelet/images/image_manager_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func pullerTestEnv(c pullerTestCase, serialized bool) (puller ImageManager, fake
125125
fakeRuntime = &ctest.FakeRuntime{}
126126
fakeRecorder := &record.FakeRecorder{}
127127

128-
fakeRuntime.ImageList = []Image{{ID: "docker.io/library/present_image:latest"}}
128+
fakeRuntime.ImageList = []Image{{ID: "present_image:latest"}}
129129
fakeRuntime.Err = c.pullerErr
130130
fakeRuntime.InspectErr = c.inspectErr
131131

@@ -188,7 +188,7 @@ func TestApplyDefaultImageTag(t *testing.T) {
188188
Input string
189189
Output string
190190
}{
191-
{Input: "root", Output: "docker.io/library/root:latest"},
191+
{Input: "root", Output: "root:latest"},
192192
{Input: "root:tag", Output: "root:tag"},
193193
{Input: "root@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", Output: "root@sha256:e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"},
194194
} {

0 commit comments

Comments
 (0)