Repository navigation
fix(cost): show a new cost source at once and sync it within minutes - #2522
Conversation
Turning on AWS Cost left the Cost page on the "No cost source yet" on-ramp until the hourly cost_sync tick created the source, then waited for that same tick to pull anything. - The AWS cost source reconcile moves to a shared helper that the AWS connection runs for its own org in the same write as a module change, a check (which can grant or lose cost) and a delete. The page shows "Waiting for the first sync" as soon as the grant is seen. - cost_sync moves from the hourly fire to the 2-59/5 fire. A tick with nothing due is a few queries; heads are still pulled once a day and the monthly request budgets are unchanged. Sources per tick drop to 6 to fit the 270-second deadline.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 29 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Maple review🟢 Confidence 10/10 · safe to merge. The moved reconcile is behaviour-preserving and the new call sites are org-scoped; only the untested 6-claims-in-270s tuning of the faster lane needs watching after deploy. Moves the AWS cost-source reconcile into a shared
Before merge
|
|
Merged with 1 step from "Before merge" still open. If it is done, tick it on the review comment; if not, now is the time.
|
Problem
After turning on AWS Cost for a connected account, the Cost page stayed on the "No cost source yet / Connect AWS" on-ramp, which reads as broken. Two causes:
cost_sourcesrow was only created by the hourlycost_synctick, so until then the page had no source and fell back to the on-ramp instead of the "Waiting for the first sync" state it already has.Seen in prod: Cost turned on at 00:16 UTC, check passed at 00:21, previous tick at 00:00, next at 01:00.
Change
CostSyncService(create a source for a connection that supplies cost, turn it off when cost is no longer supplied, remove it when the connection is deleted) moves toservices/cost/aws-cost-sources.ts, aMapleDbhelper with an optional org scope.AwsConnectionServiceruns it for its own org inside the same transaction as a module change, a check (which is where a grant shows up), and a delete. The sync lane still runs it unscoped every tick.cost_syncmoves from0 * * * *to2-59/5 * * * *, next tovercel(that fire had five free lane slots). A tick with nothing due costs a reconcile and a due-query. Heads are still pulled once a day, and the monthly request budgets are unchanged. History backfills faster but within the same budget.MAX_SOURCES_PER_TICKdrops from 20 to 6 to fit the 270s deadline (about 1 minute per claim, 2 at a time). The lease (20 min) still outlives the deadline.The rollout hold stays at 50 minutes. It only matters for an org whose
cloudCostflag is withdrawn.Verification
AwsConnectionServicetest replays the flow: Cost asked for but not granted (no source), setup re-run and checked (source enabled), turned off (disabled, kept), turned back on (enabled), connection deleted (source gone).CostSyncService,AwsConnectionService, alertingscheduled/tick-dispatch, and the cost page scene tests pass.tscclean forpackages/backend,apps/alerting,apps/api.oxlint -c .oxlintrc.effect.jsonclean on changed files.Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.