Merge pull request #41733 from feiskyer/images

Automatic merge from submit-queue (batch tested with PRs 45314, 45250, 41733)

CRI: add ImageFsInfo API

**What this PR does / why we need it**:

kubelet currently relies on cadvisor to get the ImageFS info for supported runtimes, i.e., docker and rkt. This PR adds ImageFsInfo API to CRI so kubelet could get the ImageFS correctly for all runtimes.

**Which issue this PR fixes** 

First step for  #33048 ~~also reverts temporary ImageStats in #33870~~.

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
pull/6/head
Kubernetes Submit Queue 2017-05-03 18:47:04 -07:00 committed by GitHub
commit 84f41f3388
8 changed files with 1258 additions and 223 deletions

View File

@ -97,4 +97,6 @@ type ImageManagerService interface {
PullImage(image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig) (string, error)
// RemoveImage removes the image.
RemoveImage(image *runtimeapi.ImageSpec) error
// ImageFsInfo returns information of the filesystem that is used to store images.
ImageFsInfo() (*runtimeapi.FsInfo, error)
}

View File

@ -118,3 +118,13 @@ func (r *FakeImageService) RemoveImage(image *runtimeapi.ImageSpec) error {
return nil
}
// ImageFsInfo returns information of the filesystem that is used to store images.
func (r *FakeImageService) ImageFsInfo() (*runtimeapi.FsInfo, error) {
r.Lock()
defer r.Unlock()
r.Called = append(r.Called, "ImageFsInfo")
return nil, nil
}

File diff suppressed because it is too large Load Diff

View File

@ -90,6 +90,8 @@ service ImageService {
// This call is idempotent, and must not return an error if the image has
// already been removed.
rpc RemoveImage(RemoveImageRequest) returns (RemoveImageResponse) {}
// ImageFSInfo returns information of the filesystem that is used to store images.
rpc ImageFsInfo(ImageFsInfoRequest) returns (ImageFsInfoResponse) {}
}
message VersionRequest {
@ -964,3 +966,42 @@ message StatusResponse {
// Status of the Runtime.
RuntimeStatus status = 1;
}
message ImageFsInfoRequest {}
// UInt64Value is the wrapper of uint64.
message UInt64Value {
// The value.
uint64 value = 1;
}
// FsInfo contains data about filesystem usage.
message FsInfo {
// The block device name associated with the filesystem.
string device = 1;
// The root directory for the images.
string path = 2;
// CapacityBytes represents the total capacity (bytes) of the filesystems
// underlying storage.
UInt64Value capacity_bytes = 3;
// AvailableBytes represents the storage space available (bytes) for the
// filesystem.
UInt64Value available_bytes = 4;
// UsedBytes represents the bytes used for images on the filesystem.
// This may differ from the total bytes used on the filesystem and may not
// equal CapacityBytes - AvailableBytes.
UInt64Value used_bytes = 5;
// InodesCapacity represents the total inodes in the filesystem.
UInt64Value inodes_capacity = 6;
// InodesAvailable represents the free inodes in the filesystem.
UInt64Value inodes_available = 7;
// InodesUsed represents the inodes used by the images.
// This may not equal InodesCapacity - InodesAvailable because the underlying
// filesystem may also be used for purposes other than storing images.
UInt64Value inodes_used = 8;
}
message ImageFsInfoResponse {
// filesystem information of images.
FsInfo fs_info = 1;
}

View File

@ -121,3 +121,8 @@ func getImageRef(client dockertools.DockerInterface, image string) (string, erro
return img.ID, nil
}
// ImageFsInfo returns information of the filesystem that is used to store images.
func (ds *dockerService) ImageFsInfo() (*runtimeapi.FsInfo, error) {
return nil, fmt.Errorf("not implemented")
}

View File

@ -17,6 +17,7 @@ limitations under the License.
package remote
import (
"fmt"
"time"
"golang.org/x/net/context"
@ -214,3 +215,8 @@ func (d *dockerService) RemoveImage(ctx context.Context, r *runtimeapi.RemoveIma
}
return &runtimeapi.RemoveImageResponse{}, nil
}
// ImageFsInfo returns information of the filesystem that is used to store images.
func (d *dockerService) ImageFsInfo(ctx context.Context, r *runtimeapi.ImageFsInfoRequest) (*runtimeapi.ImageFsInfoResponse, error) {
return nil, fmt.Errorf("not implemented")
}

View File

@ -256,3 +256,12 @@ func (in instrumentedImageManagerService) RemoveImage(image *runtimeapi.ImageSpe
recordError(operation, err)
return err
}
func (in instrumentedImageManagerService) ImageFsInfo() (*runtimeapi.FsInfo, error) {
const operation = "image_fs_info"
defer recordOperation(operation, time.Now())
fsInfo, err := in.service.ImageFsInfo()
recordError(operation, err)
return fsInfo, nil
}

View File

@ -127,3 +127,8 @@ func (r *RemoteImageService) RemoveImage(image *runtimeapi.ImageSpec) error {
return nil
}
// ImageFsInfo returns information of the filesystem that is used to store images.
func (r *RemoteImageService) ImageFsInfo() (*runtimeapi.FsInfo, error) {
return nil, fmt.Errorf("not implemented")
}