Skip to content

feat(supervisor): add ecr support to docker workloads #2424

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
merged 1 commit into from
Aug 20, 2025

Conversation

nicktrn
Copy link
Collaborator

@nicktrn nicktrn commented Aug 20, 2025

Adds support for AWS ECR authentication to the Docker workload manager, enabling automatic token-based authentication and refresh when AWS credentials are available and falling back to static credentials when configured.

Environment Variables

No new environment variables are required. The implementation automatically detects existing AWS credentials through standard AWS SDK mechanisms:

  • AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY (if using access keys)
  • AWS_PROFILE (if using AWS profiles - requires mounting .aws)
  • AWS_ROLE_ARN and AWS_WEB_IDENTITY_TOKEN_FILE (if using IAM roles)

Backwards Compatibility

Fully backwards compatible - existing Docker registry configurations continue to work unchanged, with ECR authentication only activating when AWS credentials are detected.

Copy link

changeset-bot bot commented Aug 20, 2025

⚠️ No Changeset found

Latest commit: f72535f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Aug 20, 2025

Walkthrough

  • Adds dependency @aws-sdk/client-ecr to apps/supervisor/package.json.
  • Introduces apps/supervisor/src/workloadManager/ecrAuth.ts with ECRAuthService to obtain and cache AWS ECR Docker auth tokens using AWS SDK v3. Provides hasAWSCredentials, getAuthConfig, and clearCache.
  • Updates apps/supervisor/src/workloadManager/docker.ts to support two auth modes: static registry credentials (renamed to staticAuth) and dynamic ECR auth via ECRAuthService. Adds getAuthConfig helper and updates image pull to use retrieved auth config. Adjusts logging and initialization logic accordingly.
  • No changes to public interfaces of DockerWorkloadManager; ECRAuthService is a new exported class.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Scope: 1 new service file with token caching/decoding logic; 1 integration refactor; 1 dependency addition.
  • Complexity: Moderate logic in ECR token management (AWS SDK usage, base64 decoding, expiry buffer, caching).
  • Heterogeneity: Mixed (new feature + integration + config).
  • Review focus: Auth flow correctness, cache/expiry handling, error paths/logging, Docker auth config usage, environment detection.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/supervisor-docker-ecr

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

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

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

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 (3)
apps/supervisor/src/workloadManager/ecrAuth.ts (2)

18-24: Region logging may print an unresolved provider function.

ecrClient.config.region can be a string or a provider function. Logging it directly will either omit the field (JSON.stringify drops functions) or log a noisy function body. Resolve it to a string-friendly value.

Apply this diff:

-    this.logger.info("🔐 ECR Auth Service initialized", {
-      region: this.ecrClient.config.region,
-    });
+    const region =
+      typeof this.ecrClient.config.region === "string"
+        ? this.ecrClient.config.region
+        : "<provider>";
+    this.logger.info("🔐 ECR Auth Service initialized", { region });

6-11: Clarify naming: token vs password.

The cache field token actually holds the decoded password. Rename for clarity to avoid confusion in future refactors.

-interface ECRTokenCache {
-  token: string;
+interface ECRTokenCache {
+  password: string;
   username: string;
   serverAddress: string;
   expiresAt: Date;
 }
@@
-    const tokenCache: ECRTokenCache = {
-      token: password,
+    const tokenCache: ECRTokenCache = {
+      password,
       username,
       serverAddress: authData.proxyEndpoint,
       expiresAt,
     };
@@
       return {
         username: this.tokenCache!.username,
-        password: this.tokenCache!.token,
+        password: this.tokenCache!.password,
         serveraddress: this.tokenCache!.serverAddress,
       };
@@
     return {
       username: newToken.username,
-      password: newToken.token,
+      password: newToken.password,
       serveraddress: newToken.serverAddress,
     };

Also applies to: 88-93, 113-116, 130-134

apps/supervisor/src/workloadManager/docker.ts (1)

170-172: Log chosen auth path for debuggability (optional).

Consider logging which auth path was used (static vs ECR) at pull time for faster diagnostics.

-      const authConfig = await this.getAuthConfig();
+      const authConfig = await this.getAuthConfig();
+      if (authConfig) {
+        logger.debug("Using authenticated pull", {
+          authType: this.staticAuth ? "static" : "ecr",
+          serveraddress: authConfig.serveraddress,
+        });
+      } else {
+        logger.debug("Pulling without registry auth");
+      }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between b41129a and f72535f.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • apps/supervisor/package.json (1 hunks)
  • apps/supervisor/src/workloadManager/docker.ts (4 hunks)
  • apps/supervisor/src/workloadManager/ecrAuth.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.github/copilot-instructions.md)

**/*.{ts,tsx}: Always prefer using isomorphic code like fetch, ReadableStream, etc. instead of Node.js specific code
For TypeScript, we usually use types over interfaces
Avoid enums
No default exports, use function declarations

Files:

  • apps/supervisor/src/workloadManager/ecrAuth.ts
  • apps/supervisor/src/workloadManager/docker.ts
🧬 Code Graph Analysis (2)
apps/supervisor/src/workloadManager/ecrAuth.ts (1)
packages/core/src/v3/utils/structuredLogger.ts (1)
  • SimpleStructuredLogger (21-102)
apps/supervisor/src/workloadManager/docker.ts (3)
apps/supervisor/src/workloadManager/types.ts (1)
  • WorkloadManager (16-18)
apps/supervisor/src/workloadManager/ecrAuth.ts (1)
  • ECRAuthService (13-144)
packages/core/src/utils.ts (1)
  • tryCatch (5-18)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (4)
apps/supervisor/package.json (1)

16-16: Dependency addition looks good; confirm compatibility matrix.

Adding @aws-sdk/client-ecr is appropriate for ECR auth. Ensure the Node runtime used by supervisor matches AWS SDK v3 requirements (Node 16+), which the repo likely already satisfies.

If you want, I can scan the repo for engines/node declarations and CI matrix to confirm alignment.

apps/supervisor/src/workloadManager/ecrAuth.ts (1)

61-65: Good error handling with tryCatch.

Wrapping the AWS SDK call with tryCatch keeps the code tidy and prevents unhandled rejections. Logging avoids leaking secrets.

apps/supervisor/src/workloadManager/docker.ts (2)

229-247: Helper is solid and side-effect free.

Prefers static creds and falls back to ECR dynamically, returning undefined when not available. Works well with the corrected createImage options.


18-21: Private fields restructuring LGTM.

Separating staticAuth from ecrAuthService clarifies the auth paths and keeps state minimal.

@nicktrn nicktrn merged commit 9092ca8 into main Aug 20, 2025
57 checks passed
@nicktrn nicktrn deleted the feat/supervisor-docker-ecr branch August 20, 2025 09:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants