mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 18:31:15 +00:00
Merge pull request #111772 from pacoxu/image-pull-time
kubelet: make the image pull time more accurate in event
This commit is contained in:
commit
43a2bb4df4
@ -164,8 +164,7 @@ func (m *imageManager) EnsureImageExists(ctx context.Context, pod *v1.Pod, conta
|
|||||||
|
|
||||||
return "", imagePullResult.err.Error(), ErrImagePull
|
return "", imagePullResult.err.Error(), ErrImagePull
|
||||||
}
|
}
|
||||||
m.podPullingTimeRecorder.RecordImageFinishedPulling(pod.UID)
|
m.logIt(ref, v1.EventTypeNormal, events.PulledImage, logPrefix, fmt.Sprintf("Successfully pulled image %q in %v (%v including waiting)", container.Image, imagePullResult.pullDuration, time.Since(startTime)), 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()
|
m.backOff.GC()
|
||||||
return imagePullResult.imageRef, "", nil
|
return imagePullResult.imageRef, "", nil
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import (
|
|||||||
type pullResult struct {
|
type pullResult struct {
|
||||||
imageRef string
|
imageRef string
|
||||||
err error
|
err error
|
||||||
|
pullDuration time.Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
type imagePuller interface {
|
type imagePuller interface {
|
||||||
@ -47,10 +48,12 @@ func newParallelImagePuller(imageService kubecontainer.ImageService) imagePuller
|
|||||||
|
|
||||||
func (pip *parallelImagePuller) pullImage(ctx context.Context, spec kubecontainer.ImageSpec, pullSecrets []v1.Secret, pullChan chan<- pullResult, podSandboxConfig *runtimeapi.PodSandboxConfig) {
|
func (pip *parallelImagePuller) pullImage(ctx context.Context, spec kubecontainer.ImageSpec, pullSecrets []v1.Secret, pullChan chan<- pullResult, podSandboxConfig *runtimeapi.PodSandboxConfig) {
|
||||||
go func() {
|
go func() {
|
||||||
|
startTime := time.Now()
|
||||||
imageRef, err := pip.imageService.PullImage(ctx, spec, pullSecrets, podSandboxConfig)
|
imageRef, err := pip.imageService.PullImage(ctx, spec, pullSecrets, podSandboxConfig)
|
||||||
pullChan <- pullResult{
|
pullChan <- pullResult{
|
||||||
imageRef: imageRef,
|
imageRef: imageRef,
|
||||||
err: err,
|
err: err,
|
||||||
|
pullDuration: time.Since(startTime),
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
@ -89,10 +92,12 @@ func (sip *serialImagePuller) pullImage(ctx context.Context, spec kubecontainer.
|
|||||||
|
|
||||||
func (sip *serialImagePuller) processImagePullRequests() {
|
func (sip *serialImagePuller) processImagePullRequests() {
|
||||||
for pullRequest := range sip.pullRequests {
|
for pullRequest := range sip.pullRequests {
|
||||||
|
startTime := time.Now()
|
||||||
imageRef, err := sip.imageService.PullImage(pullRequest.ctx, pullRequest.spec, pullRequest.pullSecrets, pullRequest.podSandboxConfig)
|
imageRef, err := sip.imageService.PullImage(pullRequest.ctx, pullRequest.spec, pullRequest.pullSecrets, pullRequest.podSandboxConfig)
|
||||||
pullRequest.pullChan <- pullResult{
|
pullRequest.pullChan <- pullResult{
|
||||||
imageRef: imageRef,
|
imageRef: imageRef,
|
||||||
err: err,
|
err: err,
|
||||||
|
pullDuration: time.Since(startTime),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user