Skip to content

Fill ALB_NAME with the reader's own load balancers #116

Open

Description

@AriaEdo

Summary

Add ALB_NAME to the placeholder tokens that docs-vars.js marks for a signed-in reader. Hovering ALB_NAME shows the ALBs in the reader's current project, so they can copy a name or the whole code block filled in, as they already can with your-project-id.

Depends on datum-cloud/cloud-portal#1787 (merged, closes cloud-portal#1786). Instead of adding project.albs to session-status, which holds the navbar loader on every page, the portal now has a separate route:

GET /api/website/projects/:projectId/albs
→ 200 { "items": [{ "name": "...", "displayName": "..." }], "truncated": true }
  • Same website group as session-status: exact-origin CORS with credentials, rate limiter, session cookie.
  • One metadata-only LIST with the reader's own token, capped at 500 items. truncated: true is set only when the cap was hit.
  • displayName comes from the app.kubernetes.io/name annotation (the portal's "chosen name") and is omitted when unset.
  • Cached 60 seconds per user, project, and type, so a new ALB can take up to a minute to show.
  • Errors: 401 signed out, 403 foreign or missing project, 400 invalid project id, 404 unknown type, 429 rate limited, 502 anything else.

Why

ALB_NAME is one of the most used placeholders in the docs, and the only common one readers still swap by hand:

Page Uses
alb/observability.mdx 7 (datumctl alb describe, MetricsQL gateway_name="ALB_NAME")
alb/operations/overview.mdx 6
alb/authentication/basic-auth.mdx 5
connectors/observability.mdx 3
alb/authentication/overview.mdx 2
domain-dns/point-to-alb.mdx 1

The MetricsQL queries already fill PROJECT_ID. Without ALB_NAME the copied query still won't run.

Changes

docs-vars.js

  • Add ALB_NAME to TOKEN_PATTERN and to the fill() pre-check (it skips any <code> without your-, PROJECT_ID, or ALB_NAME).
  • After window.datumSessionStatus resolves with a valid project.name, fetch /api/website/projects/{project}/albs with credentials: 'include' and a timeout. Mark the other tokens first. The ALB fetch must not delay them.
  • Keep only entries whose name matches NAME_PATTERN. Treat any non-2xx, network error, or bad body as "no ALBs".
  • Add a TIP_COPY['ALB_NAME'] entry ("Your load balancer") with a link to the project's load balancer list in the portal (/project/{project}/alb).
  • Hover card:
    • One ALB: works like your-project-id. Shows the value, with Copy value and Copy code with my values.
    • Several ALBs: lists them (name, plus displayName when set). Nothing is selected by default. The reader picks one, and the pick applies to every ALB_NAME on the page. Both copy buttons stay disabled until they pick. This matters on pages like datumctl alb delete ALB_NAME --yes, where a wrong default does real damage.
    • truncated: say the list shows the first 500 and link to the full list in the portal.
    • No ALBs, request failed, or no project: ALB_NAME isn't marked, as today.
  • Today values maps each token to one string. ALB_NAME needs a list and a selection, so filledCode() and the copy buttons need to handle that. "Copy code with my values" from another token's card leaves an unpicked ALB_NAME as written.

Content

  • alb/operations/overview.mdx uses ALB_NAME in datumctl alb create ALB_NAME ... and in the --display-name row ("If you omit ALB_NAME…"). There it's a new name, so filling it with an existing ALB is wrong. Rename those to NEW_ALB_NAME. The token regex won't match it.
  • Check the other uses for the same case.

README.md (Placeholders)

  • Add a row: ALB_NAME → one of the reader's ALBs in the current project, chosen on hover when there are several. Use it for an existing load balancer (datumctl alb describe|logs|delete|auth, gateway_name= in metrics).
  • Update the rule that lists ALB_NAME as never replaced. Add NEW_ALB_NAME for creating one.

Resolved questions

  • Is gateway_name the same as the ALB's HTTPProxy name? Yes. The portal's own metrics query gateway_name with the proxy name (app/features/edge/proxy/metrics/queries.ts in cloud-portal), so the MetricsQL blocks can use ALB_NAME.
  • Is the list capped? Yes, at 500, with truncated: true when hit.

Acceptance criteria

  • With one ALB in the current project, hovering ALB_NAME shows it, and both copy buttons fill it in
  • With several ALBs, the reader must pick one before either copy button works. The pick applies to every ALB_NAME on the page
  • With no ALBs, a failed ALB request, or signed out, ALB_NAME stays a plain placeholder with no errors in the console
  • The other tokens are marked without waiting for the ALB request
  • NEW_ALB_NAME in the create section is never marked
  • README Placeholders section updated
  • Tested on website.staging.env.datum.net against a staging portal that includes cloud-portal#1787

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions