Skip to content

Latest commit

 

History

History
350 lines (261 loc) · 20.7 KB

runbook.md

File metadata and controls

350 lines (261 loc) · 20.7 KB

HyperFleet Adapter Runbook

Audience: On-call engineers managing the hyperfleet-adapter service.


Table of Contents

  1. Service Overview
  2. Health Checks
  3. Failure Modes
  4. Tracing / OpenTelemetry Issues
  5. Recovery Procedures
  6. Escalation Paths

Service Overview

The hyperfleet-adapter consumes CloudEvents from a message broker (Google Pub/Sub or RabbitMQ), evaluates preconditions, applies Kubernetes resources through its transports (the local Kubernetes API, or a remote store that an applier reads), and reports status back to the HyperFleet API.

Ports:

  • 8080 — Health endpoints (/healthz, /readyz)
  • 9090 — Prometheus metrics (/metrics)

Startup sequence:

  1. Load adapter config and task config
  2. Initialize OpenTelemetry tracing
  3. Start health server and metrics server
  4. Create HyperFleet API client
  5. Create transport clients (local Kubernetes and any remote transports)
  6. Build executor
  7. Create broker subscriber and subscribe to topic
  8. Mark readiness (/readyz returns 200)

Any failure in steps 1–7 causes the process to exit with code 1.


Health Checks

Endpoint Probe Type Behavior
/healthz Liveness Always returns 200 OK
/readyz Readiness Returns 200 OK when config is loaded and broker is connected

Readiness checks

Check Meaning
config Adapter and task configs loaded successfully
broker Broker subscription established

If /readyz returns 503, inspect the response body for which check is failing:

kubectl exec <pod> -- curl -s localhost:8080/readyz | jq .

Failure Modes

Adapter Fails to Start

Symptoms: Pod is in CrashLoopBackOff. Exit code 1 in container logs.

Common causes and resolution:

Log Pattern Cause Resolution
"adapter config file path is required" Missing --config flag or HYPERFLEET_ADAPTER_CONFIG env Check deployment args and ConfigMap mount
"task config file path is required" Missing --task-config flag or HYPERFLEET_TASK_CONFIG env Check deployment args and ConfigMap mount
"failed to read adapter config file" ConfigMap not mounted or wrong path Verify ConfigMap exists and volumeMount path matches
"failed to parse adapter config YAML" Invalid YAML syntax Validate config YAML offline with yq
"unsupported apiVersion" Config version mismatch Update config to match expected apiVersion
"adapter version mismatch" spec.adapter.version doesn't match binary version Update config or redeploy matching binary version
"HyperFleet API base URL not configured" Missing spec.clients.hyperfleetApi.baseUrl Set base URL in adapter config or HYPERFLEET_API_BASE_URL env

Steps:

  1. Check pod logs: kubectl logs <pod> --previous
  2. Verify ConfigMaps exist: kubectl get configmap -l app.kubernetes.io/name=hyperfleet-adapter
  3. Verify volume mounts: kubectl describe pod <pod> — look for mount paths
  4. Validate config offline: kubectl get configmap <name> -o yaml | yq .data

Broker Connectivity Issues

Symptoms: Pod starts but /readyz returns 503 with broker: error. Or pod crashes with broker-related errors.

Log Pattern Cause Resolution
"Missing required broker configuration" subscription_id or topic not set in adapter config Check adapter config ConfigMap; set values directly in YAML (not via env vars for RabbitMQ)
"Failed to create subscriber" Broker backend misconfiguration Verify broker connection settings (Pub/Sub project, RabbitMQ URL)
"Failed to subscribe to topic" Topic doesn't exist or permissions denied Verify topic/exchange exists and adapter has access
"Subscription error" Transient broker error Usually recovers; monitor for frequency
"Fatal subscription error, shutting down" Unrecoverable broker error Check broker service health; adapter will restart via liveness probe

Steps:

  1. Check broker ConfigMap: kubectl get configmap <release>-hyperfleet-adapter-broker -o yaml
  2. Check adapter config ConfigMap: kubectl get configmap <release>-hyperfleet-adapter-config -o yaml
  3. For Google Pub/Sub: verify subscription exists and IAM permissions
  4. For RabbitMQ:
    • Verify broker.yaml exchange matches the sentinel's clients.broker.topic — this is the most common misconfiguration
    • Verify subscription_id in the adapter config is unique per adapter instance (shared IDs cause competing consumers, not fan-out)
    • Check the queue exists and is bound to the exchange: rabbitmqctl list_bindings
    • Check the queue has consumers: rabbitmqctl list_queues name messages consumers
    • Verify TCP connectivity to RabbitMQ from the pod network
  5. Check if broker service is healthy independently

