Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pod.status.containerStatuses displayed image name incorrectly when image has multiple tags on the node #165

Open
diannaowa opened this issue Feb 27, 2023 · 3 comments

Comments

@diannaowa
Copy link

For more detail: pod.status.containerStatuses displayed image name incorrectly when image has multiple tags on the node

@afbjorklund
Copy link
Contributor

afbjorklund commented Feb 27, 2023

This behaviour is defined by CRI, and seems to be done the same way in containerd:

                repoTags, repoDigests := parseImageReferences(image.References)
                if len(repoTags) > 0 {
                        // Based on current behavior of dockershim, this field should be
                        // image tag.
                        spec = &runtime.ImageSpec{Image: repoTags[0]}
                }
                if len(repoDigests) > 0 {
                        // Based on the CRI definition, this field will be consumed by user.
                        imageRef = repoDigests[0]
                }

Maybe the sort order can be tweaked, but otherwise it needs to be discussed in API ?

Something for SIG Node, https://github.com/kubernetes/community/tree/master/sig-node

@diannaowa
Copy link
Author

diannaowa commented Feb 27, 2023

Thank you for your prompt reply。@afbjorklund
In kubelet, It starts the container through the following steps:
// * pull the image
// * create the container
// * start the container
// * run the post start lifecycle hooks (if applicable)

func (m *kubeGenericRuntimeManager) startContainer(ctx context.Context, podSandboxID string, podSandboxConfig *runtimeapi.PodSandboxConfig, spec *startSpec, pod *v1.Pod, podStatus *kubecontainer.PodStatus, pullSecrets []v1.Secret, podIP string, podIPs []string) (string, error) {
        // Step 1: pull the image.
	imageRef, msg, err := m.imagePuller.EnsureImageExists(ctx, pod, container, pullSecrets, podSandboxConfig)
        ......
        containerConfig, cleanupAction, err := m.generateContainerConfig(ctx, container, pod, restartCount, podIP, imageRef, podIPs, target)
       ......
       // Step 2: create the container.
       ......
       containerID, err := m.runtimeService.CreateContainer(ctx, podSandboxID, containerConfig, podSandboxConfig)
       ......
       // Step 3: start the container.
	err = m.runtimeService.StartContainer(ctx, containerID)
        .....
}

I have a workaround with this issue: Code
This method also works for containerd.
But,I didn't do a compatibility test.
Maybe, this is not expected behavior of CRI.

@evol262
Copy link
Contributor

evol262 commented Feb 27, 2023

I'm not convinced that commenting it out entirely is a great workaround, and a 4 year old k8s issue which has more or less identical behavior across CRIs is something we should be hesitant to change. If there were going to be one, sorting ir.ImageTags and then taking the first entry is far preferable.

What are the actual impacts of this, as a reason to resurrect a 4 year old issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants