mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 23:15:14 +00:00
Merge pull request #25361 from yifan-gu/imagestates
rkt: Implement ImageStats() for rkt.
This commit is contained in:
commit
095e262461
@ -227,3 +227,17 @@ func (r *Runtime) writeDockerAuthConfig(image string, credsSlice []credentialpro
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// ImageStats returns the image stat (total storage bytes).
|
||||
func (r *Runtime) ImageStats() (*kubecontainer.ImageStats, error) {
|
||||
var imageStat kubecontainer.ImageStats
|
||||
listResp, err := r.apisvc.ListImages(context.Background(), &rktapi.ListImagesRequest{})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("couldn't list images: %v", err)
|
||||
}
|
||||
|
||||
for _, image := range listResp.Images {
|
||||
imageStat.TotalStorageBytes = imageStat.TotalStorageBytes + uint64(image.Size)
|
||||
}
|
||||
return &imageStat, nil
|
||||
}
|
||||
|
@ -1771,8 +1771,3 @@ func (r *Runtime) GetPodStatus(uid types.UID, name, namespace string) (*kubecont
|
||||
|
||||
return podStatus, nil
|
||||
}
|
||||
|
||||
// FIXME: I need to be implemented.
|
||||
func (r *Runtime) ImageStats() (*kubecontainer.ImageStats, error) {
|
||||
return &kubecontainer.ImageStats{}, nil
|
||||
}
|
||||
|
@ -1382,3 +1382,18 @@ func TestLifeCycleHooks(t *testing.T) {
|
||||
runner.Reset()
|
||||
}
|
||||
}
|
||||
|
||||
func TestImageStats(t *testing.T) {
|
||||
fr := newFakeRktInterface()
|
||||
rkt := &Runtime{apisvc: fr}
|
||||
|
||||
fr.images = []*rktapi.Image{
|
||||
{Size: 100},
|
||||
{Size: 200},
|
||||
{Size: 300},
|
||||
}
|
||||
|
||||
result, err := rkt.ImageStats()
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, result, &kubecontainer.ImageStats{TotalStorageBytes: 600})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user