Skip to content

Commit

Permalink
add duration to image pulling event
Browse files Browse the repository at this point in the history
  • Loading branch information
SataQiu committed May 29, 2020
1 parent c8ceeed commit f1729b0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/kubelet/images/image_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package images

import (
"fmt"
"time"

dockerref "github.com/docker/distribution/reference"
v1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -138,6 +139,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), klog.Info)
startTime := time.Now()
pullChan := make(chan pullResult)
m.puller.pullImage(spec, pullSecrets, pullChan, podSandboxConfig)
imagePullResult := <-pullChan
Expand All @@ -151,7 +153,7 @@ func (m *imageManager) EnsureImageExists(pod *v1.Pod, container *v1.Container, p

return "", imagePullResult.err.Error(), ErrImagePull
}
m.logIt(ref, v1.EventTypeNormal, events.PulledImage, logPrefix, fmt.Sprintf("Successfully pulled image %q", container.Image), klog.Info)
m.logIt(ref, v1.EventTypeNormal, events.PulledImage, logPrefix, fmt.Sprintf("Successfully pulled image %q in %v", container.Image, time.Since(startTime)), klog.Info)
m.backOff.GC()
return imagePullResult.imageRef, "", nil
}
Expand Down

0 comments on commit f1729b0

Please sign in to comment.