Config Loading Failures

Symptoms: Pod crashes immediately on startup with config-related errors.

Log Pattern Cause Resolution
"referenced file ... does not exist" Task config references a file not in the ConfigMap Ensure all ref: files are included in the ConfigMap
"CEL parse error" Invalid CEL expression in preconditions Fix CEL syntax in task config
"undefined template variable" Template references a variable not in params Check param names match template variables
"mutually exclusive" Conflicting config options (e.g. build and buildRef) Use only one of the mutually exclusive options
"manifest is required" Resource missing manifest definition Add manifest to resource in task config

Steps:

  1. Check pod logs for the specific validation error
  2. Pull the ConfigMap content and validate locally
  3. Use the adapter's dry-run mode to test config changes before deploying:
    ./adapter serve --config adapter-config.yaml --task-config task-config.yaml --dry-run-event event.json

Event Processing Failures

Symptoms: hyperfleet_adapter_events_processed_total{status="failed"} is increasing. Events are not being processed successfully.

All event failures are ACKed (not retried) to avoid infinite loops on non-transient errors.

Log Pattern Phase Cause Resolution
"Failed to parse event data" Params Malformed CloudEvent payload Check upstream event producer
"failed to extract required parameter" Params Missing field in event data Verify event schema matches task config params
"Precondition[...] evaluated: FAILED" Preconditions API precondition check returned failure Check HyperFleet API state for the resource
"Precondition[...] evaluated: NOT_MET" Preconditions Condition not satisfied (expected) Normal flow — event skipped
"failed to render manifest" Resources Template rendering error Fix Go template syntax in task config
"failed to apply resource" Resources Transport client error See Kubernetes Client Failures or Remote Transport Failures
"PostAction[...] processed: FAILED" Post Actions Status report API call failed Check HyperFleet API connectivity

Steps:

  1. Check error metrics: rate(hyperfleet_adapter_errors_total[5m])
  2. Identify the failing phase from error_type label
  3. Check pod logs for the specific event ID and error details
  4. For persistent failures, use dry-run to reproduce:
    ./adapter serve --config adapter-config.yaml --task-config task-config.yaml --dry-run-event failing-event.json

HyperFleet API Failures

Symptoms: Post-action status updates fail. hyperfleet_adapter_errors_total{error_type="post_actions"} is increasing.

Log Pattern Cause Resolution
"HyperFleet API request returned retryable status" API returning 5xx, 408, or 429 Check HyperFleet API health
"API request failed: ... after N attempt(s)" All retries exhausted API may be down or overloaded
"context canceled" Request timed out Increase spec.clients.hyperfleetApi.timeout or check API latency

The adapter retries on 5xx, 408 (Request Timeout), and 429 (Too Many Requests) with configurable backoff (exponential, linear, or constant).

API Authentication and Authorization Failures

Symptoms: hyperfleet_adapter_api_auth_failures_total{status_code=~"401|403"} is increasing. Error logs include http_status and either phase (parameter extraction or preconditions) or post_action, with the affected resource context.

HTTP 401 and 403 failures are ACKed under the normal event-failure policy; they are not redelivered automatically. Redelivery cannot repair invalid credentials, subject allowlists, or tenant dimensions.

Remediation: For HTTP 403 responses with tenant enforcement enabled, verify the gateway-injected tenant dimensions before changing the projected service-account token or subject allowlist. If they are correct, check the token and allowlist. Once credentials are fixed, the HyperFleet operator will reconcile the affected resources; no redelivery is needed.

Steps:

  1. With tenant enforcement enabled, verify gateway-injected tenant dimensions match the adapter's tenant.
  2. Check HyperFleet API health: kubectl get pods -l app=hyperfleet-api
  3. Check API response times from the adapter pod:
    kubectl exec <pod> -- curl -s -o /dev/null -w "%{http_code} %{time_total}s" http://hyperfleet-api:8000/healthz
  4. Check for resource exhaustion on the API service
  5. Review retryAttempts and timeout in adapter config

