Skip to content

feat: add API_EXTERNAL_URL#405

Merged
kaixi-wang merged 6 commits into
release/v2.11.0from
add-external-api-url
Aug 25, 2025
Merged

feat: add API_EXTERNAL_URL#405
kaixi-wang merged 6 commits into
release/v2.11.0from
add-external-api-url

Conversation

@kaixi-wang

@kaixi-wang kaixi-wang commented Jul 1, 2025

Copy link
Copy Markdown
Member

Rationale

Enabled the api to know the external api url for setting up remote orchestrators

Changes

  • add EXTERNAL_API_URL to helm
  • add EXTERNAL_API_URL to docker

Checklist

  • This PR maintains parity between Docker Compose and Helm

Testing

  • add and update unit tests

@kaixi-wang kaixi-wang self-assigned this Jul 1, 2025
@kaixi-wang kaixi-wang requested a review from a team as a code owner July 1, 2025 23:23
@kaixi-wang kaixi-wang marked this pull request as draft July 1, 2025 23:23
Comment thread helm/fiftyone-teams-app/templates/_helpers.tpl
@kaixi-wang kaixi-wang changed the title feat: add EXTERNAL_API_URL feat: add API_EXTERNAL_URL Jul 1, 2025
findtopher
findtopher previously approved these changes Jul 1, 2025

@findtopher findtopher 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.

Looks like a good first half!

@kevin-dimichel

Copy link
Copy Markdown
Contributor

@kaixi-wang - can you please rebase this PR on the main branch? In #406, I updated the NFS server name used in the our helm integration test PR checks. You'll need that config in this branch for new runs of the PR check (after we shut down the legacy NFS server).

@kaixi-wang kaixi-wang force-pushed the add-external-api-url branch from 8a28bc6 to b2b490b Compare July 2, 2025 22:20
@kaixi-wang kaixi-wang marked this pull request as ready for review July 2, 2025 22:20
Comment thread tests/unit/compose/docker-compose-legacy-auth_test.go
Comment thread tests/unit/helm/api-deployment_test.go Outdated
Comment thread tests/unit/helm/api-deployment_test.go Outdated
Comment thread tests/unit/helm/api-deployment_test.go Outdated
Comment thread tests/unit/helm/api-deployment_test.go
Comment thread tests/unit/helm/api-deployment_test.go
Comment thread tests/unit/helm/api-deployment_test.go Outdated
@afoley587

Copy link
Copy Markdown
Contributor

I made #424 which apply the suggestions + merge main. you can also commit the suggestions + rebase. Whatever works best!

@coderabbitai

coderabbitai Bot commented Aug 18, 2025

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

Introduces API_EXTERNAL_URL for the teams API via Helm template logic based on apiSettings.dnsName or teamsAppSettings.dnsName. Updates README and Docker env template comments to clarify external orchestrator use. Adjusts unit tests for compose and Helm to expect the new/empty env var and correct compose file path.

Changes

