-
Notifications
You must be signed in to change notification settings - Fork 5
fix(recommendations/aws): flush stale on_demand_cost cache + parser visibility (closes #321) #324
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
cristim
merged 3 commits into
feat/multicloud-web-frontend
from
fix/aws-on-demand-cost-cache-flush
May 6, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...l/database/postgres/migrations/000049_invalidate_aws_recs_missing_on_demand_cost.down.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| -- No rollback for the payload rewrite: the original AWS rows lacking | ||
| -- on_demand_cost were themselves stale (pre-PR-#312 data). Reverting | ||
| -- monthly_cost from null back to those stale values would re-introduce | ||
| -- the very bug this migration fixes. The correct values will be written | ||
| -- on the next scheduled collection. |
30 changes: 30 additions & 0 deletions
30
...nal/database/postgres/migrations/000049_invalidate_aws_recs_missing_on_demand_cost.up.sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| -- Rewrite stale pre-PR-#312 AWS recommendation payloads that lack | ||
| -- on_demand_cost in their JSONB payload. | ||
| -- | ||
| -- PR #312 added on_demand_cost population for AWS Savings Plans rows | ||
| -- (via CurrentAverageHourlyOnDemandSpend × 730). PR #277 added it for | ||
| -- Azure rows. Neither shipped a cache-invalidation migration for the | ||
| -- existing AWS rows already in the DB. | ||
| -- | ||
| -- Pre-#312 AWS rows have no on_demand_cost key, so the frontend falls | ||
| -- back to reconstructing the on-demand denominator from | ||
| -- monthly_cost + savings + amortized — a formula that double-counts | ||
| -- amortization vs. how AWS computes its savings amounts, producing | ||
| -- implausibly high Effective % values. | ||
| -- | ||
| -- Setting monthly_cost to null here causes the frontend to render "—" | ||
| -- instead, which is accurate ("data not yet collected") until the next | ||
| -- scheduler tick re-collects with correct on_demand_cost values. | ||
| -- | ||
| -- NOTE: We scope this strictly to AWS rows that lack on_demand_cost. | ||
| -- Azure rows were handled by migration 000046. GCP rows are not affected. | ||
| -- | ||
| -- NOTE: This UPDATE is idempotent — once a row has on_demand_cost | ||
| -- (written by the next scheduler tick), the NOT (payload ? 'on_demand_cost') | ||
| -- condition no longer matches it, so re-running this migration is safe. | ||
| -- | ||
| -- See GitHub issue #321 for the full root-cause investigation. | ||
| UPDATE recommendations | ||
| SET payload = jsonb_set(payload, '{monthly_cost}', 'null'::jsonb) | ||
| WHERE payload->>'provider' = 'aws' | ||
| AND NOT (payload ? 'on_demand_cost'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.