Repository navigation
Conversation
…asks Add an EventBridge rule and invoke permission to the CUDly CloudFormation stack for each scheduled server task it was missing, each switched by an Enable*Schedule parameter with a matching *Schedule expression: - finalize_revocations: on, rate(1 hour) - analytics_collect: on, rate(1 day) - reap_stuck_purchases: off (owner decision on LeanerCloud#712: the PurchaseCheck rule runs process only daily, so the reaper's 1h20m approved floor would still fail stranded approvals before process re-drives them) - fire_scheduled_purchases: off (opt-in), rate(15 minutes) - send_notifications: off (opt-in), rate(1 day) Cadences match the Terraform Lambda module defaults. The existing collection and PurchaseCheck rules are unchanged. A new Go test parses the template and checks, for every required server task, one rule targeting the Lambda with {"action": task}, one permission gated by the rule's condition, an enable default that follows the opt-in policy (with listed exceptions), a schedule parameter matching the Lambda module default, and a name suffix no longer than the oldest rule's. cleanup stays a documented CloudFormation gap until the next commit. Refs LeanerCloud#712 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add EnableCleanupSchedule (default "false") and CleanupSchedule (default rate(1 day)) to the CUDly CloudFormation stack, with a <stack>-Cleanup rule and invoke permission that run the server cleanup task. It stays opt-in, as on the Lambda module: the first run deletes every execution past the 30-day retention. Drop the last CloudFormation entry from knownGaps and document the parameter in DEPLOYMENT.md and known_issues/33. Refs LeanerCloud#712 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Comment |
Brings in main's CI fixes (LeanerCloud#1236, LeanerCloud#1252) and CI changes since, so this PR gets a fresh CI run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): VERDICT: APPROVE Blocking:
Non-blocking:
Attacked:
Body-stale:
Reviewer: rA3. Bar while the maintainers are away (set by IAmJSD as acting owner): one approving independent review on the head, two for money, auth and security paths. |
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #712. This is slice 4 of the "Scope for #712" plan: CloudFormation schedules, with cleanup as its own commit. Slices 1 to 3 are already on main (#902, #903, #939, #949, #986). The #784 change landed as #895, so nothing in the plan is blocked by it any more. This slice is AWS-only and was never blocked.
Root cause
cloudformation/stacks/CUDly/template.yamlonly scheduledcollect_recommendations(theScheduledRule) andprocess_scheduled_purchases(the dailyPurchaseCheckRule). Six other required server tasks had no EventBridge rule, so they never ran on a CloudFormation deployment:finalize_revocations,analytics_collect,reap_stuck_purchases,fire_scheduled_purchases,send_notificationsandcleanup. That includes the delayed-purchase fire sweep. The coverage test from #902 listed all six as knowncloudformationgaps.Fix
Each missing task gets one
AWS::Events::Ruleand oneAWS::Lambda::Permission. Each pair is gated by aSchedule<Task>condition on anEnable<Task>Scheduleparameter ("true"/"false"), and the schedule comes from a matching<Task>Scheduleparameter. The target isLambdaFunctionwithInput: '{"action": "<task>"}', the same contract the existing rules use. The parameters are listed in a new "Scheduled Tasks" console parameter group.finalize_revocationsrate(1 hour)analytics_collectrate(1 day)reap_stuck_purchasesrate(5 minutes)PurchaseCheckRuleruns process only daily, so a reaper would still fail a stranded approval before process re-drives it.fire_scheduled_purchasesrate(15 minutes)send_notificationsrate(1 day)cleanup(2nd commit)rate(1 day)The cadence defaults equal the Terraform Lambda module defaults, and a test pins that.
Rule names are
${AWS::StackName}-Finalize,-AnalyticsCollect,-ReapStuck,-FireScheduled,-SendNotificationsand-Cleanup. None is longer than the existing-ScheduledExecution, so every stack name the existing rule accepts still fits EventBridge's 64-character limit.The two existing rules are unchanged. That includes the always-on daily
PurchaseCheckRule(process), even though the plan's policy makes process opt-in for new schedules: turning it off would stop purchases on existing stacks. The test records it as an explicit exception.scheduled_task_coverage_test.go: thecloudformationentry is removed fromknownGaps.scheduled_task_cfn_test.go(new): parses the template with yaml.v3, rewriting short-form intrinsics to their long form. For every required server task (the roster minusexemptTasks), it checks:LambdaFunction.Arn, whoseInputis exactly{"action": task};SourceArnset to that rule, the right action, principal and function, and the same Condition as the rule;"true"/"false", and its default follows the opt-in policy (optInRequired/exemptTasks). Exceptions are listed incfnDefaultExceptionswith reasons, and each one is asserted to still apply;Refto a parameter whose default equals the Lambda module's*_scheduledefault;StateisENABLED.A rule that sends an unknown task fails. A new server task fails until it is scheduled here or listed as a CFN gap.
Docs (2nd commit):
docs/DEPLOYMENT.mdandknown_issues/33now describe the opt-in CloudFormation cleanup parameter.Deploy note
No workflow deploys this template. Customers apply it themselves, so merging deploys nothing. This PR is AWS CloudFormation only. The Azure/GCP deploy pause (since 2026-10-20) does not gate it, and none of its effect waits on that pause. The remaining #712 slices are Fargate, then GCP and Azure; the GCP/Azure ones will wait on the pause.
Verification
All of this is static, fixture and unit evidence. Nothing was deployed and no AWS API was called.
cfn-lintandtrivyare not installed on this machine, so the template's only machine check here is the yaml.v3 parse plus the structural assertions above. CI's trivy step will scan it.Fail-before: I put back
origin/main'stemplate.yamlwith the new test in place.The new template with the old
knownGapsalso fails, withcloudformation: knownGaps lists analytics_collect but it is wiredand the same for the other four.Pass-after, on this branch (head
e5bcda0a):terraform fmt/validate/testdo not apply: no Terraform files changed.Mutation probes are built into
TestCloudFormationScheduleCheckNegatives. Each one edits the real template text and must produce a problem. I checked that each fails for its intended reason:State: DISABLED;"true";Long-form
Fn::GetAttis covered too.Overlap:
git merge-treeagainst #1086, #1090, #1203, #1119, #1114 and fork branchesfix/issue-1233andfix/issue-323merges cleanly.go test ./terraform/modules/compute/passes on the merge with #1114, which also editsknownGaps, DEPLOYMENT.md and known_issues/33.Combined-tree verification. This branch was tested together with the other queued branches on a local, never-pushed tree:
queue/platform@936996ad= origin/maina14dc8f2plus these heads, merged in this order:fix/issue-72andfix/issue-312conflict on one line ininternal/api/handler_dashboard.go(both change thecalculateCommitmentMetricscall). The tree used #72's side with #312's validatedprovidervariable; whichever PR merges second takes that same resolution.Linux, Go 1.26.9,
AWS_CONFIG_FILE=/dev/null AWS_SHARED_CREDENTIALS_FILE=/dev/null AWS_EC2_METADATA_DISABLED=true; Docker Postgres via testcontainers:936996ad:go build ./...,go vet ./...,go vet -tags integration ./...and the fullgo test -race -short -count=1 ./....936996ad: golangci-lint v2.10.1 found 0 issues on every changed package, with and without--build-tags integration.tests/e2eis a separate module, so it was vetted under its owne2etag.gocyclo -over 10is silent on the changed non-test files.-tags integration -count=1, 60-minute local timeout because the VM was shared):936996ad, these pass:internal/server,internal/credentials,internal/scheduler,internal/database/postgres/migrations,internal/purchaseandinternal/api.internal/configpasses exceptTestPostgresStoreDB_ResolveStaleRIExchange_ValidatesCloudCheck, which fails the same way on unmodified main (fixed by fix(config): compare resolve checked_at at the database's microsecond precision #1252).26795376, same branches at earlier heads):internal/analytics,internal/auth,internal/commitmentopts,internal/databaseandcmd/lambda/clear-rate-limitall pass. The later fixes don't touch those packages.httpToLambdaRequestsignature change;scripts/setup-git-secrets.shpatterns in a fresh repo with an isolated HOME, found nothing in the changed files, and a planted fake key was flagged.scripts/test-git-secrets-allowlist.sh: 137 PASS, 0 FAIL.Out of scope / for the maintainer
DB_HOST/DB_*environment.initConfigStore(internal/server/app.go) returnsDB_HOST must be set, andcmd/serverexits withlog.Fatalf. So these rules, like the two existing ones, only do anything once the stack is brought up to the Postgres-backed server. I found no issue tracking this; it probably deserves one, and it may affect how much this slice is worth.docs/DEPLOYMENT.mdstill says "Scheduling for AWS Fargate, CloudFormation and GCP is tracked by fix(iac): several scheduled tasks are not scheduled; delayed purchases never fire on GCP/Azure #712". I left that line alone because fix(iac/azure): schedule the server tasks on AKS with CronJobs #1114 rewrites it. Dropping "CloudFormation" from it can follow once both have merged.PurchaseCheckRuleis a behavior change for live stacks, so it is not done here.process_scheduled_purchasesstays always-on on CFN (pre-existing), unlike the opt-in policy elsewhere.Please mirror the issue's triage labels on this PR:
priority/p1,severity/high,urgency/this-sprint,impact/many,effort/m,type/bug,triaged.Refs #712
🤖 Generated with Claude Code