fix(setup): seed the REST site record and fix the worker DB target (release/v2.0)#3340
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
🌿 Preview your docs: https://nvidia-preview-pull-request-3340.docs.buildwithfern.com/infra-controller |
🔐 TruffleHog Secret Scan✅ No secrets or credentials found! Your code has been scanned for 700+ types of secrets and credentials. All clear! 🎉 🕐 Last updated: 2026-07-09 23:19:33 UTC | Commit: ea486b6 |
🔍 Container Scan Summary
Per-CVE detail lives in the per-service |
…VIDIA#3284) <!-- Describe what this PR does --> Two defects left a fresh site with an empty `nicocli site list` despite a healthy, handshaked site-agent: 1. setup.sh minted a site UUID and the site-agent bootstrap Job POSTed /v1/site to site-manager, which creates the Site CR + OTP — but never the site row in the REST database. The agent handshakes under an identity no REST site matches, so its inventory is dropped. 2. The nico-pg-cluster consolidation (NVIDIA#3081) missed the workflow subchart: site/cloud workers stayed on the legacy postgres.postgres/nico database (zero tables) and failed every DB activity with SQLSTATE 42P01 (relation "site" does not exist), so no site could leave Pending. Both fixes are contained in setup.sh — the bootstrap Job's existing POST /v1/site flow (Site CR + OTP + temporal certs) is untouched and simply runs after the DB row exists, under the same UUID: - Resolve the site UUID instead of blindly minting: explicit NICO_SITE_UUID (bind to a pre-existing site) -> CLUSTER_ID from a prior install's site-agent StatefulSet (stable reruns) -> an existing REST site row with our name (adopt; idempotent reprovision) -> mint. Then seed the REST DB directly with the same record shape as forged's per-env envs/*/carbide-rest/site.sql: a 'default' infrastructure_provider for the org (NICO_ORG, default ncx) plus a Pending site row named after NICO_SITE_NAME / values.yaml siteName, id = created_by = the resolved UUID. All inserts are guarded (WHERE NOT EXISTS) and the seed waits for the REST migrations to have created the tables. IdP-agnostic: no API token required. - Delete a site-registration secret bound to a stale UUID so rebinding CLUSTER_ID re-bootstraps instead of silently keeping the old identity. - Inject worker DB values at install time via the existing REST creds temp file: nico-rest-workflow now targets nico-pg-cluster/nico_rest as nico-rest.nico with the db-creds secret, aligned with nico-rest-api. ## Related issues <!-- Refer to existing GitHub issues here --> ## Type of Change <!-- Check one that best describes this PR --> - [ ] **Add** - New feature or capability - [ ] **Change** - Changes in existing functionality - [X] **Fix** - Bug fixes - [ ] **Remove** - Removed features or deprecated functionality - [ ] **Internal** - Internal changes (refactoring, tests, docs, etc.) ## Breaking Changes <!-- If checked, describe the breaking changes and migration steps --> <!-- Breaking changes are not generally permitted, please discuss on a GitHub discussion or with the development team if you believe you need to break a backward compatibility guarantee --> - [ ] **This PR contains breaking changes** ## Testing <!-- How was this tested? Check all that apply --> - [ ] Unit tests added/updated - [ ] Integration tests added/updated - [X] Manual testing performed - [ ] No testing required (docs, internal refactor, etc.) tested this end to end on dev6 ## Additional Notes <!-- Any additional context, deployment notes, or reviewer guidance -->
ea486b6 to
13afa48
Compare
Cherry-pick of #3284 (
7b35d52) ontorelease/v2.0, following the same process as #3182.Bind the site-agent to a REST-created site and fix the workflow-worker DB target. Two defects left a fresh site with an empty
nicocli site listdespite a healthy, handshaked site-agent: the site UUID was minted without any REST database record behind it (the bootstrap Job'sPOST /v1/sitecreates only the Site CR + OTP), and the workflow workers missed the nico-pg-cluster consolidation (#3081), failing every DB activity with SQLSTATE 42P01 so no site could ever leavePending.Changes
setup.sh: resolve the site UUID instead of blindly minting — explicitNICO_SITE_UUID(bind to a pre-existing site), else the prior install'sCLUSTER_ID(site-agent ConfigMap), else adopt an existing REST site with the same name, else mint. Then seed the REST DB directly (same record shape as forged's per-envsite.sql): adefaultinfrastructure_providerfor the org plus aPendingsite row named aftersiteName, with the v2 networking capabilities (native_networking,network_security_group,flow) enabled and thestatus_detailrow the REST create handler writes. All inserts idempotent (WHERE NOT EXISTS); waits up to 120 s for the REST migrations. IdP-agnostic — no API token needed. The bootstrap Job's existingPOST /v1/siteflow is untouched and runs after the DB row exists, under the same UUID.setup.sh: inject workflow-worker DB values at install time via the existing REST creds temp file —nico-rest-workflownow targetsnico-pg-cluster/nico_restasnico-rest.nicowith thedb-credssecret, aligned withnico-rest-api.setup.sh: delete asite-registrationsecret bound to a stale UUID so rebindingCLUSTER_IDre-bootstraps; input validation (UUID format, site-name/org charset) before SQL interpolation; quoting-agnosticsiteNameparsing.quick-start.md,helm-prereqs/README.md,configurability.md):NICO_SITE_UUIDresolution behavior documented consistently.Related Issues
N/A
Type of Change
Fix - Bug fixes
Breaking Changes
None.
Testing
Manual end-to-end validation on dev6