Skip to content

Allow adding regions to existing namespaces - #402

Open
adityavad wants to merge 4 commits into
temporalio:mainfrom
adityavad:adityav/allow-region-addition
Open

Allow adding regions to existing namespaces#402
adityavad wants to merge 4 commits into
temporalio:mainfrom
adityavad:adityav/allow-region-addition

Conversation

@adityavad

@adityavad adityavad commented Feb 13, 2026

Copy link
Copy Markdown

Overview

Allow adding regions to an existing namespace via Terraform, enabling multi-region namespaces (MRN) without recreating the namespace. Region removals and replacements remain blocked for safety.

Closes #401

Changes

  • Replace areRegionsEqual (which blocked all region changes) with classifyRegionChanges, which distinguishes additions from removals — additions are allowed, removals/replacements are blocked
  • Extract region update logic into a testable updateNamespaceWithRegions function behind a namespaceRegionUpdateClient interface
  • Use AddNamespaceRegion for region additions instead of passing planned region order through UpdateNamespace
  • Preserve current region order in UpdateNamespace calls to avoid accidental failover from list reordering
  • Handle InvalidArgument "nothing to change" from UpdateNamespace when the only change is a region addition — skip to AddNamespaceRegion instead of failing
  • Add schema-level region count validation (SizeBetween(1, 2))

Testing

  • Unit tests for classifyRegionChanges (6 cases: no-change, reorder, addition, prepend, replacement, removal)
  • Unit tests for updateNamespaceWithRegions using a fake client (region addition sequence, removal blocking before API calls, "nothing to change" skip-to-add scenario)
  • Tested on our local terraform temporal repo:

Before change:
Screenshot 2026-02-17 at 3 04 24 PM
After change:
Screenshot 2026-02-17 at 3 04 42 PM

Checklist

  • This code has been self-reviewed
  • Tests were added/updated as appropriate

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Replace the blanket "regions cannot be changed" error with a more
nuanced check that allows region additions while still blocking
removals and replacements. This enables users to add a second region
to enable multi-region namespaces (MRN) via Terraform without
recreating the namespace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adityavad
adityavad force-pushed the adityav/allow-region-addition branch from 254535a to cb5b754 Compare February 13, 2026 21:38
adityavad and others added 2 commits February 13, 2026 17:02
…ions

UpdateNamespace now receives the current region list (preserving order)
instead of the planned list, preventing accidental active-region
migration from list reordering. Region additions are performed via
separate AddNamespaceRegion API calls after the main update completes.

Adds unit tests for getAddedRegions (4 cases) and getRegionUpdatePlan
(6 cases) covering safe add, reorder handling, removal blocking, and
replacement detection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Refactor region update logic into a testable updateNamespaceWithRegions
function behind a namespaceRegionUpdateClient interface. Add schema-level
region count validation (1-2 entries) and a sentinel error for blocked
removals. Replace old TestAreRegionsEqual/TestIsRegionRemoval with
TestGetRegionUpdatePlan covering all cases, and add fake-client tests for
the full update+add sequence and early removal blocking.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adityavad
adityavad force-pushed the adityav/allow-region-addition branch from 04e150b to 6be284a Compare February 13, 2026 23:12
When the only change is adding a region, UpdateNamespace receives a spec
identical to the current state (since we preserve currentRegions) and
returns InvalidArgument "nothing to change". Detect this case and skip
to AddNamespaceRegion instead of failing.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@adityavad
adityavad marked this pull request as ready for review February 17, 2026 20:09
@adityavad
adityavad requested a review from a team as a code owner February 17, 2026 20:09
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.

[Feature Request] "safely" add region to an existing namespace without triggering HA migration

2 participants