mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Return repoTags instead of digest in containerStatuses.image
This commit is contained in:
		@@ -364,10 +364,14 @@ func (ds *dockerService) ContainerStatus(containerID string) (*runtimeapi.Contai
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	labels, annotations := extractLabels(r.Config.Labels)
 | 
			
		||||
	imageName := r.Config.Image
 | 
			
		||||
	if len(ir.RepoTags) > 0 {
 | 
			
		||||
		imageName = ir.RepoTags[0]
 | 
			
		||||
	}
 | 
			
		||||
	return &runtimeapi.ContainerStatus{
 | 
			
		||||
		Id:          &r.ID,
 | 
			
		||||
		Metadata:    metadata,
 | 
			
		||||
		Image:       &runtimeapi.ImageSpec{Image: &r.Config.Image},
 | 
			
		||||
		Image:       &runtimeapi.ImageSpec{Image: &imageName},
 | 
			
		||||
		ImageRef:    &imageID,
 | 
			
		||||
		Mounts:      mounts,
 | 
			
		||||
		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{
 | 
			
		||||
		Name:         containerName,
 | 
			
		||||
		RestartCount: containerInfo.RestartCount,
 | 
			
		||||
		Image:        iResult.Config.Image,
 | 
			
		||||
		Image:        imageName,
 | 
			
		||||
		ImageID:      imageID,
 | 
			
		||||
		ID:           kubecontainer.DockerID(id).ContainerID(),
 | 
			
		||||
		ExitCode:     iResult.State.ExitCode,
 | 
			
		||||
 
 | 
			
		||||
@@ -478,7 +478,10 @@ func (f *FakeDockerClient) PullImage(image string, auth dockertypes.AuthConfig,
 | 
			
		||||
	err := f.popError("pull")
 | 
			
		||||
	if err == nil {
 | 
			
		||||
		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)))
 | 
			
		||||
	}
 | 
			
		||||
	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).
 | 
			
		||||
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)
 | 
			
		||||
@@ -106,8 +106,9 @@ func (m *imageManager) EnsureImageExists(pod *v1.Pod, container *v1.Container, p
 | 
			
		||||
		return "", msg, ErrImageInspect
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if !shouldPullImage(container, imageRef != "") {
 | 
			
		||||
		if imageRef != "" {
 | 
			
		||||
	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, glog.Info)
 | 
			
		||||
			return imageRef, "", nil
 | 
			
		||||
@@ -125,7 +126,7 @@ func (m *imageManager) EnsureImageExists(pod *v1.Pod, container *v1.Container, p
 | 
			
		||||
		return "", msg, ErrImagePullBackOff
 | 
			
		||||
	}
 | 
			
		||||
	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)
 | 
			
		||||
	imageRefWithErr := <-pullChan
 | 
			
		||||
	if imageRefWithErr.err != nil {
 | 
			
		||||
 
 | 
			
		||||
@@ -24,13 +24,13 @@ import (
 | 
			
		||||
	"k8s.io/kubernetes/pkg/util/wait"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type imageRefWithError struct {
 | 
			
		||||
type pullResult struct {
 | 
			
		||||
	imageRef string
 | 
			
		||||
	err      error
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type imagePuller interface {
 | 
			
		||||
	pullImage(kubecontainer.ImageSpec, []v1.Secret, chan<- imageRefWithError)
 | 
			
		||||
	pullImage(kubecontainer.ImageSpec, []v1.Secret, chan<- pullResult)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
var _, _ imagePuller = ¶llelImagePuller{}, &serialImagePuller{}
 | 
			
		||||
@@ -43,10 +43,10 @@ func newParallelImagePuller(imageService kubecontainer.ImageService) imagePuller
 | 
			
		||||
	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() {
 | 
			
		||||
		imageRef, err := pip.imageService.PullImage(spec, pullSecrets)
 | 
			
		||||
		pullChan <- imageRefWithError{
 | 
			
		||||
		pullChan <- pullResult{
 | 
			
		||||
			imageRef: imageRef,
 | 
			
		||||
			err:      err,
 | 
			
		||||
		}
 | 
			
		||||
@@ -70,10 +70,10 @@ func newSerialImagePuller(imageService kubecontainer.ImageService) imagePuller {
 | 
			
		||||
type imagePullRequest struct {
 | 
			
		||||
	spec        kubecontainer.ImageSpec
 | 
			
		||||
	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{
 | 
			
		||||
		spec:        spec,
 | 
			
		||||
		pullSecrets: pullSecrets,
 | 
			
		||||
@@ -84,7 +84,7 @@ func (sip *serialImagePuller) pullImage(spec kubecontainer.ImageSpec, pullSecret
 | 
			
		||||
func (sip *serialImagePuller) processImagePullRequests() {
 | 
			
		||||
	for pullRequest := range sip.pullRequests {
 | 
			
		||||
		imageRef, err := sip.imageService.PullImage(pullRequest.spec, pullRequest.pullSecrets)
 | 
			
		||||
		pullRequest.pullChan <- imageRefWithError{
 | 
			
		||||
		pullRequest.pullChan <- pullResult{
 | 
			
		||||
			imageRef: imageRef,
 | 
			
		||||
			err:      err,
 | 
			
		||||
		}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user