Cohort / File(s) Summary
Docker env templates (comments)
docker/internal-auth/env.template, docker/legacy-auth/env.template
Updated FIFTYONE_API_URI comments to mention end-users and external orchestrators; no functional changes.
Helm chart docs
helm/fiftyone-teams-app/README.md
Expanded apiSettings.dnsName description to note use in generating API_EXTERNAL_URL for external orchestrators.
Helm template env var
helm/fiftyone-teams-app/templates/_helpers.tpl
Added API_EXTERNAL_URL to env vars: prefers apiSettings.dnsName, else teamsAppSettings.dnsName, else empty string.
Compose unit tests
tests/unit/compose/docker-compose-internal-auth_test.go, tests/unit/compose/docker-compose-legacy-auth_test.go
Expect API_EXTERNAL_URL in service environments; adjusted delegated-operators compose path to legacy-auth directory.
Helm unit tests
tests/unit/helm/api-deployment_test.go
Assert API_EXTERNAL_URL in container env (empty by default); added case verifying override from dnsName values.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Helm Values
  participant Tpl as Helm Template (_helpers.tpl)
  participant K8s as K8s Deployment
  participant API as teams-api Pod

  Dev->>Tpl: Provide apiSettings.dnsName / teamsAppSettings.dnsName
  Tpl->>Tpl: Compute API_EXTERNAL_URL<br/>if apiSettings.dnsName -> https://{apiDNS}<br/>else if teamsAppSettings.dnsName -> https://{appDNS}<br/>else ""
  Tpl->>K8s: Render Deployment with env: API_EXTERNAL_URL
  K8s->>API: Start container with env
  API-->>API: Read API_EXTERNAL_URL at runtime
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nibbled on configs by moonlit swirl,
Set API paths with a tidy twirl.
If API DNS shines, I hop that way—
Else App DNS guides my ballet.
Tests now squeak, “All URLs true!”
Thump-thump: a deploy fresh as dew. 🐇✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-external-api-url

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

‼️ IMPORTANT
Auto-reply has been disabled for this repository in the CodeRabbit settings. The CodeRabbit bot will not respond to your replies unless it is explicitly tagged.

  • 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.

@kaixi-wang kaixi-wang force-pushed the add-external-api-url branch from c353158 to a64056b Compare August 18, 2025 19:21
@kaixi-wang kaixi-wang changed the base branch from main to release/v2.11.0 August 18, 2025 19:21

@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: 0

♻️ Duplicate comments (2)
tests/unit/compose/docker-compose-legacy-auth_test.go (1)

30-30: Delegated-operators compose path fix is correct

Pointing legacyAuthComposeDelegatedOperationsFile to dockerLegacyAuthDir is consistent with this suite’s scope (legacy-auth). Nice catch.

tests/unit/helm/api-deployment_test.go (1)

436-439: LGTM: default API_EXTERNAL_URL assertions (empty) across scenarios

Adding API_EXTERNAL_URL with an empty default in all baseline/env override/internal-auth/secret-name/cas override cases matches the new Helm helper logic and keeps ordering stable before CAS_BASE_URL.

Also applies to: 521-524, 620-623, 717-719, 801-803

🧹 Nitpick comments (5)
helm/fiftyone-teams-app/README.md (1)

477-477: Line-length lint violation (MD013) on updated row

The updated description is helpful, but markdownlint flags the table row for exceeding 80 chars.

Two low-impact ways to resolve:

  • Wrap the Values table with markdownlint disable/enable for line-length:
    • Insert before the table: <!-- markdownlint-disable line-length -->
    • Insert after the table: <!-- markdownlint-enable line-length -->
  • Or raise the per-file MD013 threshold if this table typically carries long cells.

Given other disables are already used at the top, the first option is consistent with existing style.

helm/fiftyone-teams-app/templates/_helpers.tpl (2)

340-347: Confirm path-based routing behavior; consider supporting a path prefix

The fallback to teamsAppSettings.dnsName covers the host when apiSettings.dnsName is unset (path-based setups), but the computed value is just https://<host> with no path. If your ingress routes the API under a path prefix on the app host (e.g., /api), remote orchestrators may need that prefix in API_EXTERNAL_URL.

Options:

  • Add a new optional value (e.g., apiSettings.externalPathPrefix) and, when set with only teamsAppSettings.dnsName, emit https://<host><prefix>.
  • Alternatively, detect a single matching ingress.paths entry whose serviceName is the API service and append its path (only when apiSettings.dnsName is empty).

If you confirm your ingress never path-prefixes the API in supported deployments, feel free to ignore; otherwise, I can draft a targeted patch.


342-342: Nit: template spacing for readability

Consistent spacing around pipelines improves readability.

Apply:

-  value: {{ printf "https://%s" .Values.apiSettings.dnsName | quote}}
+  value: {{ printf "https://%s" .Values.apiSettings.dnsName | quote }}
tests/unit/compose/docker-compose-internal-auth_test.go (1)

