157 lines
11 KiB
Markdown
157 lines
11 KiB
Markdown
# Deployment record — wonder-app-vq03 + wonder-app-vq04 (QA) — 2026-10-22 — `b3021e7c` → `3808b49f`
|
||
|
||
> **Status lives in Gitea.** Open items from this file are tracked as issues on gitea.dohertylan.com/dohertj2/ScadaBridge (label `migrated`, 2026-11-06). This file is a historical/design record — do not track status here; file new work as an issue.
|
||
|
||
This record covers the **QA two-host topology**:
|
||
|
||
| Box | Central node | Site-a node |
|
||
|---|---|---|
|
||
| vq03 `10.220.158.2` | central-a | node-a |
|
||
| vq04 `10.220.158.3` | central-b | node-b |
|
||
|
||
- Centrals on :8085; site gRPC on :8083, health on :8084.
|
||
- LocalDb replication is on.
|
||
- The shared config DB `ScadaBridge` is on `wonder-sql-vq03`.
|
||
|
||
The package is the one DEV received the same day. See `2026-10-22-wonder-app-vd03-3808b49f.md` for the build delta: 191 commits, including site secrets via Deploy Artifacts, the 2026-10-21 review remediation, and Topology #38/#39/#40.
|
||
|
||
The deploy ran from the Mac with the `winrm` CLI. The zip and SQL went over SMB, followed by one prep script per box and seven window calls, all from one mode-switched script.
|
||
|
||
## Pre-flight (breaking-change check)
|
||
|
||
| Area | Change in delta | QA state | Verdict |
|
||
|---|---|---|---|
|
||
| Schema | 57 → 58 `ReviewRemediationIndexes` (5 additive indexes) | 57; AuditLog 2 132 rows, AuditLogEntries 515; `ps_AuditLog_Month` present; Enterprise | OK |
|
||
| `Secrets:Replication:Enabled` ≠ false → startup failure | — | `false` in appsettings.json on both boxes; not in the service env | OK (stale `Mode`/`GrpcHub` keys log one ignore-Warning) |
|
||
| `JwtSigningKey` ≥ 32 bytes; must match on both centrals now that the CLI uses bearer tokens | — | 64 chars on both; identical hash | OK |
|
||
| `MachineDataDb`, `Transport:SchemaVersionMajor`, `JwtRefreshThresholdMinutes` removed | — | `MachineDataDb` still in the Central env and appsettings; the others are unset | Ignored, harmless |
|
||
| Actor-name deploy gate | — | 33 instance, script, alarm, native-source and connection names | All valid |
|
||
| LocalDb replicated set 10 → 12 tables (`deployed_secrets`, `secret_mirror_status`) | Registered-table digests are compared fail-closed | Both site nodes upgraded in one window | OK; the pair reconnected, backlog 0 |
|
||
| Data-connection `secret:` references | Artifact deploy resolves them centrally | The artifact hash is unchanged after the deploy, so there are no references | OK |
|
||
| Service env | — | Re-exported during prep; identical to the 2026-09-28 export on all four services | OK |
|
||
|
||
**No appsettings change.** The three files were kept and restored on each box, with matching hashes:
|
||
|
||
| Box | appsettings.json | appsettings.Central.json | appsettings.Site.json |
|
||
|---|---|---|---|
|
||
| vq03 | `F94000B1` | `D1320FA8` | `4CBAF66C` |
|
||
| vq04 | `F94000B1` | `2FD3EC4C` | `D0C1AF05` |
|
||
|
||
## Upgrade
|
||
|
||
| Item | Value |
|
||
|---|---|
|
||
| Build | `main` @ **`3808b49f`**, ProductVersion `1.0.0+3808b49fc7558a177219d00eac97747b28850a80`, all four nodes |
|
||
| Artifact | `E:\psrem-stage\3808b49f\scadabridge.zip` on both boxes; 125 543 156 B; SHA-256 `770BB992…5FB1098E47`, re-verified on each box; app 1028 files, cli 223 |
|
||
| Migration | `ReviewRemediationIndexes.sql` (idempotent) applied with `sqlcmd -C -b -I` from vq03 while both centrals were stopped; 57 → 58. SQL Server warned that `IX_AuditLog_Kind_Occurred` has a maximum key of 8 008 bytes against the 1 700-byte limit. `Kind` holds short enum names, so this is benign |
|
||
| DB backup | `F:\MSSQL\BACKUP\ScadaBridge_pre-3808b49f_20261022T152457.bak` on wonder-sql-vq03 (COPY_ONLY, CHECKSUM, COMPRESSION; VERIFYONLY valid) |
|
||
| Binary backups | `app.bak.20261022T152457` / `cli.bak.20261022T152457` plus `_appsettings-keep-20261022T152457` on both boxes |
|
||
| Notes on box | `E:\ApiInstall\ScadaBridge\_DEPLOY-NOTES-3808b49f.txt` |
|
||
|
||
| Step | Local time |
|
||
|---|---|
|
||
| Stop Site vq04 (**window opens**) | 15:29:58 → 15:30:28 |
|
||
| Stop Site vq03 | 15:30:37 → 15:30:47 |
|
||
| Stop Central vq04, swap vq04 | 15:30:55 → 15:31:12 |
|
||
| Stop Central vq03, migrate, swap vq03, start Central vq03 → ready | 15:31:19 → 15:31:49 |
|
||
| Start Central vq04 → ready | 15:32:00 → 15:32:05 |
|
||
| Start Site vq03 → ready | 15:32:12 → 15:32:21 |
|
||
| Start Site vq04 → ready (**window closes**) | 15:32:30 → 15:32:33 |
|
||
|
||
**Downtime: 2 min 35 s.**
|
||
|
||
## Verification (from the Mac)
|
||
|
||
- **Centrals:** `/health/ready` 200 on both. `database`, `akka-cluster` (memberCount 2, unreachable 0) and `required-singletons` are all Healthy. `/health/active` is 200 on vq03 and 503 on vq04, the same active node as before.
|
||
- **Sites:** `/health/ready` 200 on both. `localdb` shows `replicationConnected:true`, backlog 0. `/health/active` is 200 on vq03 and 503 on vq04.
|
||
- **Auth:**
|
||
- `POST /auth/token` returns 200; the CLI now runs on bearer tokens against QA.
|
||
- `/management` without credentials returns 401, unchanged.
|
||
- **Snapshots:**
|
||
- Z28061–Z28069: 242 Good / 2 Bad on both sides of the window. Z28063 showed 114 Uncertain on the first read while its subscriptions settled, then matched.
|
||
- Alarm counts are unchanged (14, or 8 on Z28062).
|
||
- ZIPSEN is not deployed, as before.
|
||
- **Deploy Artifacts:** deployment `d7505cd8…`, site-a success. The hash is unchanged (`sha256:d79ba1a3…`); `ArtifactsDeployedAt` is 19:32:56Z.
|
||
- **Logs** (pulled over SMB):
|
||
- The usual first-probe `akka-cluster … Removed` ERR lines.
|
||
- vq03 site logged four `Replication session … faulted` Warnings between 15:32:16 and 15:32:29, while vq04's site was still down. The session has been connected since.
|
||
- New startup Warnings: Secrets per-node SQLite on a clustered central, and the stale `Secrets:Replication`/`GrpcHub` keys.
|
||
- No other ERR or FTL lines.
|
||
- **Smoke:** `flow-debug run-method` of `SimpleAlarmStatusRequest` (id 9) with `SAPID=000000` returned InboundRequest → BTDB DbCall (1 row) → Response Ok.
|
||
|
||
## Rollback
|
||
|
||
1. Stop Site vq04 → vq03, then Central vq04 → vq03.
|
||
2. On each box rename `app` → `app.failed` and `app.bak.20261022T152457` → `app`; do the same for `cli`.
|
||
3. Start Central vq03 → vq04, then Site vq03 → vq04.
|
||
|
||
The indexes are additive, so `b3021e7c` runs against 58 migrations. For an exact DB, `RESTORE DATABASE [ScadaBridge] FROM DISK = 'F:\MSSQL\BACKUP\ScadaBridge_pre-3808b49f_20261022T152457.bak' WITH REPLACE` with everything stopped.
|
||
|
||
## Follow-up, same day: shared key and secret stores on the central pair (15:45–15:50)
|
||
|
||
**Pre-check (SMB copies of the per-node files):**
|
||
- Inbound keys: vq03 held 3 keys (`MESTestKey`, `MES_Key`, `delmia-notifier-qa`); vq04 held **none**. Before this change, a failover to vq04 would 401 every inbound client.
|
||
- Secrets: both central SQLite stores held **0** secrets, so there was nothing to migrate (the secrets store has no automatic importer).
|
||
- SQL login: `db_owner` on `ScadaBridge`.
|
||
|
||
**Change:**
|
||
|
||
| Where | Change | How |
|
||
|---|---|---|
|
||
| `appsettings.Central.json` (both boxes) | `ScadaBridge:InboundApi:ApiKeyStore:Provider=SqlServer` (connection string defaults to the ConfigurationDb) and `Secrets:Store:Provider=SqlServer`, plus a `_comment_SharedStores` note | Edited on the Mac, pushed over SMB while Central was stopped |
|
||
| `appsettings.json` (both boxes) | Removed the stale `Secrets:Replication` (incl. `Mode`) and `Secrets:GrpcHub` blocks and the dead `SqlServer` sync keys | Edited on the Mac, pushed over SMB while Central was stopped |
|
||
| Central service registry env (both) | Added `Secrets__SqlServer__ConnectionString` | Copied on the box from `ScadaBridge__Database__ConfigurationDb`; the value never left the box. Site services untouched |
|
||
|
||
Backups: `E:\psrem-stage\3808b49f\_envbak-ScadaBridge-Central-pre-sharedstores-<ts>.reg` and `E:\ApiInstall\ScadaBridge\_appsettings-keep-sharedstores-<ts>`, on each box.
|
||
|
||
**Sequence:**
|
||
1. Both centrals stopped together (15:45:42 / 15:45:55).
|
||
2. vq03 started → ready 15:46:26; vq04 started → ready 15:46:39. The `zbauth` and `zbsecrets` schemas were created in `ScadaBridge`.
|
||
3. vq03 imported **3 keys + 3 audit rows**; vq04 imported 0.
|
||
|
||
**Defect found and fixed:** on both nodes the import's rename to `*.imported` failed with `IOException: … being used by another process`.
|
||
- Cause: the library importer reads the file through a pooled `SqliteConnection`, whose handle outlives the connection. Windows refuses to rename an open file (Linux doesn't mind, so the rig never showed it).
|
||
- Reproduced on the Windows build box: the rename fails without `SqliteConnection.ClearAllPools()` and succeeds with it.
|
||
- Code fix: `6ed6800b`, which clears the pools before the rename, plus a regression test and a runbook note.
|
||
- On QA the files were renamed by hand with each Central stopped:
|
||
- vq04 first. Its first attempt hit the same lock because its Host process was still exiting, and the script stopped before restarting it, so **vq04's Central was down 15:48:55–15:50:24**.
|
||
- vq03 at 15:49:07–15:49:28.
|
||
- These two windows overlapped, so **the central API was unavailable for about 20 s**. The sites were unaffected.
|
||
|
||
**Verified:**
|
||
- Both centrals ready; 2 members, 0 unreachable; vq03 active.
|
||
- `security api-key list` returns the same 3 keys on **both** nodes.
|
||
- An inbound call with a bogus key gets 401 `UNAUTHORIZED` on the active node.
|
||
- No startup warnings after the last start (the Secrets-SQLite, inbound-key-SQLite and stale-key warnings are gone).
|
||
- `central\data` on each box now holds `inbound-api-keys.sqlite{,-wal,-shm}.imported` and the (empty) `secrets.db`.
|
||
|
||
**Rollback:**
|
||
1. Restore the two appsettings files from `_appsettings-keep-sharedstores-<ts>` and import the `.reg` backup, or remove the new env value.
|
||
2. Rename the `*.imported` files back.
|
||
3. Restart both centrals.
|
||
|
||
The `zbauth` and `zbsecrets` rows can stay; the SQLite path never reads them.
|
||
|
||
## Follow-up 2: inbound API standby relay (16:57)
|
||
|
||
`ScadaBridge:InboundApi:StandbyForwardPeerEndpoints` was added to each box's `appsettings.Central.json`:
|
||
- vq03 → `["http://10.220.158.3:8085"]`
|
||
- vq04 → `["http://10.220.158.2:8085"]`
|
||
|
||
`StandbyForwardTimeout` stays at its 60 s default, which is above QA's longest method timeout (`MesMoveIn` 46 s). The relay signature uses `ApiKeyPepper`, which is identical on both centrals.
|
||
|
||
**Rolling restart, standby first:**
|
||
1. vq04: stop 16:57:09, service process exited, file pushed over SMB, ready 16:57:28.
|
||
2. Waited for 2 members / 0 unreachable.
|
||
3. vq03: stop 16:57:33, ready 16:57:51.
|
||
|
||
The cluster never dropped below one serving central. **vq04 is now the active node** (failover on vq03's restart); nothing depends on which node is active.
|
||
|
||
Backups: `E:\ApiInstall\ScadaBridge\_appsettings.Central.json.pre-relay-<ts>` on each box.
|
||
|
||
**Verified:** a bogus-key inbound call answers **401 `UNAUTHORIZED` on both nodes**. The standby (vq03) used to answer 503 `STANDBY_NODE`; it now relays to the active peer, and the peer's answer is replayed.
|
||
|
||
## Outstanding
|
||
|
||
- **Housekeeping after soak:** delete the `*.imported` key files; also the older `app.bak.*`, `cli.bak.*`, `_appsettings-keep-*` and `E:\psrem-stage\*` folders on both boxes. → #77
|