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

MGMT-19529: Send metrics about disk usage #7178

Merged
merged 1 commit into from
Jan 20, 2025

Conversation

paul-maidment
Copy link
Contributor

When the installer cache is used (by calling get) we would like to take a sample of the disk usage in the cache directory. This PR introduces two metrics, one which is a gauge of the percentage of disk space used and the other which is a histogram of usage in GiB

As part of this PR, I have introduced a filesystem helper class to mock some filesystem functions.

The broader intent is to do this more universally but for now I am just mocking the functions necessary to gather disk usage information.

The ticket for the broader effort is here https://issues.redhat.com/browse/MGMT-19683

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Jan 12, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Jan 12, 2025

@paul-maidment: This pull request references MGMT-19529 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "4.19.0" version, but no target version was set.

In response to this:

When the installer cache is used (by calling get) we would like to take a sample of the disk usage in the cache directory. This PR introduces two metrics, one which is a gauge of the percentage of disk space used and the other which is a histogram of usage in GiB

As part of this PR, I have introduced a filesystem helper class to mock some filesystem functions.

The broader intent is to do this more universally but for now I am just mocking the functions necessary to gather disk usage information.

The ticket for the broader effort is here https://issues.redhat.com/browse/MGMT-19683

List all the issues related to this PR

  • New Feature
  • Enhancement
  • Bug fix
  • Tests
  • Documentation
  • CI/CD

What environments does this code impact?

  • Automation (CI, tools, etc)
  • Cloud
  • Operator Managed Deployments
  • None

How was this code tested?

  • assisted-test-infra environment
  • dev-scripts environment
  • Reviewer's test appreciated
  • Waiting for CI to do a full test run
  • Manual (Elaborate on how it was tested)
  • No tests needed

Checklist

  • Title and description added to both, commit and PR.
  • Relevant issues have been associated (see CONTRIBUTING guide)
  • This change does not require a documentation update (docstring, docs, README, etc)
  • Does this change include unit-tests (note that code changes require unit-tests)

Reviewers Checklist

  • Are the title and description (in both PR and commit) meaningful and clear?
  • Is there a bug required (and linked) for this change?
  • Should this PR be backported?

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 12, 2025
@openshift-ci openshift-ci bot requested review from danielerez and pastequo January 12, 2025 13:23
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 12, 2025
Copy link

codecov bot commented Jan 12, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 67.83%. Comparing base (8699842) to head (def01b8).
Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
internal/metrics/disk_stats_helper.go 73.91% 3 Missing and 3 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7178      +/-   ##
==========================================
+ Coverage   67.73%   67.83%   +0.10%     
==========================================
  Files         296      298       +2     
  Lines       40290    40561     +271     
==========================================
+ Hits        27290    27516     +226     
- Misses      10544    10577      +33     
- Partials     2456     2468      +12     
Files with missing lines Coverage Δ
internal/metrics/directory_usage_collector.go 100.00% <100.00%> (ø)
internal/metrics/metricsManager.go 70.49% <100.00%> (+0.34%) ⬆️
internal/metrics/disk_stats_helper.go 73.91% <73.91%> (ø)

... and 16 files with indirect coverage changes

@paul-maidment paul-maidment force-pushed the MGMT-19529 branch 2 times, most recently from e5bec23 to 4139d2c Compare January 12, 2025 16:20
@openshift-ci openshift-ci bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 13, 2025
@rccrdpccl
Copy link
Contributor

Nice approach, do you think there is an easy way to add a small test?

@openshift-ci openshift-ci bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 14, 2025
@paul-maidment paul-maidment force-pushed the MGMT-19529 branch 5 times, most recently from 80cc9c9 to d05c285 Compare January 14, 2025 15:20
@paul-maidment
Copy link
Contributor Author

/retest

internal/metrics/directory_usage_collector.go Outdated Show resolved Hide resolved
internal/metrics/metricsManager.go Outdated Show resolved Hide resolved
internal/metrics/metricsManager.go Outdated Show resolved Hide resolved
cmd/main.go Outdated Show resolved Hide resolved
cmd/main.go Outdated Show resolved Hide resolved
@paul-maidment
Copy link
Contributor Author

/test okd-scos-e2e-aws-ovn

1 similar comment
@paul-maidment
Copy link
Contributor Author

/test okd-scos-e2e-aws-ovn

On scrape (when responding to the /metrics endpoint) prometheus will run every collector that is registered.
This collector exists to gather disk usage stats for a specified directory.
In this case, the working directory of assisted-service
@rccrdpccl
Copy link
Contributor

/retest
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Jan 20, 2025
Copy link

openshift-ci bot commented Jan 20, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: paul-maidment, rccrdpccl

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [paul-maidment,rccrdpccl]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot
Copy link

/retest-required

Remaining retests: 0 against base HEAD aee2048 and 2 for PR HEAD def01b8 in total

@paul-maidment
Copy link
Contributor Author

/test okd-scos-e2e-aws-ovn

@openshift-merge-bot openshift-merge-bot bot merged commit 63132f1 into openshift:master Jan 20, 2025
16 of 17 checks passed
@openshift-bot
Copy link
Contributor

[ART PR BUILD NOTIFIER]

Distgit: ose-agent-installer-api-server
This PR has been included in build ose-agent-installer-api-server-container-v4.19.0-202501210009.p0.g63132f1.assembly.stream.el9.
All builds following this will include this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants