Skip to main content

Vendor Connectivity runbook

vendor-connectivity is the retail network's Open Host Service for vendors that operate fulfillment nodes: vendors register nodes, declare operational profiles, send inventory feeds, poll purchase orders, acknowledge them in full inside the acknowledgement window, request labels and confirm shipments. Every vendor write is an asynchronous transaction the vendor reconciles via GET /vendor/transactions/{id}. Sources: ADR 0002 (aggregates), 0003 (consumed contracts), 0004 (event catalogue), Runtime (probes, shutdown, outbox) and Configuration (every variable).

Runtime shape​

The chart charts/vendor-connectivity renders up to four components:

ComponentBinaryDefaultRole
apicmd/apialways on (replicaCount: 1, HPA off)Vendor REST API, relay, consumers, loops
mcpcmd/mcpmcp.enabled: falseread-only MCP, port 8090, Kong route /api/mcp/vendor-connectivity when mcp.route.enabled
a2acmd/a2aa2a.enabled: falseread-only A2A agent, port 8093, route /api/a2a/vendor-connectivity when a2a.route.enabled
frontendweb/ nginxfrontend.enabled: falsewarehouse-console remote (ADR 0007)

mcp and a2a run no relay, consumer, loop or Kafka client, so they need only the database and the four neighbour URLs. The rest of this page is about the api Deployment, which runs cmd/api. Inside that process (cmd/api/main.go, background.go, wire_adapters.go):

  • REST Vendor API on :8080 (internal/adapters/inbound/http/server.go): reads and writes under /vendor/*, RATE_LIMIT_RPS limiter, every write behind an Idempotency-Key header (24h replay of a 2xx and of a final refusal; a refusal that can pass on a retry and a 5xx are not stored, ADR 0015).
  • Transactional outbox relay draining outbox_events to Kafka (internal/adapters/outbound/outbox/relay.go).
  • Five Kafka consumers: node (retailnetwork.node-topology.events), listing (retailnetwork.offer-availability.events), sourcing (retailnetwork.order-sourcing.events) — internal/adapters/inbound/kafka/consumers.go — plus inbound shipments (retailnetwork.seller-inbound.events), catalogue packaging and return advices (retailnetwork.customer-returns.events) (retailnetwork.offer-availability.events, second group) — internal/adapters/inbound/kafka/inbound_consumers.go.
  • Three loops: submission processor (due async writes), expiry sweeper (orders past ackBy), 24h retention sweeper (startBackground in cmd/api/background.go).

If the relay, a consumer or a loop returns on its own, the process exits non-zero so the orchestrator restarts it (watchWorkers); it never sits "alive" with a dead worker.

Dependencies​

  • Postgres — DATABASE_URL (pooled DSN, PgBouncer in-cluster) and MIGRATIONS_DATABASE_URL (direct DSN for the boot migrations only: golang-migrate holds a session advisory lock, which breaks behind a transaction-pooling proxy). Both from the Secret vendor-connectivity-db (chart database.existingSecret; the migrations key is optional: true, the binary falls back to DATABASE_URL). Embedded migrations run at boot with backoff (internal/bootretry).
  • Kafka — KAFKA_BROKERS (required): relay sink, the five consumers, /readyz. Topics are auto-created by the first writer (AllowAutoTopicCreation: true, internal/adapters/outbound/kafka/writer.go). Publishes retailnetwork.vendor-connectivity.events (.../outbound/kafka/encoder.go); dead letters go to <topic>.dlq (.../inbound/kafka/deadletter.go).
  • Four sibling REST services (required, no defaults; in-cluster http://<context>.warehouse-systems.svc.cluster.local:80): NODE_TOPOLOGY_URL (node registration, operational profiles), OFFER_AVAILABILITY_URL (inventory feeds), SHIPPING_AND_TRACKING_URL (labels), NODE_PERFORMANCE_URL (scorecards). Adapter: internal/adapters/outbound/httpclient/client.go.

Health​

internal/adapters/inbound/http/readiness.go, wired in cmd/api/wire_adapters.go:

  • GET /healthz — liveness only: 200 {"status":"ok"} while the process serves, even while draining or with every dependency down.
  • GET /readyz — 200 {"status":"ready"} only while the drain gate is open, Postgres answers PING and a Kafka broker answers a topic-less metadata request (probing never creates topics). Verdict cached 3s, one round bounded 2s. Draining: 503 {"status":"not_ready"}. Dependency down: 503 application/problem+json dependency-unavailable naming postgres and/or kafka.

Writes with a dependency down, per code:

  • Postgres down — writes fail: aggregate, idempotency row and outbox rows commit in ONE Postgres transaction, so nothing durable can happen (errors.go falls through to the internal-error problem). /readyz 503 pulls the pod from Kong first.
  • Kafka down — writes are STILL accepted: events are committed to outbox_events and the relay retries every OUTBOX_RELAY_INTERVAL; only /readyz goes 503.

Configuration​

Chart charts/vendor-connectivity — each env var below maps 1:1 to a values.yaml config.* key rendered into the ConfigMap/container env (checksum-annotated so a change rolls the pods); secret keys come from the vendor-connectivity-db Secret.

Env varChart valueDefault / meaning
DATABASE_URLdatabase.existingSecretrequired, pooled Postgres DSN
MIGRATIONS_DATABASE_URLdatabase.migrationsExistingSecretKeyoptional, direct DSN for boot migrations
KAFKA_BROKERSkafka.brokersrequired, comma-separated host:port
NODE_CONSUMER_GROUPconfig.nodeConsumerGrouprequired, stable group id (node-topology)
LISTING_CONSUMER_GROUPconfig.listingConsumerGrouprequired (offer-availability)
SOURCING_CONSUMER_GROUPconfig.sourcingConsumerGrouprequired (order-sourcing)
INBOUND_CONSUMER_GROUPconfig.inboundConsumerGrouprequired (seller-inbound shipments, ADR 0005)
PACKAGING_CONSUMER_GROUPconfig.packagingConsumerGrouprequired (offer-availability packaging, ADR 0005)
NODE_TOPOLOGY_URLconfig.nodeTopologyUrlrequired, sibling base URL
OFFER_AVAILABILITY_URLconfig.offerAvailabilityUrlrequired
SHIPPING_AND_TRACKING_URLconfig.shippingAndTrackingUrlrequired
NODE_PERFORMANCE_URLconfig.nodePerformanceUrlrequired
EVENT_PUBLISHERconfig.eventPublisherkafka only; anything else is a boot error
HTTP_ADDRconfig.httpAddr:8080
LOG_LEVELconfig.logLevelinfo (debug, info, warn, error)
OUTBOX_RELAY_INTERVALconfig.outboxRelayInterval1s
OUTBOX_MAX_ATTEMPTSconfig.outboxMaxAttempts20; 0 = unlimited
SUBMISSION_POLL_INTERVALconfig.submissionPollInterval1s
EXPIRY_SWEEP_INTERVALconfig.expirySweepInterval30s
SHUTDOWN_DRAIN_DELAYconfig.shutdownDrainDelay5s; 0 disables
TX_PROCESSING_DELAYconfig.txProcessingDelay0 — fault-injection knob
TX_FAILURE_RATEconfig.txFailureRate0 — fault-injection knob
PO_REDELIVERY_RATEconfig.poRedeliveryRate0 — fault-injection knob
RATE_LIMIT_RPSconfig.rateLimitRps0 = unlimited over /vendor/*

Honest note: TX_PROCESSING_DELAY (submissions stay PROCESSING at least this long), TX_FAILURE_RATE (share of submissions that fail ON PURPOSE with ErrSimulatedFailure) and PO_REDELIVERY_RATE (chance a poll page repeats its first order) are simulation knobs so a vendor integration can exercise a hostile network (internal/application/usecases/service.go, submissions.go). They inject failures; they are not operational tuning — keep them unset in normal operation.

Alerts and dashboards​

  • Grafana dashboard: uid warehouse-vendor-connectivity (fleet convention, configmap grafana-dashboards-warehouse in namespace observability).
  • Pod-restart alerting covers every pod in warehouse-systems (WarehousePodRestarting on kube_pod_container_status_restarts_total, warehouse-infra terraform/alerting/warehouse-alert-rules.json).
  • Logs are JSON on stdout; Alloy maps the pod label app.kubernetes.io/name to the Loki label app, so query Loki with {namespace="warehouse-systems", app="vendor-connectivity"}.
  • One business metric is instrumented, the counter vendor.submissions.processed (see Observability). There is no outbox-depth, consumer-lag or per-route instrument of this service's own, and the repository ships no alert rule on any of them: alerting today sees pod restarts only. Check the dashboard in warehouse-infra before relying on any other panel.

Failure modes​

  • Pod crash-loops. Diagnosis: kubectl -n warehouse-systems logs deploy/vendor-connectivity — a missing/invalid env var is a boot error naming the variable; migrations and the first ping retry with backoff before the process gives up. The pod also restarts by design when the relay, a consumer or a loop dies (watchWorkers). Action: fix the ConfigMap/Secret (or the dependency), then rollout restart.
  • Postgres unreachable. Symptom: /readyz 503 naming postgres; loops log loop pass failed and retry next tick; REST writes fail (see Health). Action: check PgBouncer and the vendor-connectivity-db Secret; recovery is automatic.
  • Kafka unreachable. Symptom: /readyz 503 naming kafka; REST writes are STILL accepted and queue in outbox_events (published_at IS NULL); the relay retries each pass. Action: restore brokers; the backlog drains itself — watch the oldest unpublished row age (see next item) while it does.
  • Outbox relay stuck / a row parked at the attempt cap. A row whose attempts reached OUTBOX_MAX_ATTEMPTS (default 20) is EXCLUDED from future claims (AND attempts < $2 in internal/adapters/outbound/postgres/outbox_repository.go) and stays in outbox_events with attempts/last_error for inspection; the relay logs outbox relay: row reached the attempt cap and is excluded from future claims; re-arm it with attempts = 0 after fixing the cause once at ERROR (relay.go, AttemptCapReachedMsg). Later rows are NOT blocked (head-of-line safe). Re-arm after fixing the cause: UPDATE outbox_events SET attempts = 0 WHERE id = <id>;
  • Consumer lag or retry logs. The three consumed topics belong to their producers; if a producer has not written yet, its topic does not exist (topics are auto-created by the first writer) and the consumer only logs reader retries — benign. A transient handler failure retries the SAME message with capped exponential backoff (200ms doubling, cap 5s) up to 5 attempts, then dead-letters it to <topic>.dlq; a payload that can never be applied is dead-lettered at once (internal/adapters/inbound/kafka/kafka.go, deadletter.go). Effects are idempotent on the CloudEvents id (processed_events), so replaying a .dlq topic re-applies safely only if the original was never committed — inspect processed_events first.
  • A sibling REST URL unreachable. The adapter maps an outage/timeout/5xx to ports.ErrUpstreamUnavailable (httpclient/client.go). Asynchronous vendor writes that need that sibling (node registration, profiles -> node-topology; inventory -> offer-availability) DEGRADE, not fail at once: the submission stays PROCESSING and is retried on later passes, up to 5 passes (DefaultSubmissionMaxAttempts), after which it fails with ErrUpstreamUnavailable (process and classify in usecases/submissions.go). A 4xx the callee RELEASES under its Idempotency-Key (replay class RETRYABLE: for example node-topology unknown-region, offer-availability listing-not-on-node) is treated the same way, and the submission records why in submissions.last_refusal_code|message|path; at the 5th pass it fails with that refusal's own Err... code (table per callee in httpclient/refusal_classes.go, ADR 0016). The synchronous endpoints answer 503 upstream-unavailable (errors.go): POST /vendor/shipping-labels (shipping-and-tracking) and GET /vendor/nodes/{id}/scorecard (node-performance). Consumers and the REST API itself are unaffected.

Operational actions​

kubectl -n warehouse-systems rollout restart deploy/vendor-connectivity
kubectl -n warehouse-systems logs deploy/vendor-connectivity --follow

Logs in Grafana Loki: {namespace="warehouse-systems", app="vendor-connectivity"} (JSON lines; level, loop, consumer, error fields). Restarts are graceful: /readyz flips to 503, SHUTDOWN_DRAIN_DELAY (5s) waits, HTTP drains (10s), then consumers/loops stop, the relay LAST (so nothing committed is stranded); the chart's terminationGracePeriodSeconds must stay above drain delay + 30s. Any config.* value change rolls the pods automatically (ConfigMap checksum annotation).