Skip to content

Commit

Permalink
fixed printing correct image size
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar Sarkisian committed Jan 15, 2024
1 parent 0b5bcba commit 74048ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
5 changes: 3 additions & 2 deletions pkg/pullexecutor/pullexecutor.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (m *PullExecutor) StartPulling(o *PullOptions) error {
elapsed := time.Since(startTime)
metrics.ImagePullTime.WithLabelValues(metrics.Sync).Observe(elapsed.Seconds())
size := puller.ImageSize(o.Context)
o.Logger.Info("Finished pulling image", "image", o.Image, "pull-duration", elapsed, "image-size", size)
o.Logger.Info("Finished pulling image", "image", o.Image, "pull-duration", elapsed, "uncompressed-image-size", fmt.Sprintf("%.2f MiB", float64(size)/(1024.0*1024.0)))
}
pullstatus.Update(o.NamedRef, pullstatus.Pulled)
return nil
Expand Down Expand Up @@ -128,7 +128,8 @@ func (m *PullExecutor) StartPulling(o *PullOptions) error {
elapsed := time.Since(startTime)
metrics.ImagePullTime.WithLabelValues(metrics.Async).Observe(elapsed.Seconds())
size := puller.ImageSize(o.Context)
o.Logger.Info("Finished pulling image", "image", o.Image, "pull-duration", elapsed, "image-size", size)
o.Logger.Info("Finished pulling image", "image", o.Image, "pull-duration", elapsed, "uncompressed-image-size", fmt.Sprintf("%.2f MiB", float64(size)/(1024.0*1024.0)))

}
pullstatus.Update(o.NamedRef, pullstatus.Pulled)
}
Expand Down
13 changes: 5 additions & 8 deletions pkg/remoteimage/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,13 @@ type puller struct {
keyring credentialprovider.DockerKeyring
}

// Returns the size of the image that was pulled in MB(I think?) **TODO: check**
// Returns the uncompressed size of the image that was pulled in bytes
func (p puller) ImageSize(ctx context.Context) int {
imageSpec := &cri.ImageSpec{Image: p.image.String()}
return imageSpec.Size()
// info, err := p.imageSvc.ImageFsInfo(ctx, &cri.ImageFsInfoRequest{})
// if err != nil {
// return 0, err
// }

// return info.Size(), nil
imageStatusResponse, _ := p.imageSvc.ImageStatus(ctx, &cri.ImageStatusRequest{
Image: imageSpec,
})
return int(imageStatusResponse.Image.Size_)
}

func (p puller) Pull(ctx context.Context) (err error) {
Expand Down

0 comments on commit 74048ff

Please sign in to comment.