mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Return repoTags instead of digest in containerStatuses.image
This commit is contained in:
parent
394aad9d6b
commit
1de92a91e9
@ -364,10 +364,14 @@ func (ds *dockerService) ContainerStatus(containerID string) (*runtimeapi.Contai
|
|||||||
}
|
}
|
||||||
|
|
||||||
labels, annotations := extractLabels(r.Config.Labels)
|
labels, annotations := extractLabels(r.Config.Labels)
|
||||||
|
imageName := r.Config.Image
|
||||||
|
if len(ir.RepoTags) > 0 {
|
||||||
|
imageName = ir.RepoTags[0]
|
||||||
|
}
|
||||||
return &runtimeapi.ContainerStatus{
|
return &runtimeapi.ContainerStatus{
|
||||||
Id: &r.ID,
|
Id: &r.ID,
|
||||||
Metadata: metadata,
|
Metadata: metadata,
|
||||||
Image: &runtimeapi.ImageSpec{Image: &r.Config.Image},
|
Image: &runtimeapi.ImageSpec{Image: &imageName},
|
||||||
ImageRef: &imageID,
|
ImageRef: &imageID,
|
||||||
Mounts: mounts,
|
Mounts: mounts,
|
||||||
ExitCode: &exitCode,
|
ExitCode: &exitCode,
|
||||||
|
@ -430,10 +430,14 @@ func (dm *DockerManager) inspectContainer(id string, podName, podNamespace strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
imageName := iResult.Config.Image
|
||||||
|
if len(imgInspectResult.RepoTags) > 0 {
|
||||||
|
imageName = imgInspectResult.RepoTags[0]
|
||||||
|
}
|
||||||
status := kubecontainer.ContainerStatus{
|
status := kubecontainer.ContainerStatus{
|
||||||
Name: containerName,
|
Name: containerName,
|
||||||
RestartCount: containerInfo.RestartCount,
|
RestartCount: containerInfo.RestartCount,
|
||||||
Image: iResult.Config.Image,
|
Image: imageName,
|
||||||
ImageID: imageID,
|
ImageID: imageID,
|
||||||
ID: kubecontainer.DockerID(id).ContainerID(),
|
ID: kubecontainer.DockerID(id).ContainerID(),
|
||||||
ExitCode: iResult.State.ExitCode,
|
ExitCode: iResult.State.ExitCode,
|
||||||
|
@ -478,7 +478,10 @@ func (f *FakeDockerClient) PullImage(image string, auth dockertypes.AuthConfig,
|
|||||||
err := f.popError("pull")
|
err := f.popError("pull")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
authJson, _ := json.Marshal(auth)
|
authJson, _ := json.Marshal(auth)
|
||||||
f.Image = &dockertypes.ImageInspect{ID: image}
|
f.Image = &dockertypes.ImageInspect{
|
||||||
|
ID: image,
|
||||||
|
RepoTags: []string{image},
|
||||||
|
}
|
||||||
f.pulled = append(f.pulled, fmt.Sprintf("%s using %s", image, string(authJson)))
|
f.pulled = append(f.pulled, fmt.Sprintf("%s using %s", image, string(authJson)))
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
|
@ -81,7 +81,7 @@ func (m *imageManager) logIt(ref *v1.ObjectReference, eventtype, event, prefix,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnsureImageExists pulls the image for the specified pod and container, and returnsIt returns
|
// EnsureImageExists pulls the image for the specified pod and container, and returns
|
||||||
// (imageRef, error message, error).
|
// (imageRef, error message, error).
|
||||||
func (m *imageManager) EnsureImageExists(pod *v1.Pod, container *v1.Container, pullSecrets []v1.Secret) (string, string, error) {
|
func (m *imageManager) EnsureImageExists(pod *v1.Pod, container *v1.Container, pullSecrets []v1.Secret) (string, string, error) {
|
||||||
logPrefix := fmt.Sprintf("%s/%s", pod.Name, container.Image)
|
logPrefix := fmt.Sprintf("%s/%s", pod.Name, container.Image)
|
||||||
@ -106,8 +106,9 @@ func (m *imageManager) EnsureImageExists(pod *v1.Pod, container *v1.Container, p
|
|||||||
return "", msg, ErrImageInspect
|
return "", msg, ErrImageInspect
|
||||||
}
|
}
|
||||||
|
|
||||||
if !shouldPullImage(container, imageRef != "") {
|
present := imageRef != ""
|
||||||
if imageRef != "" {
|
if !shouldPullImage(container, present) {
|
||||||
|
if present {
|
||||||
msg := fmt.Sprintf("Container image %q already present on machine", container.Image)
|
msg := fmt.Sprintf("Container image %q already present on machine", container.Image)
|
||||||
m.logIt(ref, v1.EventTypeNormal, events.PulledImage, logPrefix, msg, glog.Info)
|
m.logIt(ref, v1.EventTypeNormal, events.PulledImage, logPrefix, msg, glog.Info)
|
||||||
return imageRef, "", nil
|
return imageRef, "", nil
|
||||||
@ -125,7 +126,7 @@ func (m *imageManager) EnsureImageExists(pod *v1.Pod, container *v1.Container, p
|
|||||||
return "", msg, ErrImagePullBackOff
|
return "", msg, ErrImagePullBackOff
|
||||||
}
|
}
|
||||||
m.logIt(ref, v1.EventTypeNormal, events.PullingImage, logPrefix, fmt.Sprintf("pulling image %q", container.Image), glog.Info)
|
m.logIt(ref, v1.EventTypeNormal, events.PullingImage, logPrefix, fmt.Sprintf("pulling image %q", container.Image), glog.Info)
|
||||||
pullChan := make(chan imageRefWithError)
|
pullChan := make(chan pullResult)
|
||||||
m.puller.pullImage(spec, pullSecrets, pullChan)
|
m.puller.pullImage(spec, pullSecrets, pullChan)
|
||||||
imageRefWithErr := <-pullChan
|
imageRefWithErr := <-pullChan
|
||||||
if imageRefWithErr.err != nil {
|
if imageRefWithErr.err != nil {
|
||||||
|
@ -24,13 +24,13 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/util/wait"
|
"k8s.io/kubernetes/pkg/util/wait"
|
||||||
)
|
)
|
||||||
|
|
||||||
type imageRefWithError struct {
|
type pullResult struct {
|
||||||
imageRef string
|
imageRef string
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
type imagePuller interface {
|
type imagePuller interface {
|
||||||
pullImage(kubecontainer.ImageSpec, []v1.Secret, chan<- imageRefWithError)
|
pullImage(kubecontainer.ImageSpec, []v1.Secret, chan<- pullResult)
|
||||||
}
|
}
|
||||||
|
|
||||||
var _, _ imagePuller = ¶llelImagePuller{}, &serialImagePuller{}
|
var _, _ imagePuller = ¶llelImagePuller{}, &serialImagePuller{}
|
||||||
@ -43,10 +43,10 @@ func newParallelImagePuller(imageService kubecontainer.ImageService) imagePuller
|
|||||||
return ¶llelImagePuller{imageService}
|
return ¶llelImagePuller{imageService}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (pip *parallelImagePuller) pullImage(spec kubecontainer.ImageSpec, pullSecrets []v1.Secret, pullChan chan<- imageRefWithError) {
|
func (pip *parallelImagePuller) pullImage(spec kubecontainer.ImageSpec, pullSecrets []v1.Secret, pullChan chan<- pullResult) {
|
||||||
go func() {
|
go func() {
|
||||||
imageRef, err := pip.imageService.PullImage(spec, pullSecrets)
|
imageRef, err := pip.imageService.PullImage(spec, pullSecrets)
|
||||||
pullChan <- imageRefWithError{
|
pullChan <- pullResult{
|
||||||
imageRef: imageRef,
|
imageRef: imageRef,
|
||||||
err: err,
|
err: err,
|
||||||
}
|
}
|
||||||
@ -70,10 +70,10 @@ func newSerialImagePuller(imageService kubecontainer.ImageService) imagePuller {
|
|||||||
type imagePullRequest struct {
|
type imagePullRequest struct {
|
||||||
spec kubecontainer.ImageSpec
|
spec kubecontainer.ImageSpec
|
||||||
pullSecrets []v1.Secret
|
pullSecrets []v1.Secret
|
||||||
pullChan chan<- imageRefWithError
|
pullChan chan<- pullResult
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sip *serialImagePuller) pullImage(spec kubecontainer.ImageSpec, pullSecrets []v1.Secret, pullChan chan<- imageRefWithError) {
|
func (sip *serialImagePuller) pullImage(spec kubecontainer.ImageSpec, pullSecrets []v1.Secret, pullChan chan<- pullResult) {
|
||||||
sip.pullRequests <- &imagePullRequest{
|
sip.pullRequests <- &imagePullRequest{
|
||||||
spec: spec,
|
spec: spec,
|
||||||
pullSecrets: pullSecrets,
|
pullSecrets: pullSecrets,
|
||||||
@ -84,7 +84,7 @@ func (sip *serialImagePuller) pullImage(spec kubecontainer.ImageSpec, pullSecret
|
|||||||
func (sip *serialImagePuller) processImagePullRequests() {
|
func (sip *serialImagePuller) processImagePullRequests() {
|
||||||
for pullRequest := range sip.pullRequests {
|
for pullRequest := range sip.pullRequests {
|
||||||
imageRef, err := sip.imageService.PullImage(pullRequest.spec, pullRequest.pullSecrets)
|
imageRef, err := sip.imageService.PullImage(pullRequest.spec, pullRequest.pullSecrets)
|
||||||
pullRequest.pullChan <- imageRefWithError{
|
pullRequest.pullChan <- pullResult{
|
||||||
imageRef: imageRef,
|
imageRef: imageRef,
|
||||||
err: err,
|
err: err,
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user