Prod upgrade fixes: profiler compatibility with new FastAPI, pinned dependencies
- profiler: Literal instead of Query(enum=...) (broke on FastAPI 0.162) - pin fastapi/starlette/uvicorn/pydantic for the profiler, upper bounds for APP_CORE - health check: show the service log when an HTTP check fails - update.sh: the "before" version comes from deploy.state - migrate.py: hint about OVPMON_*_DB_PATH when the default database is missing - docs: --source --no-pull mode, dependency pinning, PIP_CONSTRAINT - tests: new test for the section parameter, fixed test_server_process.py Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1bbf9b7cc1
commit
79c950f8f7
14 files changed
+156
-38
No files matched your search
@@ -102,6 +102,18 @@ How the code is restored: the current (new or half-swapped) code directories are
|
||||
|
||||
`update.sh --rollback` does the same by hand from the newest `COMPLETE` backup after a confirmation, with one difference: PKI and client profiles come from the backup too (one consistent set with the databases), and the current state is saved first to `<time>-pre-restore`. Use it when an update succeeded but the new version misbehaves. Data created after that backup is lost (it is in the `-pre-restore` copy).
|
||||
|
||||
## Updating with `--source ... --no-pull` (install directory is a git checkout)
|
||||
|
||||
When the install directory is a git checkout and the new version is brought in by hand (`--source <checkout> --no-pull`), keep in mind:
|
||||
|
||||
- `--no-pull` skips `git pull`: the sources must already be at the wanted commit. `deploy.state` records the version that was installed by the scripts; the git checkout of the install directory can differ from it (for example after a manual `git pull` or local commits). The "before" version in the update log is taken from `OVPMON_VERSION` in `deploy.state`, then from `<prefix>/VERSION`.
|
||||
- To bring a diverged checkout to the published state: `git fetch origin && git reset --hard origin/main`. This discards local changes of tracked files, including the **live `config.ini`** of both components. Save them first (`cp APP_CORE/config.ini APP_PROFILER/config.ini` to a safe place) and put them back after the reset; the update keeps `config.ini` and writes the shipped one as `config.ini.dist` when it differs.
|
||||
- The update runs the migrations as a separate step; `python migrate.py --check` outside the service environment looks at the default database path, which may not exist (exit code 2 = pending migrations). Load `/etc/ovpmon/env` first or pass `--db PATH` (variables `OVPMON_OPENVPN_MONITOR_DB_PATH` and `OVPMON_PROFILER_DB_PATH`).
|
||||
|
||||
### Dependency versions
|
||||
|
||||
`APP_PROFILER/requirements.txt` pins `fastapi`, `starlette`, `uvicorn` and `pydantic` to the tested set (an unpinned install pulled a newer FastAPI that broke the API); `APP_CORE/requirements.txt` has an upper bound by major version for each package. Update the pins deliberately and run the tests on the new set. To hold back any package without editing the files, give `pip` a constraints file: `PIP_CONSTRAINT=/etc/ovpmon/constraints.txt deploy/native/update.sh ...` (the variable is read by every `pip install` of the scripts, the environment is inherited).
|
||||
|
||||
## Existing installations (adoption)
|
||||
|
||||
A host that was set up by hand (the layout of the old guide: code in `/opt/OpenVPN-Monitoring-Simple`, `/etc/ovpmon/env`, init scripts or units, helper and doas rules) can be updated with `update.sh`: it has no state file, so it is adopted and recorded after the first successful update. Files that these scripts do not manage are **left as they are**: init scripts, units, an nginx site and a doas file that do not carry the marker line `managed by ovpmon deploy/native` and differ from the shipped ones are only reported. The helper is replaced (the new one behaves like the old one without `helper.conf`), `helper.conf` is written when missing, and `OVPMON_RUNTIME`, `OVPMON_OPENVPN_SERVICE` and `OVPMON_OPENVPN_CONFIG` are added to the environment file only when absent. If the install directory is a git checkout (the source is the install directory), `git pull` changes the live files, therefore a rollback is armed from phase 2.
|
||||
|
||||
Reference in new issue
Block a user