Skip to content

fix(nats): add self-managed regional placement tag - #1370

Open
sbaum1994 wants to merge 1 commit into
mainfrom
fix/nats-region-placement
Open

fix(nats): add self-managed regional placement tag#1370
sbaum1994 wants to merge 1 commit into
mainfrom
fix/nats-region-placement

Conversation

@sbaum1994

@sbaum1994 sbaum1994 commented Aug 30, 2026

Copy link
Copy Markdown
Collaborator

TL;DR

Add the logical NCP region tag required for JetStream to place region-scoped request queues on the bundled self-managed NATS cluster.

Additional Details

The stack supplied dc:ncp but not aws-region:ncp. Regional request-queue streams select the latter tag, so their placement could fail even though NATS was healthy.

The NATS chart now includes both tags by default. The self-managed stack passes the tag list to the currently released chart and still permits environment overrides. Focused tests cover the chart render, default stack values, and custom stack tags.

Customer Release Notes

Self-managed NATS now accepts region-scoped function request queues for the default NCP region.

Plan Summary

The NATS server configuration gains one bounded placement tag. No pods, storage, or resource requests change.

Usage

No operator action is required. Existing environments can replace the default tag list through nats.config.merge.server_tags.

For the Reviewer

Please focus on the Helmfile value merge and the environment override case in nats-placement-tags.sh.

For QA

QA needed: no additional manual QA beyond the final BDD integration run.

Tests run:

  • make test in deploy/helm/nats
  • deploy/stacks/self-managed/tests/nats-placement-tags.sh
  • Shell syntax checks
  • git diff --check

The first chart test attempt identified a missing local Helm repository. Adding the repository declared in Chart.yaml resolved the prerequisite, and the suite passed.

Notes

The autoscaler smoke in #1363 exercises the regional request-queue path after this PR is available on main.

Issues

Closes #1365

Related Pull Requests

Dependencies

No new or updated third-party dependencies. NOTICE is unchanged.

Checklist

  • I am familiar with the Contributing Guidelines.
  • I have signed off my commits for Developer Certificate of Origin (DCO) compliance.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

Summary by CodeRabbit

  • New Features

    • Added configurable NATS placement tags, including logical and AWS-region identifiers.
    • Supports environment-level overrides for NATS placement tags.
    • Preserved JetStream persistent storage-class configuration alongside the new settings.
  • Tests

    • Added coverage confirming default placement tags and custom environment overrides.
    • Helm rendering checks now verify the default server tags.

Expose the logical NCP region to JetStream so regional request queues can be placed on the bundled NATS cluster.

Closes #1365

Signed-off-by: Stephanie Baum <sbaum@nvidia.com>
@sbaum1994
sbaum1994 requested review from a team as code owners August 30, 2026 18:27
@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 26eb4239-110e-41e3-bad2-6f7255b424bc

📥 Commits

Reviewing files that changed from the base of the PR and between de77aa4 and 129e9a3.

📒 Files selected for processing (6)
  • deploy/helm/nats/scripts/test-render-auth-callout.sh
  • deploy/helm/nats/values.yaml
  • deploy/stacks/self-managed/Makefile
  • deploy/stacks/self-managed/environments/base.yaml
  • deploy/stacks/self-managed/global.yaml.gotmpl
  • deploy/stacks/self-managed/tests/nats-placement-tags.sh

Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review.


📝 Walkthrough

Walkthrough

The NATS chart and self-managed stack now include aws-region:ncp with dc:ncp. The stack supports environment-level tag overrides. Chart and stack render tests validate default and custom tags.

Changes

NATS placement tags

Layer / File(s) Summary
NATS chart defaults
deploy/helm/nats/values.yaml, deploy/helm/nats/scripts/test-render-auth-callout.sh
The chart adds aws-region:ncp to the default server_tags. The render test checks both default tags.
Self-managed tag propagation
deploy/stacks/self-managed/global.yaml.gotmpl, deploy/stacks/self-managed/environments/base.yaml
The self-managed stack defines default server_tags, supports environment overrides, and renders them with the existing JetStream storage configuration.
Placement tag validation
deploy/stacks/self-managed/Makefile, deploy/stacks/self-managed/tests/nats-placement-tags.sh
The test target runs a render test that verifies default tags and environment-specific replacements.

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

Merge Risk: ⚪ Minimal · up to 129e9

This PR adds the required regional placement tag for self-managed NATS without changing pods, storage, or resource requests. No actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: sanjay-saxena

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (4 skipped: 4 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the valid Conventional Commits format fix(nats): subject and accurately describes the regional placement-tag fix.
Linked Issues check ✅ Passed The changes satisfy issue #1365: they add aws-region:ncp to chart defaults, pass both tags through the self-managed stack, preserve storage configuration, support environment overrides, and add focu…
Out of Scope Changes check ✅ Passed All changes directly support the regional NATS placement-tag objective, including configuration, rendering, override handling, and focused test integration. No unrelated changes are identified.
Full details: Linked Issues check

Explanation

The changes satisfy issue #1365: they add aws-region:ncp to chart defaults, pass both tags through the self-managed stack, preserve storage configuration, support environment overrides, and add focused render tests.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (4 skipped: 4 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/nats-region-placement

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

@sbaum1994

Copy link
Copy Markdown
Collaborator Author

The apparent historical success is explained by two different components being able to create the same request-queue stream.

  • The NVCF API creates rq_<region>_<function-version> while establishing a worker consumer. Its placement is dc:<region>.
  • Invocation publishes to that stream. If the stream is missing, invocation lazily creates it with placement aws-region:<region>.
  • The bundled self-managed NATS server advertised only dc:ncp.

That mismatch was usually masked while at least one worker existed because the API created the stream first. Invocation found the existing stream and never exercised its own aws-region:ncp placement path.

sequenceDiagram
    participant Client
    participant Invocation
    participant API as NVCF API
    participant Worker
    participant NATS

    Note over NATS: Before this PR: server_tags = dc:ncp

    rect rgb(235, 255, 235)
        Note over API,Worker: Existing worker or minimum instances greater than zero
        Worker->>API: Establish request consumer
        API->>NATS: Create rq_ncp_VERSION with placement dc:ncp
        NATS-->>API: Stream created
        Client->>Invocation: Invoke function
        Invocation->>NATS: Publish rq.ncp.VERSION.REQUEST
        NATS-->>Invocation: Acknowledged by existing stream
        Note over Invocation,NATS: Invocation's aws-region:ncp create path is not reached
    end

    rect rgb(255, 240, 235)
        Note over API,Worker: Autoscaler allows scale to zero, so no worker creates the stream
        Client->>Invocation: First invocation from zero
        Invocation->>NATS: Publish rq.ncp.VERSION.REQUEST
        NATS-->>Invocation: StreamNotFound
        Invocation->>NATS: Create rq_ncp_VERSION with placement aws-region:ncp
        NATS-->>Invocation: No eligible server has that tag
    end
Loading

The autoscaler does not introduce or consume this placement tag. It exposes the latent mismatch by making the no-worker, no-precreated-stream path normal. Vanity gateway is not involved in the JetStream lifecycle; it only provides the alternate ingress path that the smoke coverage also exercises.

This PR stays focused on making the bundled NATS server eligible for both existing creators by advertising dc:ncp and aws-region:ncp. The separate issue for the self-managed invocation-region value being dropped will track that configuration paper cut without changing this PR's placement fix.

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.

fix(nats): add the self-managed regional placement tag

1 participant