Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(chart): scrape one target per pod, not two
Yudhi Armyndharis7ea6c7644961
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 761d120dd..0185bbe82 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0### Fixed+- 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.- 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/service.yaml b/charts/openwa/templates/service.yamlindex 489d61cf6..782c4ef8f 100644--- a/charts/openwa/templates/service.yaml+++ b/charts/openwa/templates/service.yaml@@ -4,6 +4,11 @@ metadata:name: {{ include "openwa.fullname" . }}labels:{{- include "openwa.labels" . | nindent 4 }}+ # Marks this Service as the single scrape target. Deliberately NOT in `openwa.labels`: the+ # headless Service must not carry it, or the ServiceMonitor matches both again. The headless+ # Service exists for StatefulSet DNS and sets publishNotReadyAddresses, so scraping it also+ # produces `up=0` for a pod that is still starting.+ openwa.io/scrape-target: "primary"spec:type: {{ .Values.service.type }}selector:diff --git a/charts/openwa/templates/servicemonitor.yaml b/charts/openwa/templates/servicemonitor.yamlindex a4a5457ba..47361f238 100644--- a/charts/openwa/templates/servicemonitor.yaml+++ b/charts/openwa/templates/servicemonitor.yaml@@ -10,8 +10,14 @@ metadata:{{- end }}spec:selector:+ # Names ONE Service. Prometheus Operator's endpoints-role discovery yields a target per address+ # for every Service matching this selector, with no cross-Service de-duplication by pod — so a+ # selector of only the shared selectorLabels matches both the ClusterIP and the headless Service+ # and produces two targets for the same pod, and two sets of series distinguished only by the+ # `service` label.matchLabels:{{- include "openwa.selectorLabels" . | nindent 6 }}+ openwa.io/scrape-target: "primary"endpoints:- port: httppath: /api/metrics