Skip to content

fix: prometheus increase error - #92

Merged
InftyAI-Agent merged 2 commits into
InftyAI:mainfrom
kerthcet:feat/support-logging
Sep 4, 2026
Merged

fix: prometheus increase error#92
InftyAI-Agent merged 2 commits into
InftyAI:mainfrom
kerthcet:feat/support-logging

Conversation

@kerthcet

@kerthcet kerthcet commented Sep 4, 2026

Copy link
Copy Markdown
Member

What this PR does / why we need it

Which issue(s) this PR fixes

Fixes #

Special notes for your reviewer

Does this PR introduce a user-facing change?


Signed-off-by: kerthcet <kerthcet@gmail.com>
Signed-off-by: kerthcet <kerthcet@gmail.com>
Copilot AI lite review requested due to automatic review settings September 4, 2026 22:19
@InftyAI-Agent InftyAI-Agent added needs-triage Indicates an issue or PR lacks a label and requires one. needs-priority Indicates a PR lacks a label and requires one. do-not-merge/needs-kind Indicates a PR lacks a label and requires one. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 4, 2026

Copilot AI 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.

🟡 Changes recommended

Baseline seeding is now only triggered via markPhase (Pod-present path), which can miss already-anchored claims entering teardown with no served Pod after restart/hand-off, allowing settleFinalCost to book a first-sample charge that increase() may not observe.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR aims to prevent Prometheus increase()/rate() from missing cost when a counter series’ first observed sample already contains money, by reworking how cost “baseline” (zero-valued) series are published for nebula_cost_usd_total.

Changes:

  • Move baseline seeding away from a once-at-startup CostAccrual.Start() pass and into NodeClaimReconciler.markPhase() (level-triggered reseeding behavior).
  • Refactor and rename the ungated price parsing helper (finalRateparsePrice) and update call sites/comments.
  • Update tests and documentation to reflect the new seeding approach and its limitations.
File summaries
File Description
README.md Small wording tweak in the features list.
pkg/metrics/cost.go Updates metric comments to point at the new seeding approach (seedClaimBaseline / parsePrice).
internal/controller/nodeclaim_controller.go Seeds cost baselines after a successful status patch and on subsequent passes.
internal/controller/cost_accrual.go Removes startup seeding, introduces seedClaimBaseline, and renames finalRateparsePrice.
internal/controller/cost_accrual_test.go Reworks tests to validate per-reconcile baseline seeding and restart reseeding behavior.
docs/metrics.md Updates documentation to describe the new level-triggered baseline republishing model and caveats.
Review details

Suppressed comments (1)

docs/metrics.md:452

  • The statement “At a 60s scrape it will not.” is too categorical: with accrualInterval = 1m and scrape interval also 60s, whether a scrape lands between baseline publish and the first booked window is timing-dependent. This section should describe the reliability/guarantee rather than implying it never works.
  is worth nothing unless **the scrape interval is shorter than `accrualInterval`**: the gap between a
  baseline and the first window charged on it is one tick, and a scrape has to land inside it. At a
  60s scrape it will not.
  • Files reviewed: 6/6 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/controller/nodeclaim_controller.go
Comment thread docs/metrics.md
@kerthcet

kerthcet commented Sep 4, 2026

Copy link
Copy Markdown
Member Author

/lgtm
/kind bug

@InftyAI-Agent InftyAI-Agent added lgtm Looks good to me, indicates that a PR is ready to be merged. bug Categorizes issue or PR as related to a bug. and removed do-not-merge/needs-kind Indicates a PR lacks a label and requires one. labels Sep 4, 2026

@InftyAI-Agent InftyAI-Agent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved: PR has both lgtm and approved labels

@InftyAI-Agent InftyAI-Agent left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved: PR has both lgtm and approved labels

@InftyAI-Agent
InftyAI-Agent merged commit 8d9f680 into InftyAI:main Sep 4, 2026
41 of 43 checks passed
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. bug Categorizes issue or PR as related to a bug. lgtm Looks good to me, indicates that a PR is ready to be merged. needs-priority Indicates a PR lacks a label and requires one. needs-triage Indicates an issue or PR lacks a label and requires one.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants