Skip to content

Commit

Permalink
add container file system usage
Browse files Browse the repository at this point in the history
  • Loading branch information
kinarashah committed Oct 30, 2024
1 parent 6249afd commit 9f1ecfd
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
13 changes: 11 additions & 2 deletions core/imagefs_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,16 @@ func (ds *dockerService) imageFsInfo() (*runtimeapi.ImageFsInfoResponse, error)
InodesUsed: &runtimeapi.UInt64Value{
Value: iNodesUsed,
},
},
},
}},
ContainerFilesystems: []*runtimeapi.FilesystemUsage{
{
Timestamp: time.Now().UnixNano(),
FsId: &runtimeapi.FilesystemIdentifier{
Mountpoint: ds.dockerRootDir,
},
UsedBytes: &runtimeapi.UInt64Value{
Value: ds.containerStatsCache.getWriteableLayer(),
},
}},
}, nil
}
11 changes: 11 additions & 0 deletions core/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,17 @@ func (cs *cstats) getContainerRWSize() uint64 {
return cs.rwLayerSize
}

func (c *containerStatsCache) getWriteableLayer() uint64 {
c.RLock()
defer c.RUnlock()

var totalLayerSize uint64
for _, stat := range c.stats {
totalLayerSize += stat.rwLayerSize
}
return totalLayerSize
}

func (c *containerStatsCache) getStats(containerID string) *cstats {
c.RLock()
defer c.RUnlock()
Expand Down
2 changes: 1 addition & 1 deletion network/hostport/hostport_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/sirupsen/logrus"
v1 "k8s.io/api/core/v1"
utilerrors "k8s.io/apimachinery/pkg/util/errors"
"k8s.io/kubernetes/pkg/util/conntrack"
"k8s.io/kubernetes/pkg/proxy/conntrack"
utiliptables "k8s.io/kubernetes/pkg/util/iptables"
"k8s.io/utils/exec"
utilnet "k8s.io/utils/net"
Expand Down
4 changes: 2 additions & 2 deletions streaming/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import (
remotecommandconsts "k8s.io/apimachinery/pkg/util/remotecommand"
"k8s.io/client-go/tools/remotecommand"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
"k8s.io/kubernetes/pkg/kubelet/cri/streaming/portforward"
remotecommandserver "k8s.io/kubernetes/pkg/kubelet/cri/streaming/remotecommand"
"k8s.io/kubelet/pkg/cri/streaming/portforward"
remotecommandserver "k8s.io/kubelet/pkg/cri/streaming/remotecommand"
)

// Server is the library interface to serve the stream requests.
Expand Down
2 changes: 1 addition & 1 deletion streaming/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import (
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/transport/spdy"
runtimeapi "k8s.io/cri-api/pkg/apis/runtime/v1"
kubeletportforward "k8s.io/kubernetes/pkg/kubelet/cri/streaming/portforward"
kubeletportforward "k8s.io/kubelet/pkg/cri/streaming/portforward"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion streaming/streaming.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
dockertypes "github.com/docker/docker/api/types"
dockercontainer "github.com/docker/docker/api/types/container"

"k8s.io/kubernetes/pkg/kubelet/cri/streaming"
"k8s.io/kubelet/pkg/cri/streaming"

"github.com/Mirantis/cri-dockerd/libdocker"
)
Expand Down

0 comments on commit 9f1ecfd

Please sign in to comment.