Skip to content

feat(control-plane): pin per-tenant image versions for fleet rollout and rollback - #8056

Merged
JSONbored merged 1 commit into
JSONbored:mainfrom
cleanjunc:feat/4898-pinned-version-rollout
Jul 22, 2026
Merged

feat(control-plane): pin per-tenant image versions for fleet rollout and rollback#8056
JSONbored merged 1 commit into
JSONbored:mainfrom
cleanjunc:feat/4898-pinned-version-rollout

Conversation

@cleanjunc

Copy link
Copy Markdown
Contributor

Summary

Closes #4898.

Implements the fleet rollout mechanism exactly as the issue's ratified decision (2026-07-21) specifies: a pinned_version field on the control-plane's tenant record, rollout/rollback as an explicit-list update of that field, and each tenant's container reading its own pinned version at (re)start instead of a shared :latest.

  • Tenant.pinnedVersion (control-plane/src/tenant-provisioning-driver.ts): product-agnostic — the identical field for ORB and AMS tenants, per feat(control-plane): provisionTenant()/deprovisionTenant() orchestration behind an injectable driver interface (fake driver only) #7524's product-agnostic requirement. Absent/null = unpinned (release-channel default, exactly the pre-Build a fleet rollout mechanism #4898 behavior). It persists for free inside the registry record's tenant JSON (tenant-registry.ts needed zero interface changes; pre-existing KV records read back unpinned).
  • Container (re)start (control-plane/src/container-driver.ts): a Cloudflare Container binding is fixed to one image at the wrangler.jsonc level (that file's own documented constraint), so per-tenant versioning can't swap the image reference binding-side — instead a pinned tenant's version rides into stub.start()'s existing envVars option as LOOPOVER_PINNED_VERSION, which the container's own entrypoint reads to resolve its versioned artifact — the ratified "each tenant's container reads its own pinned version at (re)start" mechanism. An unpinned tenant gets the exact pre-Build a fleet rollout mechanism #4898 start() call (no options object at all), pinned to a byte-identical-behavior test, so every existing tenant is untouched until a rollout pins it.
  • POST /v1/tenants/rollout (control-plane/src/http-app.ts): { names: [...], pinnedVersion: "vX" | null } — an explicit tenant-name list (no percentage/canary selector, per the issue's "don't invent one speculatively" boundary), null = explicit unpin/revert. All-or-nothing: the whole list is validated (unknown name → 404, torn-down tenant → 409, malformed body → 400) before any record is touched, so a typo'd name can never leave a fleet half rolled out. Sits behind the same Bearer wall as every other /v1/tenants/* route. GET /v1/tenants surfaces each tenant's pin for admin visibility.

Scope

  • The PR title follows type(scope): short summary Conventional Commit format, for example fix(api): restore profile access checks.
  • This PR is focused and does not mix unrelated backend, UI, MCP, docs, dependency, and deploy changes.
  • This follows CONTRIBUTING.md and does not reintroduce GitHub Pages, VitePress, site/, or CNAME.
  • I linked a currently open issue this PR resolves (e.g. Closes #123) — a linked open issue is required for every contributor PR.

Validation

  • git diff --check
  • npm run actionlint
  • npm run typecheck
  • npm run test:coverage locally; codecov/patch requires ≥99% coverage of the lines AND branches you changed (aim for 100% on your diff so CI variance does not fail near the threshold). Global coverage is a non-blocking trend with a loose 90% backstop, not the gate.
  • npm run test:workers
  • npm run build:mcp
  • npm run test:mcp-pack
  • npm run ui:openapi:check
  • npm run ui:lint
  • npm run ui:typecheck
  • npm run ui:build
  • npm audit --audit-level=moderate
  • New or changed behavior has unit/integration tests for new branches, fallback paths, and sanitizer boundaries

If any required check was skipped, explain why:

  • This diff is 100% inside control-plane/ — a standalone npm package with its own build, test runner, and coverage pipeline, none of which the root commands above touch (control-plane/** is not in the root vitest config; its CI job runs control-plane:test + control-plane:coverage). I ran the checks that actually exercise this package: npm --prefix control-plane test (tsc build + full node:test suite: 107/107 pass, including 13 new tests for this change), npm run control-plane:coverage (the same c8 harvest CI uploads to Codecov), and control-plane's cf:typecheck (the Worker tsconfig).
  • Patch coverage measured empirically by intersecting the harvested control-plane/coverage/lcov.info DA/BRDA records with git diff -U0 against upstream/main: 100% of changed lines and 100% of changed branches in all four touched source files (the codecov/patch gate applies to control-plane/ via its dedicated flag).
  • npm audit: this PR adds zero dependencies (root and control-plane/ package.json/lockfiles untouched).

Safety

  • No secrets, wallet details, hotkeys, coldkeys, user PATs, private keys, raw trust scores, private rankings, or private maintainer evidence are exposed.
  • Public GitHub text stays sanitized, low-noise, and does not imply compensation guarantees or optimization tactics.
  • Auth, cookie, CORS, GitHub App, Cloudflare, or session changes include negative-path tests.
  • API/OpenAPI/MCP behavior is updated and tested where needed.
  • UI changes use live API data or real empty/error/loading states, not production mock/demo fallbacks.
  • Visible UI changes include a UI Evidence section below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.
  • Public docs/changelogs are updated where needed; changelogs are only edited for release-prep PRs.

The two unchecked Safety boxes are N/A: no UI change of any kind (control-plane backend only).

Auth negative path: the new route is under the existing /v1/tenants/* Bearer middleware, and a test pins that an unauthenticated POST /v1/tenants/rollout gets 401. The rollout responses reuse safeRecord — a tenant's database connection details still never appear on the wire (this endpoint never touches them at all).

UI Evidence

N/A — no UI change (control-plane backend only).

Notes

  • Per-tenant independence, proven by test (the issue's acceptance criterion): the rollout test pins two of three tenants and asserts the third's record is completely untouched (no pin, no updatedAt churn); the rollback test re-pins one tenant and asserts the other's pin is unchanged; the unpin (null) path reverts one tenant while the other stays pinned.
  • The AMS-side parallel (Design: fleet rollout/versioning mechanism for many hosted AMS instances #5221) is noted in the issue as a cross-reference to keep in sync — this PR only implements the control-plane side Build a fleet rollout mechanism #4898 ratified; nothing here diverges from that shared shape (the field is product-agnostic by construction).
  • Recreating a previously torn-down tenant (POST /v1/tenants) starts it unpinned, consistent with the create route's existing "fresh provision, not a resurrection" doc comment.

@cleanjunc
cleanjunc requested a review from JSONbored as a code owner July 22, 2026 16:43
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 22, 2026
@loopover-orb

loopover-orb Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Tip

✅ LoopOver review result - approve/merge recommended

Review updated: 2026-07-22 17:27:15 UTC

7 files · 1 AI reviewer · no blockers · readiness 100/100 · CI green · clean

✅ Suggested Action - Approve/Merge

  • safe to merge

Review summary
This PR adds a `pinnedVersion` field to the tenant record and a `POST /v1/tenants/rollout` endpoint that atomically pins/unpins an explicit list of tenants, plus wires that version into the container's `start()` call as an env var while leaving unpinned tenants' `start()` call byte-identical to before. The all-or-nothing validation (name/version shape, duplicate names, unknown-tenant 404, torn-down 409) runs entirely before any `registry.upsert()` is called, so a bad request can't leave the fleet half-migrated, and the tests exercise every listed branch including the null-unpin path, KV JSON round-trip of the new field, and idempotent re-provision behavior. The change is scoped tightly to the ratified issue #4898 design and doesn't invent extra selector primitives (e.g. no percentage/canary logic), matching the stated boundary.

Nits — 5 non-blocking
  • http-app.ts:parseRolloutRequest fetches each tenant with a sequential `await deps.registry.get(name)` in a for-loop rather than `Promise.all`; fine for typical admin-driven list sizes but worth calling out if rollout lists ever grow large.
  • container-driver.ts:68's `if (pinnedVersion)` treats an empty-string pinnedVersion as unpinned by relying on JS truthiness rather than an explicit `!= null` check — harmless today since the only producer (parseRolloutRequest) already rejects blank strings, but worth a comment or explicit check if `Tenant.pinnedVersion` is ever set by another path.
  • http-app.ts's two validation loops (existence-check then update) duplicate the `existing.get(name)!` map indirection — could be simplified but it's clear as written.
  • Consider batching the per-name registry.get() calls in parseRolloutRequest's validation loop with Promise.all if tenant registry latency becomes a concern for larger rollout lists.
  • The PINNED_VERSION_ENV_VAR doc comment duplicates explanation already given in container-driver.ts's header comment — could trim one of the two for conciseness.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #4898
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 47 registered-repo PR(s), 13 merged, 33 issue(s).
Contributor context ✅ Confirmed Gittensor contributor cleanjunc; Gittensor profile; 47 PR(s), 33 issue(s).
Improvement ✅ Minor risk: clean · value: minor
Linked issue satisfaction

Addressed
The diff adds a product-agnostic pinnedVersion field to Tenant, has container (re)start resolve the version via an env var read at start rather than a shared :latest, and implements rollout/rollback as an explicit-list POST endpoint with no canary/percentage selector, matching the ratified decision.

Review context
  • Author: cleanjunc
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: Python, TypeScript, JavaScript, Scala
  • Official Gittensor activity: 47 PR(s), 33 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 22, 2026
@JSONbored
JSONbored merged commit b63fa69 into JSONbored:main Jul 22, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build a fleet rollout mechanism

2 participants