Skip to content

Enhance max capacity metrics - #308

Open
RadaBDimitrova wants to merge 2 commits into
gardener:masterfrom
RadaBDimitrova:enh/max-capacity-metrics
Open

Enhance max capacity metrics#308
RadaBDimitrova wants to merge 2 commits into
gardener:masterfrom
RadaBDimitrova:enh/max-capacity-metrics

Conversation

@RadaBDimitrova

@RadaBDimitrova RadaBDimitrova commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

How to categorize this PR?

/area monitoring
/kind enhancement

What this PR does / why we need it:
Improves the max-capacity metrics and consolidates the "max capacity reached" logic:

  • Adds a new max_capacity_reached Gauge that reports how many currently targeted PVCs sit at their configured max capacity. Unlike the existing max_capacity_reached_total counter, this is a live snapshot that rises and falls as PVCs enter and leave the max-capacity state. It is reset to 0 when there are no PVCAs to reconcile.
  • Moves the "already at max capacity" check into shouldResizePVC, so a PVC at max is detected up front and skipped cleanly (with the MaxCapacityReached warning event and resizing condition) instead of being handled inside resizePVC, where only actually resizable PVCs should be able to enter.
  • Fixes the semantics of the max_capacity_reached_total counter so it increments once when a resize of a PVC leads to it reaching max capacity, rather than on every reconcile while the PVC continues to sit at max. Now it only increases if the max capacity is reached or if the max capacity was augmented and was reached again.

Which issue(s) this PR fixes:
Part of #88

Special notes for your reviewer:
go.mod picks up github.com/kylelemons/godebug as an indirect dependency.
/cc @Kostov6 @plkokanov

Release note:

Add a new `max_capacity_reached` Gauge reporting how many targeted PVCs are currently at their configured max capacity. The `max_capacity_reached_total` counter now increments only once per resize-to-max instead of on every reconcile.

@RadaBDimitrova
RadaBDimitrova requested a review from a team as a code owner July 27, 2026 12:13
@gardener-prow
gardener-prow Bot requested review from Kostov6 and plkokanov July 27, 2026 12:13
@gardener-prow gardener-prow Bot added area/monitoring Monitoring (including availability monitoring and alerting) related kind/enhancement Enhancement, improvement, extension labels Jul 27, 2026
@gardener-prow

gardener-prow Bot commented Jul 27, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign radabdimitrova for approval. For more information see the Code Review Process.

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

Details Needs approval from an approver in each of these files:

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

@gardener-prow gardener-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. labels Jul 27, 2026

@Kostov6 Kostov6 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Initial review + a question:
Should we adapt the e2e test to check for those metrics if they are correctly calculated?
Maybe if it requires a lot of complexity this check is not worth it

Comment thread internal/periodic/periodic.go Outdated
Comment thread internal/utils/utils.go Outdated
Comment thread go.mod
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Where does this come from?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

From my understanding the changes in metrics.go that use testutils helpers directly from github.com/prometheus/client_golang/prometheus/testutil (which requires godebug) trigger this change. Since the package transitively needs godebug and became part of the build graph, go mod tidy started recording it explicitly in go.mod with the // indirect marker, even though we already have the direct dependency.

@RadaBDimitrova

RadaBDimitrova commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Should we adapt the e2e test to check for those metrics if they are correctly calculated?
Maybe if it requires a lot of complexity this check is not worth it

You're right, it would be too complex - the e2e scripts spin up kind and check actual PVC resize behavior. Asserting metric values there would mean scraping the metrics endpoint from inside the cluster, adding polling/timing flakiness for a value the existing unit tests already cover. Not worth it to add the complexity (and slowing down of the e2e tests) imo.

@plkokanov plkokanov self-assigned this Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/monitoring Monitoring (including availability monitoring and alerting) related cla: yes Indicates the PR's author has signed the cla-assistant.io CLA. kind/enhancement Enhancement, improvement, extension 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.

3 participants