8000 Merge pull request #120914 from kannon92/kubelet-disk-api-cri-update · kubernetes/kubernetes@413b15a · GitHub
[go: up one dir, main page]

Skip to content

Commit 413b15a

Browse files
authored
Merge pull request #120914 from kannon92/kubelet-disk-api-cri-update
Kubelet disk api cri update
2 parents f652e61 + 8ae0d39 commit 413b15a

File tree

10 files changed

+538
-441
lines changed

10 files changed

+538
-441
lines changed

pkg/kubelet/cri/remote/fake/fake_image_service.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ func (f *RemoteRuntime) RemoveImage(ctx context.Context, req *kubeapi.RemoveImag
7272

7373
// ImageFsInfo returns information of the filesystem that is used to store images.
7474
func (f *RemoteRuntime) ImageFsInfo(ctx context.Context, req *kubeapi.ImageFsInfoRequest) (*kubeapi.ImageFsInfoResponse, error) {
75-
fsUsage, err := f.ImageService.ImageFsInfo(ctx)
75+
resp, err := f.ImageService.ImageFsInfo(ctx)
7676
if err != nil {
7777
return nil, err
7878
}
7979

80-
return &kubeapi.ImageFsInfoResponse{ImageFilesystems: fsUsage}, nil
80+
return resp, nil
8181
}

pkg/kubelet/cri/remote/remote_image.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (r *remoteImageService) RemoveImage(ctx context.Context, image *runtimeapi.
217217
}
218218

219219
// ImageFsInfo returns information of the filesystem that is used to store images.
220-
func (r *remoteImageService) ImageFsInfo(ctx context.Context) ([]*runtimeapi.FilesystemUsage, error) {
220+
func (r *remoteImageService) ImageFsInfo(ctx context.Context) (*runtimeapi.ImageFsInfoResponse, error) {
221221
// Do not set timeout, because `ImageFsInfo` takes time.
222222
// TODO(random-liu): Should we assume runtime should cache the result, and set timeout here?
223223
ctx, cancel := context.WithCancel(ctx)
@@ -226,11 +226,11 @@ func (r *remoteImageService) ImageFsInfo(ctx context.Context) ([]*runtimeapi.Fil
226226
return r.imageFsInfoV1(ctx)
227227
}
228228

229-
func (r *remoteImageService) imageFsInfoV1(ctx context.Context) ([]*runtimeapi.FilesystemUsage, error) {
229+
func (r *remoteImageService) imageFsInfoV1(ctx context.Context) (*runtimeapi.ImageFsInfoResponse, error) {
230230
resp, err := r.imageClient.ImageFsInfo(ctx, &runtimeapi.ImageFsInfoRequest{})
231231
if err != nil {
232232
klog.ErrorS(err, "ImageFsInfo from image service failed")
233233
return nil, err
234234
}
235-
return resp.GetImageFilesystems(), nil
235+
return resp, nil
236236
}

pkg/kubelet/kuberuntime/instrumented_services.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ func (in instrumentedImageManagerService) RemoveImage(ctx context.Context, image
317317
return err
318318
}
319319

320-
func (in instrumentedImageManagerService) ImageFsInfo(ctx context.Context) ([]*runtimeapi.FilesystemUsage, error) {
320+
func (in instrumentedImageManagerService) ImageFsInfo(ctx context.Context) (*runtimeapi.ImageFsInfoResponse, error) {
321321
const operation = "image_fs_info"
322322
defer recordOperation(operation, time.Now())
323323

pkg/kubelet/stats/cri_stats_provider.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -395,10 +395,10 @@ func (p *criStatsProvider) ImageFsStats(ctx context.Context) (*statsapi.FsStats,
395395
// return the first one.
396396
//
397397
// TODO(yguo0905): Support returning stats of multiple image filesystems.
398-
if len(resp) == 0 {
398+
if len(resp.GetImageFilesystems()) == 0 {
399399
return nil, fmt.Errorf("imageFs information is unavailable")
400400
}
401-
fs := resp[0]
401+
fs := resp.GetImageFilesystems()[0]
402402
s := &statsapi.FsStats{
403403
Time: metav1.NewTime(time.Unix(0, fs.Timestamp)),
404404
UsedBytes: &fs.UsedBytes.Value,
@@ -430,7 +430,7 @@ func (p *criStatsProvider) ImageFsDevice(ctx context.Context) (string, error) {
430430
if err != nil {
431431
return "", err
432432
}
433-
for _, fs := range resp {
433+
for _, fs := range resp.GetImageFilesystems() {
434434
fsInfo, err := p.getFsInfo(fs.GetFsId())
435435
if err != nil {
436436
return "", fmt.Errorf("get filesystem info: %w", err)

staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.pb.go

Lines changed: 501 additions & 427 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

staging/src/k8s.io/cri-api/pkg/apis/runtime/v1/api.proto

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1583,6 +1583,11 @@ message WindowsFilesystemUsage {
15831583
message ImageFsInfoResponse {
15841584
// Information of image filesystem(s).
15851585
repeated FilesystemUsage image_filesystems = 1;
1586+
// Information of container filesystem(s).
1587+
// This is an optional field, may be used for example if container and image
1588+
// storage are separated.
1589+
// Default will be to return this as empty.
1590+
repeated FilesystemUsage container_filesystems = 2;
15861591
}
15871592

15881593
message ContainerStatsRequest{

staging/src/k8s.io/cri-api/pkg/apis/services.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,6 @@ type ImageManagerService interface {
131131
PullImage(ctx context.Context, image *runtimeapi.ImageSpec, auth *runtimeapi.AuthConfig, podSandboxConfig *runtimeapi.PodSandboxConfig) (string, error)
132132
// RemoveImage removes the image.
133133
RemoveImage(ctx context.Context, image *runtimeapi.ImageSpec) error
134-
// ImageFsInfo returns information of the filesystem that is used to store images.
135-
ImageFsInfo(ctx context.Context) ([]*runtimeapi.FilesystemUsage, error)
134+
// ImageFsInfo returns information of the filesystem(s) used to store the read-only layers and the writeable layer.
135+
ImageFsInfo(ctx context.Context) (*runtimeapi.ImageFsInfoResponse, error)
136136
}

staging/src/k8s.io/cri-api/pkg/apis/testing/fake_image_service.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ type FakeImageService struct {
3838

3939
pulledImages []*pulledImage
4040

41-
FakeFilesystemUsage []*runtimeapi.FilesystemUsage
41+
FakeFilesystemUsage []*runtimeapi.FilesystemUsage
42+
FakeContainerFilesystemUsage []*runtimeapi.FilesystemUsage
4243
}
4344

4445
// SetFakeImages sets the list of fake images for the FakeImageService.
@@ -93,6 +94,14 @@ func (r *FakeImageService) SetFakeFilesystemUsage(usage []*runtimeapi.Filesystem
9394
r.FakeFilesystemUsage = usage
9495
}
9596

97+
// SetFakeFilesystemUsage sets the FilesystemUsage for FakeImageService.
98+
func (r *FakeImageService) SetFakeContainerFilesystemUsage(usage []*runtimeapi.FilesystemUsage) {
99+
r.Lock()
100+
defer r.Unlock()
101+
102+
r.FakeContainerFilesystemUsage = usage
103+
}
104+
96105
// NewFakeImageService creates a new FakeImageService.
97106
func NewFakeImageService() *FakeImageService {
98107
return &FakeImageService{
@@ -218,7 +227,7 @@ func (r *FakeImageService) RemoveImage(_ context.Context, image *runtimeapi.Imag
218227
}
219228

220229
// ImageFsInfo returns information of the filesystem that is used to store images.
221-
func (r *FakeImageService) ImageFsInfo(_ context.Context) ([]*runtimeapi.FilesystemUsage, error) {
230+
func (r *FakeImageService) ImageFsInfo(_ context.Context) (*runtimeapi.ImageFsInfoResponse, error) {
222231
r.Lock()
223232
defer r.Unlock()
224233

@@ -227,7 +236,10 @@ func (r *FakeImageService) ImageFsInfo(_ context.Context) ([]*runtimeapi.Filesys
227236
return nil, err
228237
}
229238

230-
return r.FakeFilesystemUsage, nil
239+
return &runtimeapi.ImageFsInfoResponse{
240+
ImageFilesystems: r.FakeFilesystemUsage,
241+
ContainerFilesystems: r.FakeContainerFilesystemUsage,
242+
}, nil
231243
}
232244

233245
// AssertImagePulledWithAuth validates whether the image was pulled with auth and asserts if it wasn't.

staging/src/k8s.io/kubelet/pkg/apis/stats/v1alpha1/types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,11 @@ type RuntimeStats struct {
8383
// Usage here refers to the total number of bytes occupied by images on the filesystem.
8484
// +optional
8585
ImageFs *FsStats `json:"imageFs,omitempty"`
86+
// Stats about the underlying filesystem where container's writeable layer is stored.
87+
// This filesystem could be the same as the primary (root) filesystem or the ImageFS.
88+
// Usage here refers to the total number of bytes occupied by the writeable layer on the filesystem.
89+
// +optional
90+
ContainerFs *FsStats `json:"containerFs,omitempty"`
8691
}
8792

8893
const (

test/e2e_node/summary_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ var _ = SIGDescribe("Summary API [NodeConformance]", func() {
317317
"Inodes": bounded(1e4, 1e8),
318318
"InodesUsed": bounded(0, 1e8),
319319
}),
320+
"ContainerFs": gomega.BeNil(),
320321
}),
321322
"Rlimit": ptrMatchAllFields(gstruct.Fields{
322323
"Time": recent(maxStatsAge),

0 commit comments

Comments
 (0)
0