From 042ee255f71914addcc5c799622749900307d051 Mon Sep 17 00:00:00 2001 From: psarria Date: Mon, 21 Sep 2026 12:08:29 +0200 Subject: [PATCH] Release o6h-memory-guard 1.0.5 --- CHANGELOG.md | 17 +++++ Makefile | 9 ++- README.md | 127 +++++++++++++++++++++++++++++------- SHA256SUMS | 20 +++--- VALIDATION.md | 34 ++++++---- etc/o6h-memory-guard.conf | 4 +- logs/distribution-tests.log | 2 + logs/example.log | 2 +- logs/portability.log | 2 +- smf/o6h-memory-guard.xml | 4 +- src/guard.h | 2 +- tests/test_distribution.sh | 34 ++++++++++ 12 files changed, 203 insertions(+), 54 deletions(-) create mode 100644 logs/distribution-tests.log create mode 100644 tests/test_distribution.sh diff --git a/CHANGELOG.md b/CHANGELOG.md index fc3809a..433a7ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 1.0.5 — 2026-09-21 — Production SMF activation contract + +- Retirado `--force-dry-run` del método start del manifiesto SMF versionado para + que `ACTION_MODE` sea la fuente única de la política de acción. +- Conservado `ACTION_MODE dry-run` en la configuración distribuida: una + instalación nueva continúa siendo segura por defecto. +- Conservada la opción CLI `--force-dry-run` para probe, pruebas y validaciones + manuales. +- Neutralizado el `common_name` del servicio a `o6h memory pressure guard`. +- Documentados activación explícita, upgrade desde manifiestos v1.0.4 o + anteriores, verificación del repositorio SMF/proceso y rollback. +- Añadida advertencia de no reiniciar cerca de `lotsfree`, porque cada restart + reinicia la inhibición `armed_warmup=60`. +- Añadida una prueba del contrato de distribución para impedir regresiones del + exec SMF, modo inicial y parámetros operativos 1/2/2/15, 5/1/0/15 y 4/4/8/12. +- No hubo despliegue, activación de armed ni señales reales. + ## 1.0.4 — 2026-09-21 — Global victim ranking fix - Sustituido el orden lexicográfico dominado por `zone_score` por un top‑3 diff --git a/Makefile b/Makefile index 634c556..7b83248 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ LDLIBS = -lkstat -lrt SOURCES = src/main.c src/core.c src/config.c src/support.c src/illumos.c TESTFLAGS = -std=c99 -O1 -g -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE=700 -Isrc -Wall -Wextra -Werror -Wformat=2 -pedantic -.PHONY: all native-check test test-sanitize portability clean +.PHONY: all native-check test test-distribution test-sanitize portability clean all: o6h-memory-guard native-check: @@ -21,7 +21,10 @@ test-guard: tests/test_guard.c tests/fixtures/pageout_deadman_real_incident_2026 test-runtime: tests/test_runtime.c tests/fixtures/global_victim_ranking_smartos_2026_09.csv src/main.c src/core.c src/config.c src/guard.h $(CC) $(TESTFLAGS) -o $@ tests/test_runtime.c src/core.c src/config.c -test: test-guard test-runtime +test-distribution: tests/test_distribution.sh smf/o6h-memory-guard.xml etc/o6h-memory-guard.conf src/main.c + sh tests/test_distribution.sh + +test: test-guard test-runtime test-distribution ./test-guard ./test-runtime @@ -35,7 +38,7 @@ test-sanitize: portability: $(CC) $(TESTFLAGS) -Itests/api-sketch -fsyntax-only $(SOURCES) @for source in $(SOURCES); do $(CC) $(TESTFLAGS) -Itests/api-sketch -fanalyzer -c $$source -o /dev/null || exit 1; done - sh -n install.sh + sh -n install.sh tests/test_distribution.sh xmllint --nonet --noout smf/o6h-memory-guard.xml clean: diff --git a/README.md b/README.md index 63eaed8..f0d63c4 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,26 @@ -# o6h-memory-guard 1.0.4 +# o6h-memory-guard 1.0.5 Primera implementación para SmartOS global zone: daemon C de 64 bits, libkstat, /proc, identidad UUID + generación de zona + PID + instante de creación, configuración separada y servicio SMF. Entrega de código fuente; **no contiene un binario nativo validado en SmartOS**. Véase `VALIDATION.md`. -Arranca en `dry-run`. El manifiesto añade `--force-dry-run`, por lo que cambiar -sólo `ACTION_MODE` no arma el servicio. No se entrega ninguna zona autorizada. -No se ha desplegado ni se han enviado señales reales durante la preparación. +Una instalación nueva arranca en `dry-run` porque la configuración distribuida +contiene `ACTION_MODE dry-run`. El manifiesto SMF de producción no fuerza ese +modo: la configuración es la única fuente de la política de acción. No se +entrega ninguna zona autorizada. Esta revisión no se ha desplegado, no ha +activado `armed` y no ha enviado señales reales. + +```text +Instalación nueva +→ ACTION_MODE dry-run +→ SMF no fuerza dry-run + +Activación real +→ el operador cambia explícitamente ACTION_MODE armed +→ reinicia SMF +→ armed_warmup=60 sigue aplicando +``` ## Documentación de la entrega @@ -32,12 +45,12 @@ Si no hay herramientas de desarrollo, compilar en una **zona nativa SmartOS** de la misma plataforma (no LX), ejecutar allí `gmake test`, y copiar el binario junto a este árbol al host. No instalar un compilador en un nodo bajo presión. -Copiar el archivo distribuido a `/var/tmp/o6h-memory-guard-1.0.4.tar.gz`: +Copiar el archivo distribuido a `/var/tmp/o6h-memory-guard-1.0.5.tar.gz`: ```sh mkdir -p /opt/custom/src cd /opt/custom/src -gzip -dc /var/tmp/o6h-memory-guard-1.0.4.tar.gz | tar -xf - +gzip -dc /var/tmp/o6h-memory-guard-1.0.5.tar.gz | tar -xf - cd /opt/custom/src/o6h-memory-guard gmake CC=gcc gmake test CC=gcc @@ -84,8 +97,8 @@ svcprop -p start/exec svc:/site/o6h-memory-guard:default tail -f /opt/custom/var/log/o6h-memory-guard/guard.log ``` -Verificar `mode=dry-run` en `event=start`, `--force-dry-run` en `start/exec`, -`arc_ok=1`, `swap_committed_ok=1`, `swap_physical_used_ok=1`, +Verificar `mode=dry-run` en `event=start`, ausencia de `--force-dry-run` en +`start/exec`, `arc_ok=1`, `swap_committed_ok=1`, `swap_physical_used_ok=1`, `anon_pageout_ok=1` y `proc_scan complete=1`. No generar presión artificial en producción. Para comprobar selección y UUID, revisar `candidate`, `zone` y @@ -103,9 +116,11 @@ svccfg validate /opt/custom/smf/o6h-memory-guard.xml svccfg import /opt/custom/smf/o6h-memory-guard.xml ``` -Mantener `--force-dry-run`. La ubicación `/opt/custom/smf` se utiliza para -servicios personalizados persistentes de SmartOS; no depender exclusivamente -del estado habilitado de la instancia en el repositorio del arranque actual. +Mantener `ACTION_MODE dry-run` durante toda la validación inicial. La ubicación +`/opt/custom/smf` se utiliza para servicios personalizados persistentes de +SmartOS; no depender exclusivamente del estado habilitado de la instancia en el +repositorio del arranque actual. `--force-dry-run` sigue disponible para +`--probe`, pruebas y validaciones manuales, pero no pertenece al método SMF. ## Métricas y ventanas @@ -327,19 +342,26 @@ Los eventos `state_transition`, `candidate_cache`, `action_decision` y `recovery_check` permiten reconstruir el estado, origen/rank/edad del candidato, resultado del último scan, componentes del score y cualquier override de presupuesto. -## Preparación de armed (NO GO para v1.0.4 inicial) +## Modelo de activación real (operación futura; no ejecutada en esta entrega) -v1.0.4 debe compilarse y observarse primero en SmartOS exclusivamente en -`dry-run`; el incidente real aún no autoriza señales. En una fase futura se -necesitarían deliberadamente dos cambios: `ACTION_MODE armed` en la config y -retirar `--force-dry-run` del método start del manifiesto. Mantener las reglas -UUID `allow` mínimas y verificar antes las protecciones y el laboratorio nativo. -Después de esos cambios, validar config/manifiesto, importar, refrescar y -reiniciar el servicio. Verificar `event=start mode=armed`; comienza la inhibición -de 60 s. No se proporciona un script que arme automáticamente el servicio. +v1.0.5 debe compilarse y observarse primero en SmartOS con `ACTION_MODE dry-run`. +El manifiesto ya no contiene una segunda puerta oculta. Cuando exista aprobación +operativa explícita, el único cambio de modo es editar la configuración: -Para volver a dry-run, restaurar `ACTION_MODE dry-run` y `--force-dry-run` en -el manifiesto; importar, `svcadm refresh` y `svcadm restart` la instancia. +```sh +vi /opt/custom/etc/o6h-memory-guard.conf +# cambiar exactamente: ACTION_MODE dry-run → ACTION_MODE armed +/opt/custom/bin/o6h-memory-guard --check-config +svcadm restart svc:/site/o6h-memory-guard:default +``` + +Mantener las reglas UUID `allow` mínimas y verificar antes las protecciones y el +laboratorio nativo. Tras el restart, comprobar `event=start mode=armed`; durante +los primeros 60 s `armed_warmup` inhibe señales, aunque la detección y la caché +siguen activas. No se proporciona un script que arme automáticamente el servicio. + +Para volver a dry-run, restaurar `ACTION_MODE dry-run`, validar la configuración +y reiniciar SMF. No es necesario editar el manifiesto. ## Parada, rollback y actualización @@ -377,7 +399,66 @@ niega a sobrescribir por ese motivo. La migración desde v1.0.3 a v1.0.4 no añade parámetros de configuración: cambia el algoritmo de ranking y su logging. Comparar el top‑3 global en SmartOS real -antes de reemplazar el binario observado y mantener siempre `--force-dry-run`. +antes de reemplazar el binario observado. + +### Upgrade del manifiesto desde v1.0.4 o anterior + +Los manifiestos antiguos incluían `--force-dry-run`. Antes de retirarlo, +comprobar el modo configurado. Si no se pretende activar señales en ese mismo +restart, debe decir literalmente `ACTION_MODE dry-run`: + +```sh +grep '^ACTION_MODE ' /opt/custom/etc/o6h-memory-guard.conf +/opt/custom/bin/o6h-memory-guard --check-config --force-dry-run +kstat -p unix:0:system_pages:freemem unix:0:system_pages:lotsfree +``` + +No hacer un restart innecesario cuando `freemem` esté cerca o por debajo de +`lotsfree`: cada arranque reinicia `armed_warmup=60` y, si el modo fuese armed, +dejaría las señales inhibidas durante 60 s precisamente cuando podrían ser +necesarias. Posponer el cambio hasta que el nodo esté estable. + +Con memoria estable, conservar el manifiesto anterior y copiar el nuevo: + +```sh +mkdir -p /opt/custom/var/backups/o6h-memory-guard +cp -p /opt/custom/smf/o6h-memory-guard.xml \ + /opt/custom/var/backups/o6h-memory-guard/o6h-memory-guard.xml.v1.0.4-forced-dry-run +cp /opt/custom/src/o6h-memory-guard/smf/o6h-memory-guard.xml \ + /opt/custom/smf/o6h-memory-guard.xml +svccfg validate /opt/custom/smf/o6h-memory-guard.xml +svccfg import /opt/custom/smf/o6h-memory-guard.xml +svcadm restart svc:/site/o6h-memory-guard:default +``` + +Comprobar tanto la definición importada como el proceso activo: + +```sh +svccfg export svc:/site/o6h-memory-guard:default | +grep -A3 -B2 'o6h-memory-guard --daemon' + +pgrep -fl o6h-memory-guard +``` + +Ambas salidas deben quedar sin `--force-dry-run`. Con la configuración +distribuida, `event=start` debe seguir mostrando `mode=dry-run`. + +### Rollback del manifiesto anterior + +Primero asegurar `ACTION_MODE dry-run` y comprobar de nuevo que la memoria está +holgada respecto a `lotsfree`. Después restaurar la copia y reimportarla: + +```sh +cp /opt/custom/var/backups/o6h-memory-guard/o6h-memory-guard.xml.v1.0.4-forced-dry-run \ + /opt/custom/smf/o6h-memory-guard.xml +svccfg validate /opt/custom/smf/o6h-memory-guard.xml +svccfg import /opt/custom/smf/o6h-memory-guard.xml +svcadm restart svc:/site/o6h-memory-guard:default +``` + +El rollback vuelve a añadir la puerta forzada del manifiesto antiguo. Registrar +qué versión queda instalada para no confundir ese comportamiento con la política +de configuración de v1.0.5. ## Referencias revisadas diff --git a/SHA256SUMS b/SHA256SUMS index ed32957..0d4e0e7 100644 --- a/SHA256SUMS +++ b/SHA256SUMS @@ -1,21 +1,22 @@ 887569535302f7deba4d7c6ffb2103f1fb90bd96a40280240ff238eddc2e3a6f ./.gitignore -2e27e56dea5e00b74ccdd2ae2d5d8ff7ca7f01d82c1d2ed27ea976a7bf382856 ./CHANGELOG.md +e45fac9145e5cdd63490c3e4b9c8f6eb34894b05c90ef1af6ca8886cb7cee741 ./CHANGELOG.md ebfca7d4b5eaf0c0cc9910cf49d8c85f6aa7ff69972d7f21d17e61d1a2e23bc2 ./CHECKPOINT.md a0f96300e751d08ceeef1360325ed54008b703fa6bd07df9d5368674e580f113 ./INCIDENT_PAGEOUT_DEADMAN_2026_09.md -df619be1585cd8d6173acba541fcaeeb1e94e55459dc059914863d0e9f316121 ./Makefile -9a841ab6077f10267ee73f23b51be849d391fd0deddee85bf99338601b3b379e ./README.md -c749b5a31b3a9a72de4e2c4bb8903ccc901ddde7aa702ccbebcbfd57c075dcef ./VALIDATION.md -f89457e6fd793911c8e73843ce7f38fe0c119045c66c06fca1cb962737c8c45d ./etc/o6h-memory-guard.conf +7e735ae0ca694e748b0051a47873b53424d8d934f735f8d055ccba186de08a80 ./Makefile +6894f18fd377502ada7b9b51ec846f6d6ffe263531c457a81a50366b7d27fc3b ./README.md +fa95db79696c6a1526d3ed94277911bcd9157b9bff74f9e5a997e4ab02fd669c ./VALIDATION.md +a4727d5ac7d5ba06f59dd1ae459fcb12e1d0d966e823bec1ed9409077d986ae7 ./etc/o6h-memory-guard.conf f6565d0e1ece0a08721c9893f9ed071d2ab0a2818fa93ed0a14e0050d358ce99 ./install.sh -b9b5b28aff2d34dd8d544a73a2c4a14b8e622185b68751dd0227671c298cd50a ./logs/example.log +24c1b9bc39fda71d459d6fad6a8d889b0d9b92be89d303677643b3d0b93caf4b ./logs/distribution-tests.log +50626dec1924e19b4ca92eec30416fb39c3fe7cff28d98a8e120ccf6247d2834 ./logs/example.log b7d6826f353765641a95025344c30e6f5eb228772f29e04399a9ec78e3fb5595 ./logs/policy-tests.log -abafc237427b63f38f81d0d1b76ba64eefc64d9f8074fdaa6ed0f1573b5d0a3b ./logs/portability.log +08a771544b1e8f29eefc07477af6b83f71ab4824192edd32567e1a9182631bfa ./logs/portability.log ed9246c2a7a82ed42a49dc72439cd452f2ab8a76b4dcd1aaf466ba23eb75fc5c ./logs/runtime-tests.log 2632e52bc306f5ccc947aac41d91f0b7ad54043a4192a0c4d7ed69616b1183c5 ./logs/sanitizers.log -b55afd45a72947efdda79d593255c36def9679bcb7a33ab14d55170ebaf9bef7 ./smf/o6h-memory-guard.xml +55cf49840cf1d22e4e02bedf579a10207856a0a5b40c86ae2cf6ee2f00d3f972 ./smf/o6h-memory-guard.xml 9a4468d9acc3f1da078b009f764c7cb7bf337682d6584b8cbaf7b540c520d5f5 ./src/config.c c1f81909ec63fdb85948bbe58642478a80105b26a7c64eaf463c0e6fc42de203 ./src/core.c -df4baeefd240a61916fcdd4a06167fa34621510db027eb20cce0b3559c37b28c ./src/guard.h +4d8d30d2903d9da67c25f73cc58179bb5dfd297d3697df1fa1fe3aee47071f95 ./src/guard.h 32ab75bb6a1ff2bbbeb6a1ea658abcb96a03fcc06246f38d019faec7fdc184b8 ./src/illumos.c 4b643eb55f7846c5b1ae5906a13dec3f7ac9b6191778c8352cffd39ca0bf2bfd ./src/main.c 2cb2b4c50fd42051fde4a702e8955e07d63979d5e3216e02420ed9b54fb67578 ./src/support.c @@ -26,5 +27,6 @@ f0d06353d2e326c7bdce776bee6f0a8606cda50d5de957dfdd586b6848fca8da ./tests/api-sk 9b99e272008ad00ad0abb366e1e8720dd6c51fc050821c5d1d878eae5719c22b ./tests/api-sketch/zone.h 4aa08ded8e98cf25d2a8762543de7a9273f0ebf00b4c7e5b359603ceda46eb56 ./tests/fixtures/global_victim_ranking_smartos_2026_09.csv c5d9d7fc7a39354474d30cd316ea9f122205c2b38e57f927f4a08306b8a62c81 ./tests/fixtures/pageout_deadman_real_incident_2026_09.csv +5e80231bf4e9d04e9fbfc5f78b05c561925614346e5876986e1701a1b76efaa3 ./tests/test_distribution.sh b7ac53f6b26b4e7e2e19d7258b570a64462182ffe85c93374856caf77ec0c871 ./tests/test_guard.c 76c0a6d64a3feb74678f0455ad32a4392cea169aee735035f65b17837b82a931 ./tests/test_runtime.c diff --git a/VALIDATION.md b/VALIDATION.md index 14872b8..1f3b18a 100644 --- a/VALIDATION.md +++ b/VALIDATION.md @@ -1,16 +1,17 @@ -# Validación de la entrega v1.0.4 +# Validación de la entrega v1.0.5 Fecha: 2026-09-21. v1.0.3 se desplegó y se está validando en SmartOS real sólo en `dry-run`; confirmó la telemetría, SMF, scans y caché persistente, pero reveló -que `zone_score` podía monopolizar el top‑3. **v1.0.4 no se ha desplegado, no ha -activado `armed` y no ha enviado señales reales.** El manifiesto mantiene -`--force-dry-run`, la configuración mantiene `ACTION_MODE dry-run`, la instancia -SMF viene deshabilitada y no se distribuye ningún UUID `allow`. +que `zone_score` podía monopolizar el top‑3. **v1.0.5 no se ha desplegado, no ha +activado `armed` y no ha enviado señales reales.** El manifiesto de producción +ya no fuerza `--force-dry-run`; la configuración distribuida mantiene +`ACTION_MODE dry-run`, la instancia SMF viene deshabilitada y no se distribuye +ningún UUID `allow`. `CHECKPOINT.md` conserva la validación operativa previa de v1.0.2. `INCIDENT_PAGEOUT_DEADMAN_2026_09.md` documenta el incidente, el endurecimiento -v1.0.3 y el hallazgo que motiva v1.0.4. La telemetría nativa ya validada no se ha -refactorizado. +v1.0.3 y el hallazgo que motivó v1.0.4. v1.0.5 sólo cambia el contrato de +activación SMF y su documentación; la telemetría nativa no se ha refactorizado. ## Evidencia real que motiva esta revisión @@ -28,9 +29,12 @@ aproximadamente 1,33 GiB en cuatro zonas menores. El fixture `tests/fixtures/global_victim_ranking_smartos_2026_09.csv` conserva esas proporciones y procesos `mysqld` protegidos. -## Comprobaciones automatizadas de v1.0.4 +## Comprobaciones automatizadas de v1.0.5 - `make test` completa 138 comprobaciones de política y 138 de runtime. +- La prueba de distribución exige `ACTION_MODE dry-run`, los doce parámetros + operativos 1/2/2/15, 5/1/0/15 y 4/4/8/12, el exec SMF sin + `--force-dry-run`, el `common_name` neutral y la permanencia de la opción CLI. - La suite de política cubre configuración estricta, seis estados, transición temprana, fixture real, telemetría, identidades, protecciones, TERM/KILL, recuperación y presupuesto jerárquico. @@ -53,8 +57,9 @@ proporciones y procesos `mysqld` protegidos. `kill(2)`. El envío real sigue aislado en el backend nativo y no se enlaza en las pruebas. -Los resultados exactos se guardan en `logs/policy-tests.log`, -`logs/runtime-tests.log`, `logs/sanitizers.log` y `logs/portability.log`. +Los resultados exactos se guardan en `logs/distribution-tests.log`, +`logs/policy-tests.log`, `logs/runtime-tests.log`, `logs/sanitizers.log` y +`logs/portability.log`. ## Propiedades verificadas por las pruebas nuevas @@ -84,8 +89,9 @@ Los resultados exactos se guardan en `logs/policy-tests.log`, 1. Compilar con cabeceras nativas (`gmake CC=gcc`), ejecutar `gmake test CC=gcc` y comprobar ELF de 64 bits y dependencias. 2. Ejecutar `--probe --force-dry-run` y contrastar la telemetría ya conocida. -3. Validar el manifiesto con `svccfg validate`, importar y ejecutar SMF sólo con - `--force-dry-run`. +3. Validar e importar el manifiesto, confirmar que `start/exec` no contiene + `--force-dry-run` y que `event=start` sigue mostrando `mode=dry-run` por la + configuración distribuida. 4. Confirmar que el top‑3 es global: los `clamd` grandes de zonas menores deben superar a PHP-FPM pequeños de `web5`, sin incluir ningún `mysqld` protegido. 5. Confirmar que un scan lento/incompleto no retrasa ni borra la decisión @@ -95,6 +101,10 @@ Los resultados exactos se guardan en `logs/policy-tests.log`, 7. Sólo en laboratorio desechable y en una fase posterior: probar PCKILL, supervisores, cooldown, 4/8/12 y rollback. `armed` continúa siendo NO GO. +La opción CLI `--force-dry-run` continúa probándose y se conserva para `--probe` +y validaciones manuales. Su ausencia se exige únicamente en el manifiesto SMF +de producción. + ## Límites conocidos La caché sólo contiene tres procesos y puede quedar sin candidato si todos diff --git a/etc/o6h-memory-guard.conf b/etc/o6h-memory-guard.conf index b87d806..975fe95 100644 --- a/etc/o6h-memory-guard.conf +++ b/etc/o6h-memory-guard.conf @@ -1,4 +1,4 @@ -# o6h-memory-guard 1.0.4 -- whitespace-separated, no shell evaluation. +# o6h-memory-guard 1.0.5 -- whitespace-separated, no shell evaluation. # Restart required for configuration changes. Duplicate scalar keys are errors. ACTION_MODE dry-run @@ -35,7 +35,7 @@ protect_process zabbix_agentd # Inventory supplied by the operator, from vmadm list (outside the daemon). # Add REAL UUIDs and aliases. No active allow rules are shipped. # Grammar: zone -# allow: eligible in simulations, and in armed only when both arming gates open. +# allow: eligible in simulations and for signals only with ACTION_MODE armed. # protect / observe / absent: never eligible for signals, including floor. # Examples (replace the entire UUID; these are comments, not authorizations): # zone YOUR-REAL-WEB-ZONE-UUID web5 allow diff --git a/logs/distribution-tests.log b/logs/distribution-tests.log new file mode 100644 index 0000000..e8c363f --- /dev/null +++ b/logs/distribution-tests.log @@ -0,0 +1,2 @@ +sh tests/test_distribution.sh +PASS distribution defaults to ACTION_MODE dry-run; production SMF does not force it diff --git a/logs/example.log b/logs/example.log index 8323f94..be367cc 100644 --- a/logs/example.log +++ b/logs/example.log @@ -1,5 +1,5 @@ # SYNTHETIC FORMAT EXAMPLE -- NOT HOST TELEMETRY. Fields abridged for readability. -2026-09-21T15:00:00Z mono=100.000 event=start version=1.0.4 pid=999 mode=dry-run page_bytes=4096 armed_warmup=60 +2026-09-21T15:00:00Z mono=100.000 event=start version=1.0.5 pid=999 mode=dry-run page_bytes=4096 armed_warmup=60 2026-09-18T15:00:01Z mono=101.000 event=sample state=NORMAL action_pressure=0 floor=0 free_pages=425950 lotsfree=130875 desfree=65437 minfree=49077 nscan=0 pp_kernel=2976170 pageslocked=3002379 arc_ok=1 arc_bytes=1073741824 swap_committed_ok=1 swap_committed_pages=7480128 swap_physical_used_ok=1 swap_physical_used_bytes=4143648768 anon_pageout_ok=1 anon_pageout_pages=1000 swap_alloc_pages=7000000 swap_reserved_pages=480128 swap_available_pages=6135486 2026-09-18T15:00:01Z mono=101.000 event=delta metric=swap_committed_pages d5=NA d15=NA d60=NA 2026-09-18T15:00:01Z mono=101.000 event=delta metric=swap_physical_used_bytes d5=NA d15=NA d60=NA diff --git a/logs/portability.log b/logs/portability.log index bb03ee3..db0e4f9 100644 --- a/logs/portability.log +++ b/logs/portability.log @@ -1,7 +1,7 @@ make portability PASS C99 syntax with -Wall -Wextra -Werror -Wformat=2 -pedantic PASS GCC -fanalyzer for every production translation unit -PASS sh -n install.sh +PASS sh -n install.sh tests/test_distribution.sh PASS xmllint --nonet --noout smf/o6h-memory-guard.xml NOTE tests/api-sketch are local declarations, not native illumos headers or ABI validation. NOTE clang, clang-tidy, cppcheck, scan-build and shellcheck were not installed. diff --git a/smf/o6h-memory-guard.xml b/smf/o6h-memory-guard.xml index 80e59b5..61fe2be 100644 --- a/smf/o6h-memory-guard.xml +++ b/smf/o6h-memory-guard.xml @@ -11,7 +11,7 @@ @@ -19,7 +19,7 @@ diff --git a/src/guard.h b/src/guard.h index 6d28d6d..31ecd15 100644 --- a/src/guard.h +++ b/src/guard.h @@ -13,7 +13,7 @@ #define CONF_PATH "/opt/custom/etc/o6h-memory-guard.conf" #define LOG_DIR "/opt/custom/var/log/o6h-memory-guard" #define RUN_DIR "/opt/custom/var/run" -#define VERSION "1.0.4" +#define VERSION "1.0.5" enum state { NORMAL, PRE_PRESSURE, PRESSURE, CRITICAL, EMERGENCY, RECOVERY }; enum policy { OBSERVE, ALLOW, PROTECT }; diff --git a/tests/test_distribution.sh b/tests/test_distribution.sh new file mode 100644 index 0000000..368c352 --- /dev/null +++ b/tests/test_distribution.sh @@ -0,0 +1,34 @@ +#!/bin/sh +set -eu + +manifest=smf/o6h-memory-guard.xml +config=etc/o6h-memory-guard.conf + +if grep -Fq -- '--force-dry-run' "$manifest"; then + echo 'FAIL SMF manifest must not force dry-run' >&2 + exit 1 +fi + +test "$(grep -Fxc ' exec="/opt/custom/bin/o6h-memory-guard --daemon --config /opt/custom/etc/o6h-memory-guard.conf"' "$manifest")" -eq 1 +test "$(grep -Fxc ' o6h memory pressure guard' "$manifest")" -eq 1 +test "$(grep -Fxc 'ACTION_MODE dry-run' "$config")" -eq 1 + +while IFS= read -r setting; do + test "$(grep -Fxc "$setting" "$config")" -eq 1 +done <<'EOF' +PRE_SECONDS 1 +PRESSURE_SECONDS 2 +CRITICAL_SECONDS 2 +RECOVERY_SECONDS 15 +CRITICAL_TERM_GRACE_SECONDS 5 +EMERGENCY_TERM_GRACE_SECONDS 1 +FLOOR_KILL_DELAY_SECONDS 0 +MAX_CACHED_CANDIDATE_AGE_SECONDS 15 +MAX_VICTIMS_EPISODE 4 +MAX_VICTIMS_MINUTE 4 +MAX_EMERGENCY_VICTIMS_EPISODE 8 +MAX_FLOOR_VICTIMS_EPISODE 12 +EOF + +grep -Fq -- '"--force-dry-run"' src/main.c +echo 'PASS distribution defaults to ACTION_MODE dry-run; production SMF does not force it'