docker_image_windows.go 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // +build windows
  2. /*
  3. Copyright 2016 The Kubernetes Authors.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. */
  14. package dockershim
  15. import (
  16. "context"
  17. "time"
  18. "k8s.io/klog"
  19. runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"
  20. "k8s.io/kubernetes/pkg/kubelet/winstats"
  21. )
  22. // ImageFsInfo returns information of the filesystem that is used to store images.
  23. func (ds *dockerService) ImageFsInfo(_ context.Context, _ *runtimeapi.ImageFsInfoRequest) (*runtimeapi.ImageFsInfoResponse, error) {
  24. info, err := ds.client.Info()
  25. if err != nil {
  26. klog.Errorf("Failed to get docker info: %v", err)
  27. return nil, err
  28. }
  29. statsClient := &winstats.StatsClient{}
  30. fsinfo, err := statsClient.GetDirFsInfo(info.DockerRootDir)
  31. if err != nil {
  32. klog.Errorf("Failed to get dir fsInfo for %q: %v", info.DockerRootDir, err)
  33. return nil, err
  34. }
  35. filesystems := []*runtimeapi.FilesystemUsage{
  36. {
  37. Timestamp: time.Now().UnixNano(),
  38. UsedBytes: &runtimeapi.UInt64Value{Value: fsinfo.Usage},
  39. FsId: &runtimeapi.FilesystemIdentifier{
  40. Mountpoint: info.DockerRootDir,
  41. },
  42. },
  43. }
  44. return &runtimeapi.ImageFsInfoResponse{ImageFilesystems: filesystems}, nil
  45. }