Skip to content

Replace container-stats with golang client #2188

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

Merged
merged 9 commits into from
Jul 4, 2025

Conversation

erthalion
Copy link
Contributor

@erthalion erthalion commented Jun 20, 2025

Description

Currently we use a separate container to capture Collector container
performance stats. This container mounts docker/podman socket and uses
corresponding cli to get the data. But in some cases (e.g. SUSE) we can't mount
the socket, hence the approach doesn't work.

Use CRI/Docker API clients to get container stats information instead. This is
more direct approach, which allows to trim number of containers and overall
tests churn. The stats capturing is implemented as a cancelable background go
routine, which is started/stopped accordingly to start/stop of the Collector
container.

One side effect of this approach is different reporting units. Previously we
were reporting data in human readable form (megabytes or cpu utilization
percentage), now it's going to be more prometheus style -- bytes and millicores
used. Since the idea is to compare stats before different commits, I don't
think it's worth the effort to convert the numbers to keep the original format.

Note that docker go package bump is needed to use some functionality.

On top of that fix small anomaly -- ProcfsScraper test was using executor
object directly, instead of going through a getter.

Checklist

  • Investigated and inspected CI test results
    - [ ] Updated documentation accordingly

Automated testing
- [ ] Added unit tests
- [ ] Added integration tests
- [ ] Added regression tests

CI is sufficient.

Testing Performed

Running TestCollectorStartup and verifying stats.

@codecov-commenter
Copy link

codecov-commenter commented Jun 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.83%. Comparing base (614e6c5) to head (69f6742).
Report is 10 commits behind head on master.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2188   +/-   ##
=======================================
  Coverage   28.83%   28.83%           
=======================================
  Files          96       96           
  Lines        5799     5799           
  Branches     2551     2551           
=======================================
  Hits         1672     1672           
  Misses       3408     3408           
  Partials      719      719           
Flag Coverage Δ
collector-unit-tests 28.83% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Use CRI/Docker API clients to get container stats information, instead
of spinnig up a new container (which can fail to mount docker socket and
thus provide no information).
@erthalion erthalion force-pushed the feature/container-stats-via-api branch from 4dfd831 to 0518786 Compare June 23, 2025 12:23
@erthalion
Copy link
Contributor Author

/test

@erthalion erthalion marked this pull request as ready for review June 24, 2025 08:28
@erthalion erthalion requested a review from a team as a code owner June 24, 2025 08:28
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @erthalion - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Collaborator

@Molter73 Molter73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few comments, I'm a bit worried about the synchronization aspect of the array of stats, though I might be worrying too much.

@erthalion erthalion force-pushed the feature/container-stats-via-api branch from 6ac3cba to b966ef2 Compare June 27, 2025 15:38
@erthalion erthalion force-pushed the feature/container-stats-via-api branch 2 times, most recently from d6ef382 to de49422 Compare June 30, 2025 15:18
@erthalion erthalion force-pushed the feature/container-stats-via-api branch from de49422 to 69f6742 Compare July 1, 2025 14:22
Copy link
Collaborator

@Molter73 Molter73 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@erthalion erthalion merged commit 283c78a into master Jul 4, 2025
64 of 67 checks passed
@erthalion erthalion deleted the feature/container-stats-via-api branch July 4, 2025 09:29
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.

3 participants