261-272: Good addition: asserting API_EXTERNAL_URL in teams-api env

Adding API_EXTERNAL_URL to expected env for compose, plugins, and dedicated-plugins variants aligns tests with the Helm-side change and improves parity coverage.

Minor DRY suggestion: consider a helper to build the baseline expected env for teams-api (with optional additions like FIFTYONE_PLUGINS_DIR) to reduce duplication across these cases.

Also applies to: 343-355, 425-437

tests/unit/helm/api-deployment_test.go (1)

877-953: Great precedence test; consider adding fallback-only case and input sanitization follow-up

  • The overrideExternalApiUrl test correctly asserts precedence of apiSettings.dnsName over teamsAppSettings.dnsName and the https:// prefix. Nicely done.
  • Suggestion: Add a test where only teamsAppSettings.dnsName is set (apiSettings.dnsName unset) to validate the intended fallback.
  • Optional hardening (follow-up in chart code, not required for this PR): sanitize dnsName to avoid double schemes if a user accidentally includes “http(s)://” in values (e.g., don’t produce https://https://host). Tests could then cover this.

You can add a focused fallback test like this:

@@ func (s *deploymentApiTemplateTest) TestContainerEnv() {
         {
             "overrideExternalApiUrl",
             map[string]string{
                 "apiSettings.dnsName":      "external-api-url:443",
                 "teamsAppSettings.dnsName": "external-app-url:443",
             },
             func(envVars []corev1.EnvVar) {
                 expectedEnvVarJSON := `[
                   {
                     "name": "API_EXTERNAL_URL",
                     "value": "https://external-api-url:443"
                   },
                   {
                     "name": "CAS_BASE_URL",
                     "value": "http://teams-cas:80/cas/api"
                   },
                   ...
                 ]`
                 var expectedEnvVars []corev1.EnvVar
                 err := json.Unmarshal([]byte(expectedEnvVarJSON), &expectedEnvVars)
                 s.NoError(err)
                 s.Equal(expectedEnvVars, envVars, "Envs should be equal")
             },
         },
+        {
+            "fallbackToTeamsAppDnsName",
+            map[string]string{
+                // Intentionally omit apiSettings.dnsName to test fallback
+                "teamsAppSettings.dnsName": "external-app-url:443",
+            },
+            func(envVars []corev1.EnvVar) {
+                expectedEnvVarJSON := `[
+                  {
+                    "name": "API_EXTERNAL_URL",
+                    "value": "https://external-app-url:443"
+                  },
+                  {
+                    "name": "CAS_BASE_URL",
+                    "value": "http://teams-cas:80/cas/api"
+                  },
+                  {
+                    "name": "FIFTYONE_AUTH_SECRET",
+                    "valueFrom": {"secretKeyRef": {"name": "fiftyone-teams-secrets", "key": "fiftyoneAuthSecret"}}
+                  },
+                  {
+                    "name": "FIFTYONE_DATABASE_NAME",
+                    "valueFrom": {"secretKeyRef": {"name": "fiftyone-teams-secrets", "key": "fiftyoneDatabaseName"}}
+                  },
+                  {
+                    "name": "FIFTYONE_DATABASE_URI",
+                    "valueFrom": {"secretKeyRef": {"name": "fiftyone-teams-secrets", "key": "mongodbConnectionString"}}
+                  },
+                  {
+                    "name": "FIFTYONE_ENCRYPTION_KEY",
+                    "valueFrom": {"secretKeyRef": {"name": "fiftyone-teams-secrets", "key": "encryptionKey"}}
+                  },
+                  {
+                    "name": "MONGO_DEFAULT_DB",
+                    "valueFrom": {"secretKeyRef": {"name": "fiftyone-teams-secrets", "key": "fiftyoneDatabaseName"}}
+                  },
+                  {
+                    "name": "FIFTYONE_ENV",
+                    "value": "production"
+                  },
+                  {
+                    "name": "FIFTYONE_INTERNAL_SERVICE",
+                    "value": "true"
+                  },
+                  {
+                    "name": "GRAPHQL_DEFAULT_LIMIT",
+                    "value": "10"
+                  },
+                  {
+                    "name": "LOGGING_LEVEL",
+                    "value": "INFO"
+                  }
+                ]`
+                var expectedEnvVars []corev1.EnvVar
+                err := json.Unmarshal([]byte(expectedEnvVarJSON), &expectedEnvVars)
+                s.NoError(err)
+                s.Equal(expectedEnvVars, envVars, "Envs should be equal")
+            },
+        },

If you decide to sanitize schemes in the helm template later, I can propose a small helper to strip any leading “http://” or “https://” before prefixing.

📜 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 17c1182 and c353158.

⛔ Files ignored due to path filters (3)
  • docker/common-services.yaml is excluded by !**/*.yaml
  • helm/fiftyone-teams-app/values.schema.json is excluded by !**/*.json
  • helm/fiftyone-teams-app/values.yaml is excluded by !**/*.yaml
📒 Files selected for processing (7)
  • docker/internal-auth/env.template (1 hunks)
  • docker/legacy-auth/env.template (1 hunks)
  • helm/fiftyone-teams-app/README.md (1 hunks)
  • helm/fiftyone-teams-app/templates/_helpers.tpl (1 hunks)
  • tests/unit/compose/docker-compose-internal-auth_test.go (3 hunks)
  • tests/unit/compose/docker-compose-legacy-auth_test.go (5 hunks)
  • tests/unit/helm/api-deployment_test.go (6 hunks)
🧰 Additional context used
🪛 markdownlint-cli2 (0.17.2)
helm/fiftyone-teams-app/README.md

477-477: Line length
Expected: 80; Actual: 456

(MD013, line-length)

⏰ 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). (7)
  • GitHub Check: helm-unit / unit-helm
  • GitHub Check: docker-unit / integration-compose-legacy
  • GitHub Check: docker-unit / integration-compose-internal
  • GitHub Check: helm-integration / integration-helm
  • GitHub Check: docker-unit / unit-compose
  • GitHub Check: pre-commit
  • GitHub Check: docker-pulls
🔇 Additional comments (3)
docker/legacy-auth/env.template (1)

7-9: Comment update is clear and accurate

Wording now correctly calls out external orchestrators. Parity with internal-auth template is maintained.

docker/internal-auth/env.template (1)

4-6: Verify Docker Compose mapping for API_EXTERNAL_URL

I didn’t find any Docker Compose YAML wiring API_EXTERNAL_URL. Please confirm that your Compose configuration for the teams-api service includes:

services:
  teams-api:
    environment:
      API_EXTERNAL_URL: ${FIFTYONE_API_URI}
tests/unit/compose/docker-compose-legacy-auth_test.go (1)

261-272: Verify API_EXTERNAL_URL in Docker Compose configurations

The new unit and integration tests for both legacy-auth and internal-auth variants assert that teams-api’s environment includes API_EXTERNAL_URL. Since these compose files are carried in the docker/legacy-auth and docker/internal-auth directories (as submodules or fixtures), please confirm that every compose*.yaml under those folders (compose.yaml, compose.plugins.yaml, compose.dedicated-plugins.yaml, compose.delegated-operators.yaml) has:

services:
  teams-api:
    environment:
      - API_EXTERNAL_URL=${API_EXTERNAL_URL:-}

If any are missing this entry, add it to ensure the tests pass and keep Compose and Helm in sync.

@findtopher findtopher 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.

Seems reasonable to me

@kaixi-wang kaixi-wang merged commit 08a8384 into release/v2.11.0 Aug 25, 2025
11 checks passed
@kaixi-wang kaixi-wang deleted the add-external-api-url branch August 25, 2025 16:51
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.

4 participants