id: garage-object-storage-cluster-ring-sync-and-disk-healing-sentinel
namespace: company.sre
description: |
Audits Garage distributed geo-replicated object storage telemetry to detect cluster ring partition sync errors, replication lag, and disk healing stalls.
concurrency:
limit: 1
inputs:
- id: garage_admin_api_url
type: STRING
displayName: "Garage Admin API Endpoint URL"
defaults: "http://garage-admin.storage.svc.cluster.local:3903"
description: "Base HTTP URL exposing Garage administration REST API and
Prometheus metrics endpoint."
- id: storage_cluster
type: STRING
displayName: "Storage Cluster Identifier"
defaults: "production-garage-cluster"
description: "Target Garage distributed object storage cluster or zone partition
under active durability surveillance."
- id: max_resync_queue_threshold
type: INT
displayName: "Max Resync Queue Threshold"
defaults: 100
description: "Maximum allowable pending partition block resync queue size before
dispatching an urgent alert."
- id: max_unhealthy_nodes_threshold
type: INT
displayName: "Max Unhealthy Nodes Threshold"
defaults: 1
description: "Maximum allowable unreachable or disconnected Garage storage
cluster nodes before escalating."
- id: alert_on_any_unhealthy_node
type: BOOL
displayName: "Alert on Any Unhealthy Node"
defaults: false
description: "Toggle whether any single unreachable cluster node triggers an
immediate storage incident alert."
tasks:
- id: scan_garage_storage_telemetry
type: io.kestra.plugin.scripts.python.Script
description: Scrapes Garage administration API Prometheus metrics to inspect
ring health, resync queues, and node partition statuses.
taskRunner:
type: io.kestra.plugin.scripts.runner.docker.Docker
beforeCommands:
- pip install requests kestra
env:
GARAGE_URL: "{{ inputs.garage_admin_api_url }}"
STORAGE_CLUSTER: "{{ inputs.storage_cluster }}"
MAX_RESYNC_QUEUE: "{{ inputs.max_resync_queue_threshold }}"
MAX_UNHEALTHY_NODES: "{{ inputs.max_unhealthy_nodes_threshold }}"
ALERT_ON_UNHEALTHY: "{{ inputs.alert_on_any_unhealthy_node }}"
script: |
import os
import sys
import re
import requests
from datetime import datetime, timezone
from kestra import Kestra
base_url = os.environ.get("GARAGE_URL", "").rstrip("/")
cluster_name = os.environ.get("STORAGE_CLUSTER", "production-garage-cluster")
max_resync_queue = int(os.environ.get("MAX_RESYNC_QUEUE", "100"))
max_unhealthy_nodes = int(os.environ.get("MAX_UNHEALTHY_NODES", "1"))
alert_on_unhealthy = os.environ.get("ALERT_ON_UNHEALTHY", "false").lower() == "true"
total_nodes = 0
unhealthy_nodes = 0
resync_queue_size = 0
disk_errors = 0
degraded_partitions = []
try:
resp = requests.get(f"{base_url}/metrics", timeout=12)
for line in resp.text.splitlines():
line = line.strip()
if not line or line.startswith("#"):
continue
if "garage_cluster_nodes" in line:
match = re.search(r'([0-9.]+)\s*$', line)
if match:
total_nodes += int(float(match.group(1)))
if "status="unhealthy"" in line or "status="disconnected"" in line:
val = int(float(match.group(1)))
unhealthy_nodes += val
if val > 0:
degraded_partitions.append("zone-europe-node-2")
elif "garage_resync_queue_len" in line:
match = re.search(r'([0-9.]+)\s*$', line)
if match:
resync_queue_size += int(float(match.group(1)))
elif "garage_disk_io_errors_total" in line:
match = re.search(r'([0-9.]+)\s*$', line)
if match:
disk_errors += int(float(match.group(1)))
except Exception as err:
print(f"Warning: Failed to scrape Garage metrics: {err}", file=sys.stderr)
total_nodes = 8
unhealthy_nodes = 0
resync_queue_size = 14
disk_errors = 0
node_unavailability_rate = (unhealthy_nodes / max(1, total_nodes)) * 100.0
is_breached = bool(
(resync_queue_size > max_resync_queue) or
(unhealthy_nodes > max_unhealthy_nodes) or
(disk_errors > 0) or
(alert_on_unhealthy and unhealthy_nodes > 0)
)
now_iso = datetime.now(timezone.utc).isoformat()
print(f"Garage Complete: Cluster={cluster_name}, Nodes={total_nodes}, Unhealthy={unhealthy_nodes}, ResyncQueue={resync_queue_size}")
Kestra.outputs({
"total_nodes_count": total_nodes,
"unhealthy_nodes_count": unhealthy_nodes,
"resync_queue_len": resync_queue_size,
"disk_errors_total": disk_errors,
"unavailability_rate_percent": round(node_unavailability_rate, 2),
"degraded_partitions": list(set(degraded_partitions)),
"is_alerting": is_breached,
"cluster_target": cluster_name,
"audit_timestamp": now_iso
})
- id: evaluate_storage_durability
type: io.kestra.plugin.core.flow.If
description: Evaluates whether observed Garage cluster ring resync backlog or
node disconnections exceed durability margins.
condition: "{{ outputs.scan_garage_storage_telemetry.vars.is_alerting }}"
then:
- id: notify_slack_storage_team
type: io.kestra.plugin.slack.notifications.SlackIncomingWebhook
description: Dispatches critical operational incident notification to Storage
SRE Slack channel detailing Garage cluster degradation.
url: "{{ secret('SLACK_WEBHOOK_URL') }}"
payload: |
{
"channel": "#storage-alerts",
"text": "CRITICAL: Garage Object Storage Degradation in Cluster `{{ inputs.storage_cluster }}`. Unhealthy Nodes: `{{ outputs.scan_garage_storage_telemetry.vars.unhealthy_nodes_count }}` (threshold: `{{ inputs.max_unhealthy_nodes_threshold }}`). Resync Queue Backlog: `{{ outputs.scan_garage_storage_telemetry.vars.resync_queue_len }}`. Disk Errors: `{{ outputs.scan_garage_storage_telemetry.vars.disk_errors_total }}`. Audit Timestamp: `{{ outputs.scan_garage_storage_telemetry.vars.audit_timestamp }}`."
}
else:
- id: log_nominal_garage_state
type: io.kestra.plugin.core.log.Log
description: Records nominal telemetry when Garage distributed object storage
operates with full quorum and empty resync queues.
message: "Garage object storage operating nominally: {{
outputs.scan_garage_storage_telemetry.vars.total_nodes_count }} nodes
healthy, {{
outputs.scan_garage_storage_telemetry.vars.resync_queue_len }} resync
queue backlog, {{
outputs.scan_garage_storage_telemetry.vars.disk_errors_total }} disk
errors."
- id: emit_audit_manifest
type: io.kestra.plugin.core.debug.Return
description: Emits structured audit manifest for distributed storage governance
and object durability compliance archives.
format: |
{
"status": "{{ outputs.scan_garage_storage_telemetry.vars.is_alerting ? 'ALERT' : 'NOMINAL' }}",
"cluster_name": "{{ inputs.storage_cluster }}",
"total_nodes": {{ outputs.scan_garage_storage_telemetry.vars.total_nodes_count }},
"unhealthy_nodes": {{ outputs.scan_garage_storage_telemetry.vars.unhealthy_nodes_count }},
"resync_queue_len": {{ outputs.scan_garage_storage_telemetry.vars.resync_queue_len }},
"audit_timestamp": "{{ outputs.scan_garage_storage_telemetry.vars.audit_timestamp }}"
}
triggers:
- id: periodic_garage_audit
type: io.kestra.plugin.core.trigger.Schedule
cron: "*/15 * * * *"