Repository navigation
feat(deploy): run Orbit on EKS with S3-backed uploads - #23
Conversation
This reverts commit 59f8784.
Green CI is not enough on its own. Record that a pull request waits for the review to finish, and that each thread ends either with a fix or with a reply saying why the finding does not apply.
Completion only rejected oversized uploads, so an object smaller than the client declared kept the larger registered size and misled anything reading attachment.size. Record the size storage actually reports. The route also wrote to Postgres without bumping sync_id or publishing a SyncAction, so realtime clients never saw an attachment become ready. Move that into a core service that allocates the sync id and emits the action in the same transaction, scoped to the parent doc or issue. Cover the upload path with tests that fail if the completion request is removed.
Redis took its password through argv, where any process listing inside the container could read it. Write a config file at startup instead, and let the probes authenticate through REDISCLI_AUTH. The migration job ran the mutable latest tag, so it could apply a different release than the one being rolled out. Pin it to the tag the web deployment is actually running, and refuse to migrate from a mutable tag. The migration image ran as root despite holding database and token access, so give it a non-root user. apply.sh matched only a certificate's primary domain and could pick one that does not cover the host. Match subject alternative names, restrict to issued certificates, and say so when nothing matches. migrate.sh started its timeout only after the log stream ended, so a stuck job waited forever. Bound the wait and stop following logs when it ends. Pass the bastion server to the kubectl examples in the README so they work in the flow the same document describes.
Static review cannot catch a broken copy path, a missing runtime module or a placeholder that never got substituted. Build all four images, boot the web image and require it to serve its health endpoint, assert the migration image is not root, and render every manifest to check no placeholder survives and the result validates. The web build required a Doppler token, which made the image impossible to build without production credentials. Fall back to a clearly labelled placeholder build when no token is mounted.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughThis PR makes object storage S3-only, adds attachment completion validation, introduces Docker builds for application services, and adds CI and EKS deployment infrastructure with Kubernetes manifests, rendering scripts, migration execution, and operational documentation. ChangesS3 storage and attachment uploads
Container and delivery pipeline
EKS runtime deployment
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant Browser
participant WebAPI
participant Storage
participant AttachmentService
participant Realtime
Browser->>WebAPI: request presigned upload
WebAPI-->>Browser: return presigned URL
Browser->>Storage: upload file
Browser->>WebAPI: request attachment completion
WebAPI->>Storage: verify object and size
WebAPI->>AttachmentService: mark attachment ready
AttachmentService->>Realtime: publish attachment update
WebAPI-->>Browser: return completed attachment
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8).github/workflows/ci.ymlTraceback (most recent call last): k8s/06-migrate-job.yamlTraceback (most recent call last): Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🧹 Nitpick comments (3)
packages/services/src/storage/s3.ts (2)
14-21: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winPartial S3 credentials are silently dropped rather than rejected.
If only
accessKeyIdor onlysecretAccessKeyis supplied directly toS3StorageDriver(bypassingcreateStorageDriver's "both or neither" guard),explicitCredentialsbecomes{}and the client silently falls back to ambient credentials instead of erroring. The invariant is enforced only at the factory level (index.ts), not ins3ConfigSchemaitself, so any other caller ofS3StorageDriverdirectly (as the test suite already does) can bypass it.🛡️ Suggested fix: enforce the invariant in the schema
export const s3ConfigSchema = z.object({ bucket: z.string().min(1), region: z.string().min(1).default('us-east-1'), endpoint: z.string().url().optional(), accessKeyId: z.string().min(1).optional(), secretAccessKey: z.string().min(1).optional(), forcePathStyle: z.boolean().optional(), -}); +}).refine( + (config) => (config.accessKeyId === undefined) === (config.secretAccessKey === undefined), + { message: 'Set both accessKeyId and secretAccessKey, or neither.' }, +);Also applies to: 34-44
🤖 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 `@packages/services/src/storage/s3.ts` around lines 14 - 21, Update s3ConfigSchema to reject configurations where exactly one of accessKeyId or secretAccessKey is provided, while continuing to accept both credentials or neither. Enforce this invariant at schema validation so direct S3StorageDriver callers cannot silently fall back to ambient credentials; preserve the existing field validation and defaults.
17-17: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse
z.url()here.z.string().url()is deprecated in Zod v4 and will be removed in a future major version.🤖 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 `@packages/services/src/storage/s3.ts` at line 17, Update the endpoint schema to use Zod v4’s z.url() validator instead of the deprecated z.string().url() chain, while preserving its optional behavior.packages/core/src/content/attachment-service.ts (1)
17-70: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing direct test coverage for
markAttachmentReady/findAttachmentForOrganization.
docs.test.tsonly exercises this indirectly through the client-side upload flow (mockedfetch); none of the reviewed files test the transactional core logic itself (org-scoped lookup,syncIdallocation,SyncActionscope construction for doc vs. issue parents). As per coding guidelines, "Every feature must include tests that would fail if the feature broke."🤖 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 `@packages/core/src/content/attachment-service.ts` around lines 17 - 70, The attachment service lacks direct tests for findAttachmentForOrganization and markAttachmentReady. Add focused tests covering organization-scoped lookup, not-found behavior, transactional syncId allocation and update, and SyncAction scope construction for both doc and issue parent types, using mocks or fixtures consistent with the existing test setup.Source: Coding guidelines
🤖 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 @.github/workflows/ci.yml:
- Around line 119-129: Update the actions/checkout@v5 step in the CI workflow to
set persist-credentials to false, ensuring the GitHub token is not retained for
subsequent build steps.
In `@apps/web/src/app/api/files/`[...key]/route.ts:
- Around line 38-42: Cache a single module-level storage driver created by
createStorageDriver() and reuse it across requests. In
apps/web/src/app/api/files/[...key]/route.ts lines 38-42, replace the inline
factory call with the cached instance for getUrl; apply the same cached instance
in apps/web/src/app/api/attachments/[id]/complete/route.ts line 15 for stat.
In `@k8s/06-migrate-job.yaml`:
- Around line 9-11: Add activeDeadlineSeconds to the Kubernetes Job spec
alongside backoffLimit and ttlSecondsAfterFinished, setting it to the migration
timeout used by migrate.sh. Reuse the existing JOB_TIMEOUT substitution
mechanism, such as the __JOB_TIMEOUT__ placeholder, so the server-side Job
deadline stays synchronized with the script timeout.
In `@k8s/migrate.sh`:
- Around line 21-22: Update the AWS_ACCOUNT_ID initialization flow in migrate.sh
to mirror the validation guard used by apply.sh: reject empty or "None" account
IDs before constructing ECR_REGISTRY, and fail with the same clear error
behavior. Ensure invalid credentials cannot produce a registry value beginning
with "None.dkr.ecr".
---
Nitpick comments:
In `@packages/core/src/content/attachment-service.ts`:
- Around line 17-70: The attachment service lacks direct tests for
findAttachmentForOrganization and markAttachmentReady. Add focused tests
covering organization-scoped lookup, not-found behavior, transactional syncId
allocation and update, and SyncAction scope construction for both doc and issue
parent types, using mocks or fixtures consistent with the existing test setup.
In `@packages/services/src/storage/s3.ts`:
- Around line 14-21: Update s3ConfigSchema to reject configurations where
exactly one of accessKeyId or secretAccessKey is provided, while continuing to
accept both credentials or neither. Enforce this invariant at schema validation
so direct S3StorageDriver callers cannot silently fall back to ambient
credentials; preserve the existing field validation and defaults.
- Line 17: Update the endpoint schema to use Zod v4’s z.url() validator instead
of the deprecated z.string().url() chain, while preserving its optional
behavior.
🪄 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
Run ID: cc186147-b40c-486b-b23b-aad98e1b7acc
📒 Files selected for processing (35)
.dockerignore.env.example.github/workflows/ci.yml.gitignoreCLAUDE.mdapps/mcp/Dockerfileapps/realtime/Dockerfileapps/web/Dockerfileapps/web/next.config.tsapps/web/src/app/api/attachments/[id]/complete/route.tsapps/web/src/app/api/files/[...key]/route.tsapps/web/src/app/api/health/route.tsapps/web/src/features/docs/docs.test.tsapps/web/src/features/docs/upload.tsbuildspec.ymldocker-compose.ymlk8s/00-namespace.yamlk8s/01-redis.yamlk8s/02-web.yamlk8s/03-realtime.yamlk8s/04-mcp.yamlk8s/05-ingress.yamlk8s/06-migrate-job.yamlk8s/README.mdk8s/apply.shk8s/migrate.shpackages/core/src/content/attachment-service.tspackages/core/src/index.tspackages/db/Dockerfilepackages/services/src/storage/index.tspackages/services/src/storage/key.tspackages/services/src/storage/local.tspackages/services/src/storage/s3.tspackages/services/src/storage/storage.test.tspackages/services/src/storage/types.ts
💤 Files with no reviewable changes (2)
- .env.example
- packages/services/src/storage/local.ts
Every request built a fresh S3 client, re-parsing config and rebuilding the credential chain. Under IRSA that can mean an STS round trip on the download and upload paths, so cache one driver and share it. migrate.sh only bounded its own wait, leaving a hung job running and letting a retry start a second migration against the same schema. Give the job a deadline that fires before the script stops waiting, and refuse to start when one is already active. Validate the resolved account id rather than building a broken registry reference from it. Drop the persisted git credential from the image job, which never pushes.
Re-lands the reverted deploy work with every CodeRabbit finding from #22 addressed, plus a CLAUDE.md rule that no PR merges with an unresolved review thread.