Kubernetes Client Failures

Symptoms: Resource apply phase fails for Kubernetes transport tasks.

Log Pattern Cause Resolution
"failed to create kubernetes client" RBAC or kubeconfig issues Check ServiceAccount and RBAC permissions
K8sOperationError{Operation:"create",...} Resource creation failed Check RBAC, resource quotas, namespace existence
K8sOperationError{Operation:"update",...} Conflict on update Usually transient; retried automatically
"context canceled while waiting for resource deletion" Recreate timed out waiting for deletion Resource may have finalizers preventing deletion

Retryable K8s errors (automatically retried): timeouts, server unavailable, internal errors, rate limiting, network errors (connection refused, connection reset). Non-retryable: forbidden, unauthorized, bad request, invalid, gone, method not supported, not acceptable.

Steps:

  1. Check RBAC: kubectl auth can-i --as=system:serviceaccount:<ns>:<sa> create <resource>
  2. Check resource quotas: kubectl describe resourcequota -n <namespace>
  3. Check for finalizers blocking deletion: kubectl get <resource> -o yaml | grep finalizers

Remote Transport Failures

Symptoms: The adapter fails to start with a store or transport error, or the resources phase fails or stays pending for resources on a type: remote transport.

Log Pattern Cause Resolution
"ping Redis" in the "failed to create transport registry" error The adapter cannot reach the Redis store at startup Check that the store is running and reachable from the adapter pod
"url is invalid for redis store" or "redis URL is invalid" The store url is not a valid Redis URL Fix stores.<name>.url, or HYPERFLEET_STORES_<NAME>_URL when the URL comes from the environment
"url must use rediss:// when credentials are configured" The store URL carries credentials over plain redis:// Use a rediss:// URL
"references unknown store" A remote transport names a store that is not declared under stores Declare the store, or fix the transport's store
"target_cluster is required for remote transport" A remote transport has no target_cluster Set transports.<name>.target_cluster
"must be a Kubernetes DNS-1123 label" target_cluster is, or renders to, a value that is not a DNS-1123 label. A literal value fails when the config loads; a template fails on the event that renders it Fix the literal value, or the param the template uses
"has no resource_plurals mapping" The transport's resource_plurals has no entry for the manifest's apiVersion/Kind Add "<apiVersion>/<Kind>": <plural> to the transport's resource_plurals
"failed to create the apply request for" or "failed to update the apply request for" The store rejected or failed the apply write; the wrapped error gives the reason When the store is unreachable, check it from the adapter pod
"ApplyResource: delete pending, retrying on next event" The store refused a new apply while a delete request for the same resource is still active. The executor skips the apply for this event and records the resource as unsynced If it persists across events, check that an applier for the rendered target_cluster reads the same store
"resource_id is required by the store API" An api store refuses a create because the event data has no id Check that Sentinel's messageData maps id (its default maps id: resource.id)
"store API returned HTTP 401" or "store API returned HTTP 403" The gateway or the store API rejected the token or the caller Check that adapterConfig.desireStore.auth mounts a token with the hyperfleet-desire-store audience, that token_scheme matches what the gateway expects, and that the adapter's service account is allowed to call the store API
"store API request failed: tls: failed to verify certificate" The adapter does not trust the gateway's certificate, or the certificate does not name the url host. For certificate signed by unknown authority, set stores.<name>.ca_file to the gateway CA bundle. After the bundle changes, restart the adapter with kubectl rollout restart, because it reads the file at startup. For certificate is valid for, set the url host to a name in the gateway certificate
"store API returned HTTP 400 HYPERFLEET-VAL-005 desire-id" The store API rejected the object name in the request path Check the manifest's name. A store API on an applier older than 155664c rejects names with colons, uppercase letters or underscores
"owner conflict" on an api store A different service account owns desires for the same object, for example after a service-account or namespace rename Use the original service account. Only that account can delete the old owner's desires: the store API rejects a delete by another caller with the same conflict
"store API returned HTTP 404 HYPERFLEET-NTF-000", or "store API returned HTTP 404" without a code The request path matches no store API route. The store API answers an unknown route with HYPERFLEET-NTF-000; a gateway in front of it may answer without a body Fix stores.<name>.url. Any path in it is a prefix of /api/hyperfleet/desire-store/v1/...
"token file" or "read token file" with "enable adapterConfig.desireStore.auth or set stores.<name>.token_path" in the "failed to create transport registry" error The adapter cannot read the projected token for an api store at startup Enable adapterConfig.desireStore.auth, or set token_path to the mounted token
"resource delete: waiting for transport confirmation" The adapter wrote a delete request and the applier has not confirmed the deletion yet. The executor records the reason deletion pending and checks again on the next event If it persists across events, check that an applier for the rendered target_cluster reads the same store

