[COST-7401] Wasted Cost Fix#6029
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds a new architectural document, solution-options-and-limitations.md, which analyzes limitations in efficiency score calculations like aggregation bias and cost double-counting. It also updates the README and changelog. Feedback suggests targeting summary tables like OCPPodSummaryP for proposed fixes to align with reporting logic and removing tool-specific IDE references to keep documentation tool-agnostic.
ed0a583 to
4536352
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6029 +/- ##
=====================================
Coverage 94.3% 94.3%
=====================================
Files 362 362
Lines 32029 32028 -1
Branches 3522 3524 +2
=====================================
Hits 30218 30218
Misses 1174 1174
+ Partials 637 636 -1 🚀 New features to boost your workflow:
|
|
/retest |
|
🤖 CI Triager — Diagnosis Check: Red Hat Konflux / koku-ci / koku The test expects Action: The OCP compute reports handler should not include Generated automatically. Review before applying. |
|
🤖 CI Triager — Diagnosis Check: Red Hat Konflux / koku-ci / koku Action: Re-trigger the Konflux CI pipeline (e.g., via Generated automatically. Review before applying. |
koku-ci-triager-bot
left a comment
There was a problem hiding this comment.
🤖 CI Triager Suggestion
Check: Units - 3.11
Root cause: Two bugs in query_handler.py introduced by this PR cause three test failures:
_format_query_response()unconditionally addstotal_score: {}to all OCP reports — the tests require it to be absent from cost and volume reports.- The
should_compute=Falsebranch (multi-group-by) popswasted_costfromquery_sum, buttest_efficiency_score_multi_group_by_omits_efficiency_percentexpectswasted_costto still appear intotal_score(it is a plain SUM, valid regardless of group-by cardinality).
Accept each suggestion below with one click.
| self.query_sum = self._pack_data_object(self.query_sum, **self._mapper.PACK_DEFINITIONS) | ||
| if "score" in self.query_sum: | ||
| self.query_sum["total_score"] = self.query_sum.pop("score") | ||
| self.query_sum["total_score"] = self.query_sum.pop("score", {}) |
There was a problem hiding this comment.
total_score must only be injected for compute (cpu/memory) reports. Cost and volume reports have no efficiency score, so this key should be absent entirely.
| self.query_sum["total_score"] = self.query_sum.pop("score", {}) | |
| if self._report_type in ("cpu", "memory"): | |
| self.query_sum["total_score"] = self.query_sum.pop("score", {}) | |
| else: | |
| self.query_sum.pop("score", None) |
| else: | ||
| query_sum.pop("usage_efficiency", None) | ||
| query_sum.pop("wasted_cost", None) | ||
| query_sum.pop("wasted_cost_units", None) |
There was a problem hiding this comment.
wasted_cost is a simple aggregate SUM and is meaningful even when multiple group-by dimensions are used. Only usage_efficiency_percent (a ratio-of-sums) should be suppressed for multi-group-by. Keep wasted_cost and its units so the packing step can include it in total_score.
| else: | |
| query_sum.pop("usage_efficiency", None) | |
| query_sum.pop("wasted_cost", None) | |
| query_sum.pop("wasted_cost_units", None) | |
| else: | |
| query_sum.pop("usage_efficiency", None) | |
| query_sum["wasted_cost_units"] = self.currency |
Jira Ticket
COST-####
Description
This change will ...
Testing
Release Notes