Просмотр исходного кода

docs: prod's second, customer-facing hostname and why its root answers 404

fszontagh 1 месяц назад
Родитель
Сommit
a1951f51d6
1 измененных файлов с 5 добавлено и 0 удалено
  1. 5 0
      CLAUDE.md

+ 5 - 0
CLAUDE.md

@@ -202,6 +202,11 @@ docker run -d --name svapi-dev -p 8080:8080 -e SMARTBOTIC_VECTORAPI_KEY=dev svap
 - **A SECOND RESTART IS NOT NEEDED ON 2.17.2, measured rather than reasoned.** Our `KeyStore`/`SettingsStore` bootstraps DO perform the online upgrade after the migration, and the log says so - but with **0 rows and 0 history versions rewritten**, because the collections are already ciphertext through the bare-alias merge. `encryption-verify` then reports `sealed: yes`, `CLEAN`, exit 0. So the window is TWO steps and ONE compaction (upgrade, then start vectorapi), with verify as the branch: plain `CLEAN` means done, `CLEAN (UNSEALED: ...)` means take the reseal inside the window. On 2.17.1 that same flag move requested a reseal that compacted every project, which is where the obsolete three-step plan came from.
 - **A SECOND RESTART IS NOT NEEDED ON 2.17.2, measured rather than reasoned.** Our `KeyStore`/`SettingsStore` bootstraps DO perform the online upgrade after the migration, and the log says so - but with **0 rows and 0 history versions rewritten**, because the collections are already ciphertext through the bare-alias merge. `encryption-verify` then reports `sealed: yes`, `CLEAN`, exit 0. So the window is TWO steps and ONE compaction (upgrade, then start vectorapi), with verify as the branch: plain `CLEAN` means done, `CLEAN (UNSEALED: ...)` means take the reseal inside the window. On 2.17.1 that same flag move requested a reseal that compacted every project, which is where the obsolete three-step plan came from.
   Note the upstream log line still says "old plaintext copies are removed at the next restart" even when it rewrote NOTHING, which contradicts verify's `sealed: yes` and would have an operator restart for no reason. Trust verify.
   Note the upstream log line still says "old plaintext copies are removed at the next restart" even when it rewrote NOTHING, which contradicts verify's `sealed: yes` and would have an operator restart for no reason. Trust verify.
 - **MOVING THE CLIENT PACKAGE UNDER AN EXISTING BINARY IS AN ABI QUESTION, AND IT IS CHEAP TO TEST.** Every 2.x client shares one SONAME, so apt will happily put a 2.17.2 `libsmartbotic-db-client.so.2` under a server binary compiled against 2.14.0 headers - and the documented failure mode is that it installs fine and segfaults later. Verified before deploying rather than hoped: a Debian 13 container holding the real `smartbotic-vectorapi 0.12.0-1` deb plus `libsmartbotic-db-client 2.17.2-1`, against a 2.17.2 server, answered **21 of 21 calls** correctly - including `POST /indexes` with `unique`, which exercises `CreateIndexResult`, the by-value struct whose SIZE is the thing that would break, and a 409 duplicate refusal, which proves `duplicateExamples` crossed the boundary intact. `/api/v1/version` reported `db_client: 2.17.2` so the new library really was loaded. Repeat this whenever `DB_CLIENT_VERSION` and the deployed client diverge; it takes minutes and the alternative is a restart days later.
 - **MOVING THE CLIENT PACKAGE UNDER AN EXISTING BINARY IS AN ABI QUESTION, AND IT IS CHEAP TO TEST.** Every 2.x client shares one SONAME, so apt will happily put a 2.17.2 `libsmartbotic-db-client.so.2` under a server binary compiled against 2.14.0 headers - and the documented failure mode is that it installs fine and segfaults later. Verified before deploying rather than hoped: a Debian 13 container holding the real `smartbotic-vectorapi 0.12.0-1` deb plus `libsmartbotic-db-client 2.17.2-1`, against a 2.17.2 server, answered **21 of 21 calls** correctly - including `POST /indexes` with `unique`, which exercises `CreateIndexResult`, the by-value struct whose SIZE is the thing that would break, and a 409 duplicate refusal, which proves `duplicateExamples` crossed the boundary intact. `/api/v1/version` reported `db_client: 2.17.2` so the new library really was loaded. Repeat this whenever `DB_CLIENT_VERSION` and the deployed client diverge; it takes minutes and the alternative is a restart days later.
