Skip to content

Conversation

nenych
Copy link

@nenych nenych commented Sep 16, 2025

Use the CRI stats api to gather the containerd disk usage metrics

* Add CRI stats API integration for containerd filesystem usage

- Enable filesystem stats collection using CRI ContainerStats API
- Replace inefficient directory walking with proper CRI stats calls
- Add memory-efficient caching (30s) to minimize API overhead
- Support containerd 2.x with k8s.io/cri-api dependency
- Only collect stats for regular containers (exclude sandbox containers)
- Maintain backward compatibility and existing design patterns

* Fix Docker build: ensure dependencies are resolved after adding source code

- Add go mod download && go mod tidy step after ADD . .
- This ensures k8s.io/cri-api dependency is properly resolved in Docker build context

* Add explicit k8s.io/cri-api dependency in Dockerfile

- Explicitly get k8s.io/cri-api@v0.29.0 before build step
- This ensures the dependency is available in Docker build context

* Add k8s.io/cri-api dependency to cmd module

- Add k8s.io/cri-api v0.29.0 to cmd/go.mod
- Run go mod tidy to update cmd/go.sum
- This fixes Docker build module resolution for CRI stats API

* Remove unwanted Dockerfile module download

* Update k8s.io/cri-api to v0.34.1

- Upgrade from v0.29.0 to v0.34.1 for latest CRI API features
- Update both root and cmd module dependencies
- Run go mod tidy to update checksums

* Fix tests

* Update collectFilesystemUsage function

---------

Co-authored-by: nenych <mykhailo.nenych@aspira.global>
Copy link

google-cla bot commented Sep 16, 2025

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant