- Profiler: UserProfile.note (nullable, startup migration), PUT
/profiles/{id}/note (max 1000 chars); add missing `requests`
dependency (client creation failed without Public IP set).
- UI: clickable rows on Certificates open a compact profile details
modal with an editable note; tooltip with the note on the client
name (v-note-tooltip) and a note icon.
- PKI init runs in a background thread: POST /system/init returns 202,
GET /system/init/status, 409 for a second start, Clear PKI and client
creation are blocked while it runs. A marker file identifies an
interrupted run (only such a PKI is wiped on the next Init).
- PKI Configuration page: state from the server, progress spinner and
step text, polling, Init/Clear/Save locked while running, Init locked
once initialized.
- Tests: one pytest each for notes and async init (requirements-dev.txt).
- Docs: plans and summaries in DOCS/Changes, API reference, README, Index.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
4.1 KiB
4.1 KiB
Async PKI initialization: implementation plan (2026-10-04)
Goal: Init PKI can take minutes (DH parameters). Run it in the background; the PKI Configuration page shows progress, survives a page reload and prevents a second start.
Current state
POST /system/init(APP_PROFILER/routers/system.py) runspki.init_pki()synchronously: init-pki, build-ca, server cert, gen-dh, ta.key, gen-crl, CRL publish. The HTTP request stays open until it ends.pki.init_pki()treats the PKI as initialized ifca.crtexists, so a PKI interrupted after the CA step (restart, crash) would be reported as ready.PKIConfig.vue:isLoadingis local to the page, so a reload loses the state and the button becomes active again.- The Profiler runs as a single process (
python main.pyin Docker, oneuvicornin the native unit), so in-memory job state is valid.
Steps
1. Backend (APP_PROFILER/)
services/pki.pyis_initialized(): true only when the PKI is complete (ca.crt,dh.pem,ta.key,crl.pemand the server certificate exist). Existing complete PKIs are detected without migration.- Job state
init_job(module level, guarded by a lock):state=idle | running | done | error,step(init-pki, CA, server certificate, DH, TLS key, CRL),started_at,finished_at,error. start_init_async(): refuses to start when a job is running or the PKI is complete; removes an incomplete PKI left by an interrupted run; starts a daemon thread with its own DB session; the thread updatesstepand ends indoneorerror(error text from EasyRSA, no secrets).
routers/system.pyPOST /system/initreturns202 {"state": "running"}immediately;409if a job is running or the PKI is already initialized.GET /system/init/statusreturns{state, step, initialized, started_at, finished_at, error}.DELETE /system/pkireturns409while an init job is running.POST /profilesreturns409while an init job is running (the PKI is not complete).
- After an application restart the state is
idle; an interrupted PKI is reported asinitialized: false, and Init PKI cleans it up and starts again.
2. UI (APP_UI/src/views/PKIConfig.vue)
- On mount call
GET /system/init/status; state is taken from the server, not from the page. running: spinner on the Init PKI button, the current step text ("Generating DH parameters..."), polling every 3 s, Init / Clear / Save disabled.doneorinitialized: true: Init PKI is disabled with the hint "PKI is already initialized. Use Clear PKI to start over"; a success message is shown once when the job finishes while the page is open.error: error message, Init PKI is enabled again.- After Clear PKI the status is reloaded and the button is enabled again.
- A double click or a second tab cannot start a second job (button locked immediately on click, backend answers
409anyway; the UI treats409 runningas "attach to the running job"). - Polling stops on unmount.
3. Tests (minimal)
- One pytest in
APP_PROFILER: with the EasyRSA steps replaced by fast stubs,POST /system/initreturns202, a secondPOSTreturns409,GET /system/init/statusends indoneandinitialized: true, a thirdPOSTreturns409. No UI tests.
4. Verification (containers, stand ovpmon-test, port 8089)
- Rebuild
app-profilerandapp-ui. Clear PKI, press Init PKI: spinner appears, the page can be reloaded and still shows progress, buttons are locked, the result appears on completion, Init PKI stays locked afterwards, Clear PKI unlocks it. - Restart
ovp-profilerduring the run: status isidleandinitialized: false, Init PKI cleans up and completes. - Existing PKI from the current stand is detected as initialized.
5. Documentation
DOCS/Profiler_Management/API_Reference.md(new endpoints and409cases),README.md,DOCS/General/Index.md, summaryDOCS/Changes/2026-10-04_Async_PKI_Init.md. Note for operators: single Profiler process is required (do not run several uvicorn workers).
Out of scope
Cancelling a running init, progress percentage, async Clear PKI, job history.