Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ContainerFilesystems to ImageFsInfoResponse #409

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add container file system usage
kinarashah committed Oct 30, 2024
commit 9f1ecfd0230c630373c650fa34dadde50663187b
13 changes: 11 additions & 2 deletions core/imagefs_linux.go
Original file line number Diff line number Diff line change
@@ -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
@@ -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()
2 changes: 1 addition & 1 deletion network/hostport/hostport_manager.go
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 2 additions & 2 deletions streaming/server.go
Original file line number Diff line number Diff line change
@@ -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.
2 changes: 1 addition & 1 deletion streaming/server_test.go
Original file line number Diff line number Diff line change
@@ -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 (
2 changes: 1 addition & 1 deletion streaming/streaming.go
Original file line number Diff line number Diff line change
@@ -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"
)