+- **PROD HAS TWO HOSTNAMES AND THEY SERVE DIFFERENT SURFACES. Probing the customer-facing one at `/` answers 404 BY DESIGN.** Added 2026-10-15.
+  - `qdrant-1.shop.static.shopcall.ai/rag/` - the ORIGINAL mount, unchanged and still the full surface including the admin web UI. `proxy_pass` carries a TRAILING SLASH here, which strips the `/rag` prefix before vectorapi sees it.
+  - `global-api-01.smartbotics.ai` - the CUSTOMER-FACING name, at the ROOT, with its own Let's Encrypt cert (expires 2027-01-13, `--redirect` so 80 answers 301). `proxy_pass` has NO trailing slash, so the path reaches vectorapi unchanged. The two mounts are deliberately different and must never be copied onto each other.
+  **It is a WHITELIST, not a deny-list on `/`, and that is the load-bearing choice**: `/api/`, `/docs` (prefix, because the page fetches `/docs/rapidoc-min.js`), `/openapi.json`, `/llms.txt` and `/healthz` are proxied, everything else returns 404. vectorapi serves its ADMIN WEB UI at `/`, which does not belong on a hostname handed to customers - and with a deny-list, a route added by a later release would be exposed the moment the package upgraded, with nobody noticing. The cost is that a genuinely public new route must be added here deliberately, which is the point. The shared proxy settings (180 s read timeout for the server-side embedding, 10 MB body) live in `/etc/nginx/snippets/vectorapi-proxy.conf` and are included by every location, so the two cannot drift.
+  **Two traps met while doing it.** The half-written config was a BYTE COPY of the qdrant one with a single `server_name` changed, so it still carried full duplicate `qdrant-1` blocks on 443 and 80 and pointed at qdrant's port 6333 and qdrant's certificate - enabling that would have put conflicting server blocks on the live site and served a cert that covers neither name. And **the first request after `systemctl reload nginx` hit the old worker set and answered 404**, which read exactly like a broken location block; every path passed on a retry seconds later. Do not diagnose an nginx location from a request issued in the same breath as the reload.
 - **Prod's database binds `localhost`, not `0.0.0.0`** (`storage.bind_address`), which is why it is only reachable from vectorapi on the same box - correct, and worth knowing before wondering why a port-mapped copy refuses connections.
 - **Prod's database binds `localhost`, not `0.0.0.0`** (`storage.bind_address`), which is why it is only reachable from vectorapi on the same box - correct, and worth knowing before wondering why a port-mapped copy refuses connections.
 - **`policy-rc.d` DOES NOT HOLD THE DATABASE PACKAGE. It blocks `invoke-rc.d`, and that postinst calls `systemctl` DIRECTLY.** Measured the hard way on 2026-10-12: a `policy-rc.d` returning 101 was in place, the pinned install ran at 18:21:12, and the service restarted anyway - the 2.17.2 first-boot migration ran to completion before the install command had even returned. **A hold point three consumers had been promised simply did not exist**, and that cost TWO separate things, not one. One consumer lost the chance to say "wait, a call is live" that they had explicitly been offered. **And because the install itself triggered the migration, the outage happened at 18:21 rather than in the 18:30 slot all three had approved** - it ran NINE MINUTES EARLY, outside the approved window, which is a governance failure distinct from the missing check. A consumer put that second point in the record; my own account had blurred it into the first, which understated it.
 - **`policy-rc.d` DOES NOT HOLD THE DATABASE PACKAGE. It blocks `invoke-rc.d`, and that postinst calls `systemctl` DIRECTLY.** Measured the hard way on 2026-10-12: a `policy-rc.d` returning 101 was in place, the pinned install ran at 18:21:12, and the service restarted anyway - the 2.17.2 first-boot migration ran to completion before the install command had even returned. **A hold point three consumers had been promised simply did not exist**, and that cost TWO separate things, not one. One consumer lost the chance to say "wait, a call is live" that they had explicitly been offered. **And because the install itself triggered the migration, the outage happened at 18:21 rather than in the 18:30 slot all three had approved** - it ran NINE MINUTES EARLY, outside the approved window, which is a governance failure distinct from the missing check. A consumer put that second point in the record; my own account had blurred it into the first, which understated it.
   **The error was verifying the mechanism's PURPOSE instead of its EFFECT.** `policy-rc.d` genuinely is the standard Debian way to prevent a maintainer script starting a service; it is just not effective against a script that bypasses `invoke-rc.d`. Checking that it is the right tool is not the same as checking that it works here, and one `systemctl show -p ActiveEnterTimestamp` before the install - or one `grep systemctl` over the postinst - would have shown it. **A control nobody has seen fire is not a control.** If a window needs a pause, REHEARSE THE PAUSE, not just the migration: install on a scratch box and confirm the service did NOT start. The consumer's framing is the one to keep - they asked for a pause and then treated it as load-bearing without either of us testing that it pauses.
   **The error was verifying the mechanism's PURPOSE instead of its EFFECT.** `policy-rc.d` genuinely is the standard Debian way to prevent a maintainer script starting a service; it is just not effective against a script that bypasses `invoke-rc.d`. Checking that it is the right tool is not the same as checking that it works here, and one `systemctl show -p ActiveEnterTimestamp` before the install - or one `grep systemctl` over the postinst - would have shown it. **A control nobody has seen fire is not a control.** If a window needs a pause, REHEARSE THE PAUSE, not just the migration: install on a scratch box and confirm the service did NOT start. The consumer's framing is the one to keep - they asked for a pause and then treated it as load-bearing without either of us testing that it pauses.