Steps:

  1. Check that the store is reachable from the adapter pod.
  2. Check that an applier for the rendered target_cluster reads the same store.
  3. Review the Remote transport prerequisites.

Tracing / OpenTelemetry Issues

Symptoms: OTLP export errors in logs at startup or during event processing. Traces not appearing in the collector.

Log Pattern Cause Resolution
"failed to create OTLP exporter" Invalid endpoint or protocol Verify OTEL_EXPORTER_OTLP_ENDPOINT is reachable and OTEL_EXPORTER_OTLP_PROTOCOL is grpc or http/protobuf
"failed to export spans" Collector is down or unreachable Check OTLP collector health; verify network connectivity from the pod
"context deadline exceeded" on spans Slow or overloaded collector Check collector resource usage; consider increasing export timeout
Traces going to stdout unexpectedly No OTLP endpoint configured Set OTEL_EXPORTER_OTLP_ENDPOINT to point to your collector

Default mismatch: The binary defaults to tracing enabled (HYPERFLEET_TRACING_ENABLED=true), but the Helm chart defaults to tracing disabled. Running adapter serve locally without setting HYPERFLEET_TRACING_ENABLED=false will attempt OTLP export (falling back to stdout if no endpoint is set).

Steps:

  1. Check if tracing is enabled: look for "tracing enabled" in startup logs
  2. To disable tracing entirely: HYPERFLEET_TRACING_ENABLED=false
  3. Verify collector connectivity:
    kubectl exec <pod> -- curl -s http://otel-collector:4317
  4. Check Helm values: monitoring.tracing.enabled, monitoring.tracing.otlpEndpoint, monitoring.tracing.otlpProtocol

Recovery Procedures

Restart the Adapter

kubectl rollout restart deployment/<release>-hyperfleet-adapter -n <namespace>

Force Reprocess a Failed Event

Events are ACKed on failure and not automatically retried. To reprocess:

  1. Identify the failed event from logs (look for event_id)

  2. Republish the event to the broker topic. The event payload must conform to the async API contract.

    For Google Pub/Sub:

    gcloud pubsub topics publish <topic> --message '<event-json>'

    For RabbitMQ (the adapter's queue binding uses an empty routing key, so publish with routing_key=""):

    rabbitmqadmin publish exchange=<exchange> routing_key="" payload='<event-json>'
  3. Monitor hyperfleet_adapter_events_processed_total for the reprocessed event

Roll Back a Deployment

kubectl rollout undo deployment/<release>-hyperfleet-adapter -n <namespace>

Verify Recovery

# Check pod health
kubectl get pods -l app.kubernetes.io/name=hyperfleet-adapter

# Check readiness
kubectl exec <pod> -- curl -s localhost:8080/readyz | jq .

# Check metrics
kubectl exec <pod> -- curl -s localhost:9090/metrics | grep hyperfleet_adapter_up

# Verify events are being processed (confirms the adapter is doing work, not just alive).
# If the counter is not incrementing, confirm there are messages in the broker
# before concluding the adapter is stuck.
kubectl exec <pod> -- curl -s localhost:9090/metrics | grep hyperfleet_adapter_events_processed_total

Escalation Paths

Severity Condition Action
P1 - Critical Adapter down across all replicas; no events processing Page on-call SRE. Check broker and API dependencies.
P2 - High High failure rate (>10% events failing for 15+ min) Notify team. Investigate error_type in metrics.
P3 - Medium Single replica crash-looping; other replicas healthy Investigate logs. This may be a config or resource issue.
P4 - Low Intermittent errors, auto-recovering Monitor. Create ticket if pattern persists.

Escalation contacts

Level Team When
L1 On-call SRE Initial triage, restart, basic recovery
L2 HyperFleet Adapter team Config issues, event processing logic, transport client failures
L3 HyperFleet Platform team Broker infrastructure, HyperFleet API issues

How to escalate