Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(chart): restart the pod when Helm configuration changes
Yudhi Armyndharis62f549b1ff35
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f2f626469..294a3d470 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0- The chart's optional ServiceMonitor now scrapes one target per pod instead of two. Its selector matched only the shared selector labels, which both the ClusterIP and the headless Service carry, so Prometheus discovered a target through each and produced two sets of series distinguished only by the `service` label — enough to double-count any naive aggregation. The headless Service also publishes not-ready addresses, so it kept a target pointed at a pod whose port is still closed during boot and reported it as down. The ServiceMonitor and the ClusterIP Service now share a `openwa.io/scrape-target` label that the headless Service does not carry. After upgrading, series previously collected through the headless target stop appearing: check any dashboard or alerting rule that matches on the `service` label, which now always resolves to the ClusterIP Service.- The Helm chart no longer restarts the pod while it is still starting. The container binds its port only after every bootstrap hook has finished, so during boot the endpoint is closed rather than unhealthy and each liveness probe is a connection refusal; with no startup probe the liveness settings governed that window and allowed 50 seconds before the kubelet killed the container. This is not limited to deployments using session auto-start: the database connect retry alone is up to 10 attempts three seconds apart, so a database that is slow to accept connections can consume 30 of those 50 seconds on a stock install. A startup probe now allows 300 seconds (a 5-second period, 60 failures) and fires immediately, so a fast boot is recognised in about five seconds rather than after a fixed delay — the pod becomes live sooner than before, not later. A boot that is genuinely unbounded is not made safe by any fixed budget.+- A Helm upgrade that changes only `env` or `secretEnv` now restarts the pod, so the new configuration actually reaches the running container. The pod template carried nothing derived from the ConfigMap or Secret, so such an upgrade rendered a byte-identical template and triggered no rollout: the release reported success while the process kept its previous values, because Kubernetes reads `envFrom` only when a container is created. The pod template now carries checksums of the rendered ConfigMap and Secret. Two consequences worth reading before upgrading: a configuration change now restarts this single-instance StatefulSet where previously it did not, and the chart can only observe configuration it renders itself — with `existingSecret` set no Secret is created, so changes to that operator-managed Secret still need `kubectl rollout restart`. The Secret checksum is published as a pod annotation, which is readable by anyone who can list pods; `values.yaml` notes what that means when choosing between `secretEnv` and `existingSecret`.- A participant id carrying a recognised domain but a nonsense user-part — `NOT A [email protected]`, `@c.us` — is now rejected with `400` like any other malformed id. The earlier check tested only the domain, so these still reached WhatsApp Web and produced the same undiagnosable `500` the check was added to prevent. The same rule now backs the `mentions` validator, which had the identical gap, and it covers the two membership-request routes, which take the same ids and were missed the first time. A bare phone number is also qualified before it reaches the Baileys socket; previously it went out without a domain, which WhatsApp does not read as an id at all, so the write silently did nothing. Fixes #1220.- Messages that existed before the full-text index was created are indexed on the next boot instead of being permanently unsearchable, and ordinary edits and deletes on them work again. The boot-time backfill was gated on the index being empty, but `messages_fts` is an FTS5 external-content table whose `count(*)` returns the row count of `messages`, so the condition could never hold and the backfill never ran; until those rows are indexed the sync triggers issue delete commands for documents that were never added and SQLite rejects the whole statement. The guard is now a rowid-level completeness check, so it also repairs a partially populated index rather than only an empty one.- A WhatsApp-level refusal of a group participant add, remove, promote or demote on the Baileys engine is now reported as `403` instead of propagating as an unhandled error. Participant refusals normally arrive one per participant and were already mapped; a refusal of the request itself arrives through the other channel, and this was the only write in the Baileys group adapter that did not map it. A dropped connection or a timeout is still reported as itself rather than as a permissions problem. Refs #1220.diff --git a/charts/openwa/templates/statefulset.yaml b/charts/openwa/templates/statefulset.yamlindex 75a85b831..c7525f4a2 100644--- a/charts/openwa/templates/statefulset.yaml+++ b/charts/openwa/templates/statefulset.yaml@@ -12,6 +12,15 @@ spec:{{- include "openwa.selectorLabels" . | nindent 6 }}template:metadata:+ # envFrom is read once, when the container is created — Kubernetes never updates it in a+ # running container. Without something config-derived here, a `helm upgrade` that changes only+ # env/secretEnv renders an identical pod template, so no rollout happens and the process keeps+ # its old values while the release reports success. Hashing the RENDERED objects rather than+ # `.Values` on purpose: a change to the template itself — a new key, a changed quoting rule —+ # alters the ConfigMap without altering the values it was built from.+ annotations:+ checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}+ checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}labels:{{- include "openwa.selectorLabels" . | nindent 8 }}spec:diff --git a/charts/openwa/values.yaml b/charts/openwa/values.yamlindex 6e49c6aa0..ff1b3e4b9 100644--- a/charts/openwa/values.yaml+++ b/charts/openwa/values.yaml@@ -29,6 +29,15 @@ env:secretEnv:API_MASTER_KEY: ""+# Note: a sha256 of the rendered Secret is published as a pod annotation so that changing+# secretEnv restarts the pod — without it the new value would never reach the running+# container. Pod annotations are readable by anyone with `get pods`, which is a wider set+# than `get secrets` under a common RBAC split, so someone who can list Pods can confirm a+# guessed value offline. Uninteresting for a high-entropy API_MASTER_KEY; worth knowing+# before adding something like DATABASE_PASSWORD here. Use existingSecret below to keep the+# value out of the chart entirely — the trade is that the chart can no longer detect changes+# to it, so restarts become `kubectl rollout restart`.+## Name of an existing, operator-managed Secret to load via envFrom instead of the# chart-managed one. When set, secretEnv is ignored and no Secret is created.existingSecret: ""