From 06752b96fd2fbadad9cd43dd677895c870e28b5f Mon Sep 17 00:00:00 2001 From: Mohammed Naser Date: Tue, 19 May 2026 09:06:55 -0400 Subject: [PATCH] Add NodeMemoryHighUtilization alert (hugepages-aware) with docs and tests (#3936) Signed-off-by: Mohammed Naser Signed-off-by: Rico Lin Co-authored-by: Rico Lin --- doc/source/admin/monitoring.rst | 77 +++++++++++++++---- ...ilization-huge-pages-3a7d9f2c0b6e1d5a.yaml | 7 ++ ...cksdk-modern-default-5b4e0cf83d9a2c1f.yaml | 6 ++ .../files/jsonnet/mixins.libsonnet | 33 +++++++- .../files/jsonnet/tests.yml | 72 +++++++++++++++++ roles/openstacksdk/defaults/main.yml | 3 + roles/openstacksdk/tasks/main.yml | 6 +- 7 files changed, 187 insertions(+), 17 deletions(-) create mode 100644 releasenotes/notes/node-memory-high-utilization-huge-pages-3a7d9f2c0b6e1d5a.yaml create mode 100644 releasenotes/notes/openstacksdk-modern-default-5b4e0cf83d9a2c1f.yaml diff --git a/doc/source/admin/monitoring.rst b/doc/source/admin/monitoring.rst index a64814a9..27330fc7 100644 --- a/doc/source/admin/monitoring.rst +++ b/doc/source/admin/monitoring.rst @@ -4,7 +4,7 @@ Monitoring and operations Atmosphere includes a Grafana deployment with dashboards created by default and a Prometheus deployment that collects metrics from the cluster and sends alerts -to AlertManager. Loki also collects logs from the cluster using Vector. +to Alertmanager. Loki also collects logs from the cluster using Vector. ****************************** Philosophy and alerting levels @@ -49,7 +49,7 @@ Inhibition and grouping ----------------------- Alerts have dependency awareness. When a parent component fails (for example, a -node goes down), inhibition rules in AlertManager suppress child component +node goes down), inhibition rules in Alertmanager suppress child component alerts (for example, pods on that node) to avoid cascading alert storms. The system groups related alerts so that a single notification represents a coherent incident rather than dozens of individual symptoms. @@ -126,23 +126,23 @@ as an admin user. :alt: Silences menu :width: 200 -2. Make sure that you select "AlertManager" on the top right corner of the page, - this ensures that you create a silence inside of the AlertManager +2. Make sure that you select "Alertmanager" on the top right corner of the page, + this ensures that you create a silence inside of the Alertmanager that's managed by the Prometheus operator instead of the built-in Grafana - AlertManager which isn't used. + Alertmanager which isn't used. .. image:: images/monitoring-alertmanger-list.png - :alt: AlertManager list + :alt: Alertmanager list :width: 200 - .. admonition:: AlertManager selection + .. admonition:: Alertmanager selection :class: warning - It's important that you select the AlertManager that's managed by the + It's important that you select the Alertmanager that's managed by the Prometheus operator, otherwise your silence won't apply to the Prometheus instance that Atmosphere deploys. -3. Click the "Add Silence" button and use the AlertManager format to create +3. Click the "Add Silence" button and use the Alertmanager format to create your silence, which you can test by seeing if it matches any alerts in the list labeled "Affected alert instances". @@ -211,7 +211,7 @@ Viewing data ************ The monitoring stack offers a few different ways to view collected data. The most -common ways are through AlertManager, Grafana, and Prometheus. +common ways are through Alertmanager, Grafana, and Prometheus. Grafana dashboard ================= @@ -298,10 +298,10 @@ changes to your inventory: In this example, the configuration restricts access to the IP range ``10.0.0.0/24`` and the IP address ``172.10.0.1``. -AlertManager +Alertmanager ============ -By default, the AlertManager dashboard points to the Ansible variable +By default, the Alertmanager dashboard points to the Ansible variable ``kube_prometheus_stack_alertmanager_host`` and sits behind an ``Ingress`` with the `oauth2-proxy` service, protected by Keycloak similar to Prometheus. @@ -309,10 +309,10 @@ with the `oauth2-proxy` service, protected by Keycloak similar to Prometheus. Integrations ************ -Since Atmosphere relies on AlertManager to send alerts, you can integrate it +Since Atmosphere relies on Alertmanager to send alerts, you can integrate it with services like OpsGenie, PagerDuty, email, and more. To receive monitoring alerts using your preferred notification tools, integrate them with -AlertManager. +Alertmanager. OpsGenie ======== @@ -1172,6 +1172,55 @@ true per-operation latency at the block device layer. replace the failed member. For standalone disks, migrate workloads before the disk fails completely. +``NodeMemoryHighUtilization`` +============================= + +This alert fires when computed node memory utilization exceeds 90% for at +least 15 minutes. The calculation uses normal available memory +(``node_memory_MemAvailable_bytes``) plus free huge page capacity +(``node_memory_HugePages_Free * node_memory_Hugepagesize_bytes``), then compares +it with total memory. If huge page metrics are absent on a node, the alert +automatically falls back to ``MemAvailable``-only behavior. This avoids false +positives on compute nodes that intentionally reserve large huge page pools for +VM workloads while preserving normal behavior elsewhere. + +**Likely Root Causes** + +- Real host-level memory pressure from application or system processes. +- Workload density increase that reduced both normal free memory and free huge + pages. +- Memory leak in host services, virtualization daemons, or VM workloads. +- Unexpected huge page consumption reducing the free huge page pool. + +**Diagnostic and Remediation Steps** + +1. Identify the affected node from the alert ``instance`` label. + +2. Validate memory pressure from Prometheus metrics: + + .. code-block:: console + + kubectl -n monitoring exec svc/kube-prometheus-stack-prometheus -- \ + promtool query instant http://localhost:9090 \ + '(1 - ((node_memory_MemAvailable_bytes{instance="",job="node-exporter"} + (node_memory_HugePages_Free{instance="",job="node-exporter"} * node_memory_Hugepagesize_bytes{instance="",job="node-exporter"})) / node_memory_MemTotal_bytes{instance="",job="node-exporter"})) * 100' + +3. Inspect current host memory and huge page usage: + + .. code-block:: console + + free -h + grep -E 'HugePages_(Total|Free|Rsvd|Surp)|Hugepagesize' /proc/meminfo + +4. Identify the top memory consumers on the host: + + .. code-block:: console + + ps aux --sort=-rss | head -20 + +5. If huge page usage depletes the free pool, investigate VM placement and + compute scheduling changes. If normal memory runs out, move workloads, + increase host capacity, or resolve memory leaks. + ``NginxIngressCriticalErrorBudgetBurn`` ======================================= diff --git a/releasenotes/notes/node-memory-high-utilization-huge-pages-3a7d9f2c0b6e1d5a.yaml b/releasenotes/notes/node-memory-high-utilization-huge-pages-3a7d9f2c0b6e1d5a.yaml new file mode 100644 index 00000000..5c84bf84 --- /dev/null +++ b/releasenotes/notes/node-memory-high-utilization-huge-pages-3a7d9f2c0b6e1d5a.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + The ``NodeMemoryHighUtilization`` alert now counts free huge page capacity + as available memory. This reduces false positives on compute nodes that + reserve huge page pools for virtual machine workloads while preserving the + previous behavior on nodes without huge page metrics. diff --git a/releasenotes/notes/openstacksdk-modern-default-5b4e0cf83d9a2c1f.yaml b/releasenotes/notes/openstacksdk-modern-default-5b4e0cf83d9a2c1f.yaml new file mode 100644 index 00000000..6363e273 --- /dev/null +++ b/releasenotes/notes/openstacksdk-modern-default-5b4e0cf83d9a2c1f.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + The ``openstacksdk`` role now requires a modern SDK release when operators + don't pin an exact version. This avoids reusing old image-baked SDK + versions that are incompatible with supported Python releases. diff --git a/roles/kube_prometheus_stack/files/jsonnet/mixins.libsonnet b/roles/kube_prometheus_stack/files/jsonnet/mixins.libsonnet index 90c309de..7b72b481 100644 --- a/roles/kube_prometheus_stack/files/jsonnet/mixins.libsonnet +++ b/roles/kube_prometheus_stack/files/jsonnet/mixins.libsonnet @@ -210,7 +210,38 @@ local mixins = { diskDeviceSelector: 'device=~"(/dev/)?(mmcblk.p.+|nvme.+|rbd.+|sd.+|vd.+|xvd.+|dm-.+|md.+|dasd.+)"', }, prometheusAlerts+:: { - groups+: [ + groups: [ + if group.name == 'node-exporter' then group { + rules: [ + if rule.alert == 'NodeMemoryHighUtilization' then rule { + expr: ||| + 100 - ( + ( + node_memory_MemAvailable_bytes{%(nodeExporterSelector)s} + + + ( + ( + node_memory_HugePages_Free{%(nodeExporterSelector)s} + * on(instance, job) group_left() + node_memory_Hugepagesize_bytes{%(nodeExporterSelector)s} + ) + or on(instance, job) + (0 * node_memory_MemAvailable_bytes{%(nodeExporterSelector)s}) + ) + ) / node_memory_MemTotal_bytes{%(nodeExporterSelector)s} * 100 + ) > %(memoryHighUtilizationThreshold)d + ||| % mixins.node._config, + annotations+: { + summary: 'Node memory: high utilization can affect host and workload stability', + description: 'Computed node memory utilization at {{ $labels.instance }} is {{ printf "%.2f" $value }}%, exceeding the threshold of 90% for 15 minutes. This computation includes free huge page capacity (node_memory_HugePages_Free * node_memory_Hugepagesize_bytes) in available memory to avoid false positives on compute nodes backed by huge pages. Normal behavior is below 90% sustained utilization.', + runbook_url: 'https://vexxhost.github.io/atmosphere/admin/monitoring.html#nodememoryhighutilization', + }, + } else rule + for rule in group.rules + ], + } else group + for group in super.groups + ] + [ { name: 'node-exporter-extras', rules: [ diff --git a/roles/kube_prometheus_stack/files/jsonnet/tests.yml b/roles/kube_prometheus_stack/files/jsonnet/tests.yml index 3ca8b585..1ad778a1 100644 --- a/roles/kube_prometheus_stack/files/jsonnet/tests.yml +++ b/roles/kube_prometheus_stack/files/jsonnet/tests.yml @@ -147,6 +147,78 @@ tests: description: "Average IO latency on nvme0n1 at 192.0.2.2:9100 is 50ms over the last 5 minutes, which exceeds the threshold of 20ms. Normal SSD latency is below 1ms and normal HDD latency is below 15ms." runbook_url: "https://vexxhost.github.io/atmosphere/admin/monitoring.html#nodediskhighlatency" + # NodeMemoryHighUtilization - negative test (huge pages reserved but free) + - interval: 1m + input_series: + - series: 'node_memory_MemTotal_bytes{instance="192.0.2.3:9100", job="node-exporter"}' + values: '1000x20' + - series: 'node_memory_MemAvailable_bytes{instance="192.0.2.3:9100", job="node-exporter"}' + values: '50x20' + - series: 'node_memory_HugePages_Free{instance="192.0.2.3:9100", job="node-exporter"}' + values: '200x20' + - series: 'node_memory_Hugepagesize_bytes{instance="192.0.2.3:9100", job="node-exporter"}' + values: '4x20' + alert_rule_test: + - eval_time: 16m + alertname: NodeMemoryHighUtilization + exp_alerts: [] + + # NodeMemoryHighUtilization - positive test (real high utilization, alert fires) + - interval: 1m + input_series: + - series: 'node_memory_MemTotal_bytes{instance="192.0.2.4:9100", job="node-exporter"}' + values: '1000x20' + - series: 'node_memory_MemAvailable_bytes{instance="192.0.2.4:9100", job="node-exporter"}' + values: '50x20' + - series: 'node_memory_HugePages_Free{instance="192.0.2.4:9100", job="node-exporter"}' + values: '20x20' + - series: 'node_memory_Hugepagesize_bytes{instance="192.0.2.4:9100", job="node-exporter"}' + values: '1x20' + alert_rule_test: + - eval_time: 16m + alertname: NodeMemoryHighUtilization + exp_alerts: + - exp_labels: + severity: P3 + instance: "192.0.2.4:9100" + job: node-exporter + exp_annotations: + summary: "Node memory: high utilization can affect host and workload stability" + description: "Computed node memory utilization at 192.0.2.4:9100 is 93.00%, exceeding the threshold of 90% for 15 minutes. This computation includes free huge page capacity (node_memory_HugePages_Free * node_memory_Hugepagesize_bytes) in available memory to avoid false positives on compute nodes backed by huge pages. Normal behavior is below 90% sustained utilization." + runbook_url: "https://vexxhost.github.io/atmosphere/admin/monitoring.html#nodememoryhighutilization" + + # NodeMemoryHighUtilization - negative test (no huge page metrics, normal memory usage) + - interval: 1m + input_series: + - series: 'node_memory_MemTotal_bytes{instance="192.0.2.5:9100", job="node-exporter"}' + values: '1000x20' + - series: 'node_memory_MemAvailable_bytes{instance="192.0.2.5:9100", job="node-exporter"}' + values: '150x20' + alert_rule_test: + - eval_time: 16m + alertname: NodeMemoryHighUtilization + exp_alerts: [] + + # NodeMemoryHighUtilization - positive test (no huge page metrics, high memory usage) + - interval: 1m + input_series: + - series: 'node_memory_MemTotal_bytes{instance="192.0.2.6:9100", job="node-exporter"}' + values: '1000x20' + - series: 'node_memory_MemAvailable_bytes{instance="192.0.2.6:9100", job="node-exporter"}' + values: '50x20' + alert_rule_test: + - eval_time: 16m + alertname: NodeMemoryHighUtilization + exp_alerts: + - exp_labels: + severity: P3 + instance: "192.0.2.6:9100" + job: node-exporter + exp_annotations: + summary: "Node memory: high utilization can affect host and workload stability" + description: "Computed node memory utilization at 192.0.2.6:9100 is 95.00%, exceeding the threshold of 90% for 15 minutes. This computation includes free huge page capacity (node_memory_HugePages_Free * node_memory_Hugepagesize_bytes) in available memory to avoid false positives on compute nodes backed by huge pages. Normal behavior is below 90% sustained utilization." + runbook_url: "https://vexxhost.github.io/atmosphere/admin/monitoring.html#nodememoryhighutilization" + - interval: 1m input_series: - series: 'mysql_up{instance="percona-xtradb-pxc-0", job="pxc"}' diff --git a/roles/openstacksdk/defaults/main.yml b/roles/openstacksdk/defaults/main.yml index 96db7681..90fdb2c6 100644 --- a/roles/openstacksdk/defaults/main.yml +++ b/roles/openstacksdk/defaults/main.yml @@ -12,4 +12,7 @@ # License for the specific language governing permissions and limitations # under the License. +# Set this to pin the exact ``openstacksdk`` version installed by the role. +# When unset, the role installs ``openstacksdk>1`` to avoid old SDK versions +# that are incompatible with supported Python releases. # openstacksdk_version: diff --git a/roles/openstacksdk/tasks/main.yml b/roles/openstacksdk/tasks/main.yml index a44e2d0a..4321a556 100644 --- a/roles/openstacksdk/tasks/main.yml +++ b/roles/openstacksdk/tasks/main.yml @@ -14,8 +14,10 @@ - name: Install openstacksdk ansible.builtin.pip: - name: openstacksdk - version: "{{ openstacksdk_version | default(omit) }}" + name: >- + {{ 'openstacksdk==' + openstacksdk_version + if openstacksdk_version is defined + else 'openstacksdk>1' }} register: _openstacksdk_pip_install retries: 3 delay: 5