Skip to content

docs: add design doc for SNS/SQS scalable change notifications - #708

Open
rrp-bot wants to merge 2 commits into
openshift-online:mainfrom
rrp-bot:docs/sns-sqs-design
Open

docs: add design doc for SNS/SQS scalable change notifications#708
rrp-bot wants to merge 2 commits into
openshift-online:mainfrom
rrp-bot:docs/sns-sqs-design

Conversation

@rrp-bot

@rrp-bot rrp-bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an Architecture Decision Record documenting the replacement of DynamoDB Streams with SNS/SQS fan-out for bidirectional change notifications between the hyperfleet-operator (RC account) and kube-applier-aws (MC account).

What's in the doc

  • Context — the DynamoDB Streams 2-consumer-per-shard limit and why it caps the operator at 2 replicas
  • Alternatives considered — retain Streams, EventBridge Pipes, SNS/SQS (chosen)
  • Architecture diagram — two-account Mermaid flowchart covering both notification directions
  • Specs path — sequence diagram + step-by-step walkthrough (operator → kube-applier)
  • Status path — sequence diagram + step-by-step walkthrough (kube-applier → operator), including EventRouter behaviour and the optional vs required flag distinction
  • Message format — SpecNotification / StatusNotification JSON shapes, raw delivery rationale
  • Infrastructure provisioning — both Terraform modules, queue naming convention, bootstrapping guard
  • Cross-account IAM — all four resource policies with KMS grants
  • Reliability — at-least-once delivery, 5-minute safety-net poll, no DLQ rationale
  • Startup behaviour — pre-provisioned queue URL as CLI flag, EventRouter cold start, re-list wave
  • Cross-cutting concerns — scalability, resiliency, observability, security, performance, cost, operability
  • Future optimisations — BatchGetItem, eventually-consistent reads on notification path
  • Key file references — table mapping Terraform modules and Go packages across both repos

Related

  • rosa-hyperfleet-api feature branch: rrp-bot:feature/sns-sqs
  • rosa-hyperfleet-kube-applier feature branch: rrp-bot:feature/sns-sqs

Summary by CodeRabbit

  • Documentation
    • Added a comprehensive design document for replacing DynamoDB Streams with SNS/SQS-based change notifications.
    • Documented notification flows, message formats, routing behavior, delivery guarantees, infrastructure requirements, and operational considerations.
    • Included cross-account integration details, reliability trade-offs, monitoring guidance, and potential future optimizations.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@openshift-ci openshift-ci Bot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jul 27, 2026
@openshift-ci

openshift-ci Bot commented Jul 27, 2026

Copy link
Copy Markdown

Hi @rrp-bot. Thanks for your PR.

I'm waiting for a openshift-online member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Tip

We noticed you've done this a few times! Consider joining the org to skip this step and gain /lgtm and other bot rights. We recommend asking approvers on your previous PRs to sponsor you.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@coderabbitai

coderabbitai Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@rrp-bot, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 15 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 88cc7f98-b4d8-4cd2-aa68-fea7a74d093e

📥 Commits

Reviewing files that changed from the base of the PR and between 68421e1 and 160dd33.

📒 Files selected for processing (1)
  • docs/design/sns-sqs-change-notifications.md
📝 Walkthrough

Walkthrough

The design document specifies replacing DynamoDB Streams with cross-account SNS/SQS fan-out for specs and status change notifications, including message schemas, routing, Terraform provisioning, reliability guarantees, startup behavior, operational considerations, and future optimizations.

Changes

SNS/SQS change notification architecture

Layer / File(s) Summary
Notification flows and message contracts
docs/design/sns-sqs-change-notifications.md
Defines specs and status paths, per-pod queue routing, ownership checks, startup behavior, and documentID/tableSuffix notification payloads.
Messaging infrastructure and delivery model
docs/design/sns-sqs-change-notifications.md
Documents SNS topics, SQS queues, KMS, IAM, SSM parameters, cross-account policies, at-least-once delivery, and the 5-minute consistency safety-net.
Operations, trade-offs, and follow-up work
docs/design/sns-sqs-change-notifications.md
Describes architectural consequences, observability, security, performance, cost, future optimizations, and implementation references.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding a design doc for SNS/SQS-based change notifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 3

🧹 Nitpick comments (1)
docs/design/sns-sqs-change-notifications.md (1)

1-5: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add explicit ADR status and ownership metadata.

Include Status (Proposed/Accepted), decision date, owners/reviewers, and related or superseded ADRs. Last Updated Date alone does not establish the decision’s approval state.

