-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Pods can't find cached images in minikube with containerd #4985
Comments
Looks to be a bug with the containerd cri plugin, that is not in the dockershim and not in other plugins. Fails with containerd:
Works fine with CRI-O:
If I understood correctly, this could be an issue with spec := kubecontainer.ImageSpec{Image: image}
imageRef, err := m.imageService.GetImageRef(spec)
if err != nil {
msg := fmt.Sprintf("Failed to inspect image %q: %v", container.Image, err)
m.logIt(ref, v1.EventTypeWarning, events.FailedToInspectImage, logPrefix, msg, klog.Warning)
return "", msg, ErrImageInspect
}
present := imageRef != ""
if !shouldPullImage(container, present) {
if present {
msg := fmt.Sprintf("Container image %q already present on machine", container.Image)
m.logIt(ref, v1.EventTypeNormal, events.PulledImage, logPrefix, msg, klog.Info)
return imageRef, "", nil
}
msg := fmt.Sprintf("Container image %q is not present with pull policy of Never", container.Image)
m.logIt(ref, v1.EventTypeWarning, events.ErrImageNeverPullPolicy, logPrefix, msg, klog.Warning)
return "", msg, ErrImageNeverPull
} But nothing indicates that this is something in minikube, looks like an upstream containerd thing. |
Changing to
Even though the image is successfully imported and listed:
$ sudo ctr images list
REF TYPE DIGEST SIZE PLATFORMS LABELS
gcr.io/k8s-minikube/cache-bug:latest application/vnd.oci.image.manifest.v1+json sha256:ec1de3156f10594891bec7321851727593665df38eaa1f26af5dda9dc532c125 1.4 MiB linux/amd64 -
gcr.io/k8s-minikube/storage-provisioner:v1.8.1 application/vnd.oci.image.manifest.v1+json sha256:9b4c1942733f9e4209ad4764691f72099b2d6e3967708d441cd30386de29b8f1 19.7 MiB linux/amd64 -
... The shouldPullImage code in Kubernetes is quite trivial, so the problem is with imageRef: // shouldPullImage returns whether we should pull an image according to
// the presence and pull policy of the image.
func shouldPullImage(container *v1.Container, imagePresent bool) bool {
if container.ImagePullPolicy == v1.PullNever {
return false
}
if container.ImagePullPolicy == v1.PullAlways ||
(container.ImagePullPolicy == v1.PullIfNotPresent && (!imagePresent)) {
return true
}
return false
} |
Apparently we are calling the wrong command, This will be fixed in containerd 1.3: containerd/cri#909 But for now (1.2.6), we need to use the older command - and add some versioning later on... @priyawadhwa : can you verify if running @tstromberg: do you know why it was changed earlier ? (e091338 in #3767)
Was that when we had older (broken) containerd, perhaps ? UPDATE: Apparently we could also use |
Hey @afbjorklund thanks for looking int o this --
but I tried with |
Caching images doesn't work with the containerd backend, instead pods will always try to pull images from a remote registry even if they exist locally.
To reproduce, copy these files into a directory:
Dockerfile
pod.yaml
minikube cache add
theredocker build -t gcr.io/k8s-minikube/cache-bug .
minikube start --container-runtime=containerd --docker-opt containerd=/var/run/containerd/containerd.sock --logtostderr
minikube cache add gcr.io/k8s-minikube/cache-bug
minikube ssh -- sudo ctr images ls | grep cache-bug
should show that the image exists within Minikubekubectl apply -f pod.yaml
kubectl get pod cache-bug
should show statusImagePullBackOff
instead ofRunning
because the pod is trying to get the remote image which doesn't exist, even though the image exists locally.The above steps with the docker runtime work as expected, with the pod having status
Running
after a few seconds.The text was updated successfully, but these errors were encountered: