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:
| Component | Binary | Default | Role |
|---|---|---|---|
api | cmd/api | always on (replicaCount: 1, HPA off) | Vendor REST API, relay, consumers, loops |
mcp | cmd/mcp | mcp.enabled: false | read-only MCP, port 8090, Kong route /api/mcp/vendor-connectivity when mcp.route.enabled |
a2a | cmd/a2a | a2a.enabled: false | read-only A2A agent, port 8093, route /api/a2a/vendor-connectivity when a2a.route.enabled |
frontend | web/ nginx | frontend.enabled: false | warehouse-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_RPSlimiter, every write behind anIdempotency-Keyheader (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_eventsto 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 (startBackgroundincmd/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) andMIGRATIONS_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 Secretvendor-connectivity-db(chartdatabase.existingSecret; the migrations key isoptional: true, the binary falls back toDATABASE_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). Publishesretailnetwork.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 answersPINGand 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+jsondependency-unavailablenamingpostgresand/orkafka.
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.gofalls through to the internal-error problem)./readyz503 pulls the pod from Kong first. - Kafka down — writes are STILL accepted: events are committed to
outbox_eventsand the relay retries everyOUTBOX_RELAY_INTERVAL; only/readyzgoes 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 var | Chart value | Default / meaning |
|---|---|---|
DATABASE_URL | database.existingSecret | required, pooled Postgres DSN |
MIGRATIONS_DATABASE_URL | database.migrationsExistingSecretKey | optional, direct DSN for boot migrations |
KAFKA_BROKERS | kafka.brokers | required, comma-separated host:port |
NODE_CONSUMER_GROUP | config.nodeConsumerGroup | required, stable group id (node-topology) |
LISTING_CONSUMER_GROUP | config.listingConsumerGroup | required (offer-availability) |
SOURCING_CONSUMER_GROUP | config.sourcingConsumerGroup | required (order-sourcing) |
INBOUND_CONSUMER_GROUP | config.inboundConsumerGroup | required (seller-inbound shipments, ADR 0005) |
PACKAGING_CONSUMER_GROUP | config.packagingConsumerGroup | required (offer-availability packaging, ADR 0005) |
NODE_TOPOLOGY_URL | config.nodeTopologyUrl | required, sibling base URL |
OFFER_AVAILABILITY_URL | config.offerAvailabilityUrl | required |
SHIPPING_AND_TRACKING_URL | config.shippingAndTrackingUrl | required |
NODE_PERFORMANCE_URL | config.nodePerformanceUrl | required |
EVENT_PUBLISHER | config.eventPublisher | kafka only; anything else is a boot error |
HTTP_ADDR | config.httpAddr | :8080 |
LOG_LEVEL | config.logLevel | info (debug, info, warn, error) |
OUTBOX_RELAY_INTERVAL | config.outboxRelayInterval | 1s |
OUTBOX_MAX_ATTEMPTS | config.outboxMaxAttempts | 20; 0 = unlimited |
SUBMISSION_POLL_INTERVAL | config.submissionPollInterval | 1s |
EXPIRY_SWEEP_INTERVAL | config.expirySweepInterval | 30s |
SHUTDOWN_DRAIN_DELAY | config.shutdownDrainDelay | 5s; 0 disables |
TX_PROCESSING_DELAY | config.txProcessingDelay | 0 — fault-injection knob |
TX_FAILURE_RATE | config.txFailureRate | 0 — fault-injection knob |
PO_REDELIVERY_RATE | config.poRedeliveryRate | 0 — fault-injection knob |
RATE_LIMIT_RPS | config.rateLimitRps | 0 = 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, configmapgrafana-dashboards-warehousein namespaceobservability). - Pod-restart alerting covers every pod in
warehouse-systems(WarehousePodRestartingonkube_pod_container_status_restarts_total, warehouse-infraterraform/alerting/warehouse-alert-rules.json). - Logs are JSON on stdout; Alloy maps the pod label
app.kubernetes.io/nameto the Loki labelapp, 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), thenrollout restart. - Postgres unreachable. Symptom:
/readyz503 namingpostgres; loops logloop pass failedand retry next tick; REST writes fail (see Health). Action: check PgBouncer and thevendor-connectivity-dbSecret; recovery is automatic. - Kafka unreachable. Symptom:
/readyz503 namingkafka; REST writes are STILL accepted and queue inoutbox_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
attemptsreachedOUTBOX_MAX_ATTEMPTS(default 20) is EXCLUDED from future claims (AND attempts < $2ininternal/adapters/outbound/postgres/outbox_repository.go) and stays inoutbox_eventswithattempts/last_errorfor inspection; the relay logsoutbox relay: row reached the attempt cap and is excluded from future claims; re-arm it with attempts = 0 after fixing the causeonce 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.dlqtopic re-applies safely only if the original was never committed — inspectprocessed_eventsfirst. - 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 staysPROCESSINGand is retried on later passes, up to 5 passes (DefaultSubmissionMaxAttempts), after which it fails withErrUpstreamUnavailable(processandclassifyinusecases/submissions.go). A 4xx the callee RELEASES under itsIdempotency-Key(replay class RETRYABLE: for example node-topologyunknown-region, offer-availabilitylisting-not-on-node) is treated the same way, and the submission records why insubmissions.last_refusal_code|message|path; at the 5th pass it fails with that refusal's ownErr...code (table per callee inhttpclient/refusal_classes.go, ADR 0016). The synchronous endpoints answer503 upstream-unavailable(errors.go):POST /vendor/shipping-labels(shipping-and-tracking) andGET /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).