As per path instructions, this file should comply with ADR decision-document conventions.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/design/sns-sqs-change-notifications.md` around lines 1 - 5, Update the
ADR metadata near the document title and existing Last Updated Date to include
explicit Status, decision date, owners/reviewers, and related or superseded ADR
references, using the repository’s established ADR conventions and valid
Proposed/Accepted status values.

Source: Path instructions

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/design/sns-sqs-change-notifications.md`:
- Around line 503-504: Update the “Low-latency notifications” statement to avoid
claiming an end-to-end latency bound of 20 seconds; describe 20 seconds
specifically as the SQS long-poll interval, or replace it with a measured
end-to-end latency SLO if one is established.
- Around line 581-585: Update the SQS cost description in the messaging cost
model to state that the free tier applies account-wide rather than per queue,
and clarify the SNS-to-SQS cost description to distinguish free delivery from
applicable region-specific payload data-transfer charges. Preserve the existing
request and API pricing details.
- Around line 336-340: The documented KMS key and IAM inline policy must include
the required KMS permissions for encrypted messaging: grant
`kms:GenerateDataKey*` for SNS publishing and `kms:Decrypt` for SQS consumption,
covering both the SNS topic CMK and every subscribed SQS queue CMK. Update the
module/config symbols defining the CMK policies and service-principal grants
while preserving the existing SNS/SQS permissions.

---

Nitpick comments:
In `@docs/design/sns-sqs-change-notifications.md`:
- Around line 1-5: Update the ADR metadata near the document title and existing
Last Updated Date to include explicit Status, decision date, owners/reviewers,
and related or superseded ADR references, using the repository’s established ADR
conventions and valid Proposed/Accepted status values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 76f48a28-f5d1-4f09-81ae-846f80acb0a1

📥 Commits

Reviewing files that changed from the base of the PR and between 948528c and 68421e1.

📒 Files selected for processing (1)
  • docs/design/sns-sqs-change-notifications.md

Comment thread docs/design/sns-sqs-change-notifications.md
Comment thread docs/design/sns-sqs-change-notifications.md Outdated
Comment thread docs/design/sns-sqs-change-notifications.md Outdated

This document describes the replacement of DynamoDB Streams with an SNS/SQS fan-out architecture
for bidirectional change notifications between the hyperfleet-operator (RC account) and
kube-applier-aws (MC account). DynamoDB remains the authoritative data store; SNS/SQS replaces

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Actually postgres is the authoritative source


### Problem Statement

The hyperfleet-operator runs as a Kubernetes StatefulSet and uses DynamoDB Streams to learn when

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The problem is more around multiple controllers, the two streams is absolute, not per controller

DynamoDB Streams enforces a hard limit of **two concurrent consumers per stream shard**. A
three-replica operator deployment violates this limit, causing stream throttling and missed events.

The equivalent limit exists in kube-applier-aws, which tails DynamoDB Streams on the specs tables

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ensure this is regarding the scaling of replicas


### Assumptions

- The hyperfleet-operator is deployed as a Kubernetes StatefulSet. Pod hostnames encode the

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

However - every queue gets ALL notifications and each pod just responds to the ones it owns/is sharded to

- The hyperfleet-operator is deployed as a Kubernetes StatefulSet. Pod hostnames encode the
replica ordinal (e.g., `hyperfleet-operator-2`), which is used to determine which pre-provisioned
SQS queue a pod should poll.
- kube-applier-aws is leader-elected per MC: only one active replica polls the specs SQS queue

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Currently a single replica - but we wanted options

…ine#708

- Reframe two-consumer limit: clarify it is absolute across the entire
  stream; multiple controller goroutines per replica means even a single
  replica can approach the limit with multiple MCs
- Clarify kube-applier Streams removal enables future horizontal scaling
- Note every per-pod SQS queue receives all MC status notifications;
  EventRouter silently drops IDs the pod does not own
- Note kube-applier is currently single-replica (leader-elected) but the
  design keeps options open for future scaling
- Add kms:GenerateDataKey* and kms:Decrypt to IAM inline policy
  descriptions for both RC and MC modules, and to the Security summary
- Fix low-latency bullet: 20 s is the empty-queue long-poll wait, not
  end-to-end latency; actual delivery is typically sub-second
- Fix Cost section: SQS free tier is account-wide not per-queue;
  SNS-to-SQS delivery has no per-notification fee but cross-account data
  transfer charges apply

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@openshift-ci

openshift-ci Bot commented Jul 27, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from psav. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants