id: rook-ceph-operator-reconciliation-loop-stall-sentinel
namespace: company.sre
description: |
Monitors Rook Ceph Kubernetes operator telemetry to detect reconciliation loop timeouts, blocked CRD syncs, and daemon spec stalls across storage clusters.
concurrency:
limit: 1
inputs:
- id: rook_metrics_url
type: STRING
displayName: "Rook Operator Metrics URL"
defaults: "http://rook-ceph-operator.rook-ceph.svc.cluster.local:9090"
description: "Base HTTP URL exposing Prometheus metrics for the Rook Ceph
storage orchestration operator."
- id: cluster_namespace
type: STRING
displayName: "Rook Ceph Namespace"
defaults: "rook-ceph"
description: "Kubernetes namespace housing the CephCluster custom resource and
operator pods."
- id: max_reconciliation_errors_threshold
type: INT
displayName: "Max Reconcile Errors Threshold"
defaults: 2
description: "Maximum allowable operator reconciliation loop errors within the
evaluation window before alerting."
- id: lookback_minutes
type: INT
displayName: "Lookback Period (Minutes)"
defaults: 15
description: "Time duration in minutes across which operator reconcile errors
and queue latency are evaluated."
- id: alert_on_operator_stall
type: BOOL
displayName: "Alert On Operator Stall"
defaults: true
description: "Toggle whether Slack alerts are dispatched upon detecting operator
reconciliation stalls."
tasks:
- id: scan_rook_operator_metrics
type: io.kestra.plugin.scripts.python.Script
description: Scrapes Rook Ceph operator Prometheus metrics to calculate
reconciliation errors, loop duration, and CRD status health.
containerImage: python:3.11-slim
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
beforeCommands:
- pip install requests kestra
env:
METRICS_URL: "{{ inputs.rook_metrics_url }}"
NAMESPACE: "{{ inputs.cluster_namespace }}"
MAX_ERRORS: "{{ inputs.max_reconciliation_errors_threshold }}"
LOOKBACK_MIN: "{{ inputs.lookback_minutes }}"
script: |
import os
import sys
import re
from datetime import datetime, timezone
import requests
from kestra import Kestra
metrics_url = os.environ.get("METRICS_URL", "http://rook-ceph-operator:9090").rstrip("/")
namespace = os.environ.get("NAMESPACE", "rook-ceph")
max_errors = int(os.environ.get("MAX_ERRORS", "2"))
lookback = int(os.environ.get("LOOKBACK_MIN", "15"))
reconcile_errors = 0
reconcile_duration_sec = 0.0
cr_health_code = 1
is_stalled = False
try:
resp = requests.get(f"{metrics_url}/metrics", timeout=12)
resp.raise_for_status()
lines = resp.text.splitlines()
for line in lines:
if line.startswith("#") or not line.strip():
continue
if "controller_runtime_reconcile_errors_total" in line and 'controller="ceph-cluster-controller"' in line:
match = re.search(r'([0-9\.]+)\s*$', line)
if match:
reconcile_errors += int(float(match.group(1)))
elif "controller_runtime_reconcile_time_seconds" in line and 'quantile="0.99"' in line:
match = re.search(r'([0-9\.]+)\s*$', line)
if match:
reconcile_duration_sec = float(match.group(1))
elif "rook_ceph_cluster_state" in line and 'state="Progressing"' in line:
match = re.search(r'([0-9\.]+)\s*$', line)
if match and float(match.group(1)) > 0:
cr_health_code = 2
except Exception as err:
print(f"Warning: Failed to reach Rook operator metrics endpoint: {err}", file=sys.stderr)
reconcile_errors = 4
reconcile_duration_sec = 185.0
cr_health_code = 2
if reconcile_duration_sec > 120.0 or reconcile_errors >= max_errors:
is_stalled = True
is_breached = bool(is_stalled or reconcile_errors >= max_errors)
now_iso = datetime.now(timezone.utc).isoformat()
print(f"Rook Ceph Complete: Errors={reconcile_errors}, Duration={reconcile_duration_sec}s, Stalled={is_stalled}, Alert={is_breached}")
Kestra.outputs({
"reconcile_errors_count": reconcile_errors,
"reconcile_duration_seconds": round(reconcile_duration_sec, 2),
"is_operator_stalled": is_stalled,
"is_alerting": is_breached,
"namespace_target": namespace,
"audit_timestamp": now_iso
})
- id: evaluate_reconciliation_threshold
type: io.kestra.plugin.core.flow.If
description: Verifies whether observed Rook Ceph operator reconciliation errors
or duration exceed operational safety bounds.
condition: "{{ outputs.scan_rook_operator_metrics.vars.is_alerting and
inputs.alert_on_operator_stall }}"
then:
- id: notify_slack_storage_team
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Dispatches high-urgency incident notification to Storage SRE Slack
channel detailing Rook operator reconciliation stall.
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "#storage-sre-alerts",
"username": "Rook Ceph Sentinel",
"icon_emoji": ":package:",
"text": "CRITICAL: Rook Ceph operator reconciliation stall detected in namespace `{{ inputs.cluster_namespace }}`. Reconcile Errors: `{{ outputs.scan_rook_operator_metrics.vars.reconcile_errors_count }}` (threshold: `{{ inputs.max_reconciliation_errors_threshold }}`). Loop Duration: `{{ outputs.scan_rook_operator_metrics.vars.reconcile_duration_seconds }}s`. CephCluster custom resource changes and OSD volume provisioning are blocked."
}
else:
- id: log_nominal_rook_state
type: io.kestra.plugin.core.log.Log
description: Records nominal telemetry when Rook Ceph operator reconciles custom
resources cleanly without sync loop stalls.
message: "Rook Ceph operator in namespace {{ inputs.cluster_namespace }}
nominal. Loop duration {{
outputs.scan_rook_operator_metrics.vars.reconcile_duration_seconds
}}s. Reconcile errors: {{
outputs.scan_rook_operator_metrics.vars.reconcile_errors_count }} is
below threshold {{ inputs.max_reconciliation_errors_threshold }}."
- id: emit_audit_manifest
type: io.kestra.plugin.core.debug.Return
description: Emits structured audit manifest for cloud-native storage platform
logs and CRD reconciliation history.
format: |
{
"status": "{{ outputs.scan_rook_operator_metrics.vars.is_alerting ? 'ALERT' : 'NOMINAL' }}",
"namespace": "{{ inputs.cluster_namespace }}",
"reconcile_errors": {{ outputs.scan_rook_operator_metrics.vars.reconcile_errors_count }},
"reconcile_duration_seconds": {{ outputs.scan_rook_operator_metrics.vars.reconcile_duration_seconds }},
"is_stalled": {{ outputs.scan_rook_operator_metrics.vars.is_operator_stalled }},
"audit_timestamp": "{{ outputs.scan_rook_operator_metrics.vars.audit_timestamp }}"
}
triggers:
- id: periodic_rook_audit
type: io.kestra.plugin.core.trigger.Schedule
cron: "*/15 * * * *"