Skip to content

Commit 49c4393

Browse files
authored
chore(stovepipe): set up dlv debugging setup in container (#307)
## Why? Provide a configuration to get breakpoint debugging working locally ## What? Adjust Makefile with an additional `local-stovepipe-debug-start`. This builds a debug binary and starts it inside a container with dlv. Includes a .vscode/launch.json configuration to attach to it. ## Test Plan ``` % make local-stovepipe-debug-start Building Stovepipe Linux debug binary for Docker... INFO: Invocation ID: bbd58a95-06b5-4cd7-9e57-dc5395bff6ab INFO: Analyzed target //service/stovepipe/server:stovepipe (0 packages loaded, 0 targets configured). INFO: Found 1 target... Target //service/stovepipe/server:stovepipe up-to-date: bazel-bin/service/stovepipe/server/stovepipe_/stovepipe INFO: Elapsed time: 0.201s, Critical Path: 0.00s INFO: 1 process: 1 action cache hit, 1 internal. INFO: Build completed successfully, 1 total action Stovepipe Linux debug binary ready at .docker-bin/stovepipe-debug Starting Stovepipe service with compose (debug)... [+] Building 0.9s (15/15) FINISHED => [internal] load local bake definitions 0.0s => => reading from stdin 576B 0.0s => [internal] load build definition from Dockerfile.debug 0.0s => => transferring dockerfile: 665B 0.0s => [internal] load metadata for docker.io/library/debian:bookworm-slim 0.0s => [internal] load metadata for docker.io/library/golang:1.24-bookworm 0.3s => [internal] load .dockerignore 0.0s => => transferring context: 2B 0.0s => [dlv 1/2] FROM docker.io/library/golang:1.24-bookworm@sha256:1a6d4452c65dea36aac2e2d606b01b4a029ec90cc1ae53890 0.0s => [stage-1 1/5] FROM docker.io/library/debian:bookworm-slim 0.0s => [internal] load build context 0.2s => => transferring context: 21.20MB 0.2s => CACHED [stage-1 2/5] RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/* 0.0s => CACHED [dlv 2/2] RUN go install github.com/go-delve/delve/cmd/dlv@v1.24.2 0.0s => CACHED [stage-1 3/5] COPY --from=dlv /go/bin/dlv /usr/local/bin/dlv 0.0s => CACHED [stage-1 4/5] WORKDIR /root/ 0.0s => CACHED [stage-1 5/5] COPY .docker-bin/stovepipe-debug ./stovepipe 0.0s => exporting to image 0.0s => => exporting layers 0.0s => => writing image sha256:a44246269b1d261c3abd7cde3c10922933786c3df65d9ab52edbac4c221627f5 0.0s => => naming to docker.io/library/stovepipe-stovepipe-service 0.0s => resolving provenance for metadata file 0.0s WARN[0001] Found orphan containers ([stovepipe-gateway-service-1 stovepipe-orchestrator-service-1]) for this project. Ifyou removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. [+] Running 4/4 ✔ stovepipe-stovepipe-service Built 0.0s ✔ Container stovepipe-mysql-app-1 Healthy 1.0s ✔ Container stovepipe-mysql-queue-1 Healthy 1.0s ✔ Container stovepipe-stovepipe-service-1 Healthy 1.0s Applying storage and queue schemas... Applying storage schema to mysql-app... - Applying request.sql... - Applying request_uri.sql... Applying queue schema to mysql-queue... - Applying queue_delivery_state.sql... - Applying queue_messages.sql... - Applying queue_offsets.sql... - Applying queue_partition_leases.sql... - Applying queue_subscriber_heartbeats.sql... ✅ Stovepipe schemas applied successfully ✅ Stovepipe debug is running (delve :2345)! NAME IMAGE COMMAND SERVICE CREATED STATUS PORTS stovepipe-mysql-app-1 mysql:8.0 "docker-entrypoint.s…" mysql-app 14 minutes ago Up 14 minutes (healthy) 33060/tcp, 0.0.0.0:32777->3306/tcp, [::]:32777->3306/tcp stovepipe-mysql-queue-1 mysql:8.0 "docker-entrypoint.s…" mysql-queue 14 minutes ago Up 14 minutes (healthy) 33060/tcp, 0.0.0.0:32778->3306/tcp, [::]:32778->3306/tcp stovepipe-stovepipe-service-1 stovepipe-stovepipe-service "dlv exec ./stovepip…" stovepipe-service 41 minutes ago Up 41 minutes 0.0.0.0:2345->2345/tcp, [::]:2345->2345/tcp, 0.0.0.0:32776->8080/tcp, [::]:32776->8080/tcp Stovepipe gRPC port: 32776 Delve: 127.0.0.1:2345 — run launch config "Debug: attach (dlv in docker)" ``` - Send a request (e.g. ` grpcurl -plaintext -d '{"queue":"monorepo/main"}' localhost:32776 uber.submitqueue.stovepipe.Stovepipe/Ingest` and ensure the service stops at a breakpoint
1 parent 19a9535 commit 49c4393

6 files changed

Lines changed: 77 additions & 3 deletions

File tree

‎.gitignore‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
/bazel-*
33
MODULE.bazel.lock
44
/pkg/**
5-
.vscode/
5+
.vscode/*
6+
!.vscode/launch.json
67
.idea/
78
.claude/
89
.mcp.json

‎.vscode/launch.json‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Debug: attach (dlv in docker)",
6+
"type": "go",
7+
"request": "attach",
8+
"mode": "remote",
9+
"cwd": "${workspaceFolder}",
10+
"host": "127.0.0.1",
11+
"port": 2345,
12+
"showLog": true
13+
}
14+
]
15+
}

‎Makefile‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ SUBMITQUEUE_LOCAL_PROJECT = submitqueue
1414

1515
# Stovepipe compose file (single Ping-only service)
1616
STOVEPIPE_COMPOSE_FILE = service/stovepipe/docker-compose.yml
17+
STOVEPIPE_DEBUG_COMPOSE_FILE = service/stovepipe/docker-compose.debug.yml
1718

1819
# Fixed project name for local manual testing (tests use unique random names)
1920
STOVEPIPE_LOCAL_PROJECT = stovepipe
@@ -51,7 +52,7 @@ define assert_clean
5152
fi
5253
endef
5354

54-
.PHONY: build build-all-linux build-runway-linux build-submitqueue-gateway-linux build-submitqueue-orchestrator-linux build-stovepipe-linux check-gazelle check-mocks check-tidy clean clean-proto deps e2e-test fmt gazelle integration-test integration-test-submitqueue-consumer integration-test-extensions integration-test-submitqueue-gateway integration-test-submitqueue-orchestrator license-fix lint lint-fmt lint-license local-init-runway-queue-schema local-init-stovepipe-schemas local-runway-start local-runway-stop local-submitqueue-clean local-submitqueue-gateway-start local-submitqueue-gateway-stop local-init-submitqueue-schemas local-submitqueue-logs local-submitqueue-orchestrator-start local-submitqueue-orchestrator-stop local-submitqueue-ps local-submitqueue-restart local-submitqueue-start local-stop local-stovepipe-logs local-stovepipe-start local-stovepipe-stop mocks proto query-deps query-targets run-client-runway run-client-submitqueue-gateway run-client-submitqueue-orchestrator run-client-stovepipe run-queue-admin test test-no-cache tidy tidy-bazel tidy-go help
55+
.PHONY: build build-all-linux build-runway-linux build-submitqueue-gateway-linux build-submitqueue-orchestrator-linux build-stovepipe-linux build-stovepipe-linux-debug check-gazelle check-mocks check-tidy clean clean-proto deps e2e-test fmt gazelle integration-test integration-test-submitqueue-consumer integration-test-extensions integration-test-submitqueue-gateway integration-test-submitqueue-orchestrator license-fix lint lint-fmt lint-license local-init-runway-queue-schema local-init-stovepipe-schemas local-runway-start local-runway-stop local-submitqueue-clean local-submitqueue-gateway-start local-submitqueue-gateway-stop local-init-submitqueue-schemas local-submitqueue-logs local-submitqueue-orchestrator-start local-submitqueue-orchestrator-stop local-submitqueue-ps local-submitqueue-restart local-submitqueue-start local-stop local-stovepipe-debug-start local-stovepipe-logs local-stovepipe-start local-stovepipe-stop mocks proto query-deps query-targets run-client-runway run-client-submitqueue-gateway run-client-submitqueue-orchestrator run-client-stovepipe run-queue-admin test test-no-cache tidy tidy-bazel tidy-go help
5556

5657

5758
build: ## Build all services and examples
@@ -95,6 +96,14 @@ build-stovepipe-linux: ## Build Stovepipe Linux binary for Docker
9596
cp -f bazel-bin/service/stovepipe/server/stovepipe .docker-bin/stovepipe
9697
@echo "Stovepipe Linux binary ready at .docker-bin/stovepipe"
9798

99+
build-stovepipe-linux-debug: ## Build Stovepipe Linux debug binary for Docker/delve (symbols, no optimizations)
100+
@echo "Building Stovepipe Linux debug binary for Docker..."
101+
@$(BAZEL) build --compilation_mode=dbg --platforms=@rules_go//go/toolchain:linux_amd64 //service/stovepipe/server:stovepipe
102+
@mkdir -p .docker-bin
103+
@cp -f bazel-bin/service/stovepipe/server/stovepipe_/stovepipe .docker-bin/stovepipe-debug 2>/dev/null || \
104+
cp -f bazel-bin/service/stovepipe/server/stovepipe .docker-bin/stovepipe-debug
105+
@echo "Stovepipe Linux debug binary ready at .docker-bin/stovepipe-debug"
106+
98107
check-gazelle: ## Check BUILD.bazel files are up to date
99108
@echo "Running Gazelle to check BUILD files..."
100109
@$(BAZEL) run //:gazelle
@@ -320,6 +329,19 @@ local-stop: ## Stop all services (keep data)
320329
@$(COMPOSE) -f $(RUNWAY_COMPOSE_FILE) -p $(RUNWAY_LOCAL_PROJECT) down
321330
@echo "Services stopped. Data volumes preserved."
322331

332+
local-stovepipe-debug-start: build-stovepipe-linux-debug ## Start Stovepipe under delve in Docker (attach IDE to :2345)
333+
@echo "Starting Stovepipe service with compose (debug)..."
334+
@$(COMPOSE) -f $(STOVEPIPE_COMPOSE_FILE) -f $(STOVEPIPE_DEBUG_COMPOSE_FILE) -p $(STOVEPIPE_LOCAL_PROJECT) up -d --build --wait
335+
@echo "Applying storage and queue schemas..."
336+
@$(MAKE) -s local-init-stovepipe-schemas
337+
@echo ""
338+
@echo "✅ Stovepipe debug is running (delve :2345)!"
339+
@echo ""
340+
@$(COMPOSE) -f $(STOVEPIPE_COMPOSE_FILE) -f $(STOVEPIPE_DEBUG_COMPOSE_FILE) -p $(STOVEPIPE_LOCAL_PROJECT) ps
341+
@echo ""
342+
@echo "Stovepipe gRPC port: $$(docker port $(STOVEPIPE_LOCAL_PROJECT)-stovepipe-service-1 8080 2>/dev/null | cut -d: -f2 || echo 'unknown')"
343+
@echo "Delve: 127.0.0.1:2345 — run launch config \"Debug: attach (dlv in docker)\""
344+
323345
local-stovepipe-logs: ## View logs from the running Stovepipe service
324346
@$(COMPOSE) -f $(STOVEPIPE_COMPOSE_FILE) -p $(STOVEPIPE_LOCAL_PROJECT) logs -f
325347

‎service/stovepipe/README.md‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ make local-stovepipe-logs # follow logs
5252

5353
The compose service key is **`stovepipe-service`**, so under the default project **`stovepipe`** the container is **`stovepipe-stovepipe-service-1`**. Inside the container the server listens on `:8080`, published on a random ephemeral host port.
5454

55+
### Breakpoint debugging (dlv debugger)
56+
57+
```bash
58+
make local-stovepipe-debug-start
59+
```
60+
61+
Attach with `.vscode/launch.json` (**Debug: attach (dlv in docker)**), then send a request using the gRPC port from the make output.
62+
63+
```bash
64+
# Ingest example
65+
grpcurl -plaintext -d '{"queue":"monorepo/main"}' localhost:PORT uber.submitqueue.stovepipe.Stovepipe/Ingest
66+
```
67+
5568
### Bazel / Go
5669

5770
```bash
@@ -75,4 +88,3 @@ grpcurl -plaintext -d '{"message": "hello"}' localhost:8083 uber.submitqueue.sto
7588
## Shutdown
7689

7790
The server handles `SIGINT` / `SIGTERM` gracefully: it drains in-flight RPCs, then stops the process consumer (30s timeout). It exits `0` on clean shutdown, `143` (128 + SIGTERM) when stopped by signal, and `1` on startup/runtime errors (details on stderr). Shutdown errors override the signal exit code.
78-
</content>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Debug override for make local-stovepipe-debug-start — delve on :2345.
2+
services:
3+
stovepipe-service:
4+
build:
5+
dockerfile: service/stovepipe/server/Dockerfile.debug
6+
ports:
7+
- "2345:2345"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Debug image: delve wraps a -compilation_mode=dbg binary (make build-stovepipe-linux-debug).
2+
FROM golang:1.24-bookworm AS dlv
3+
RUN go install github.com/go-delve/delve/cmd/dlv@v1.24.2
4+
5+
FROM debian:bookworm-slim
6+
7+
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*
8+
COPY --from=dlv /go/bin/dlv /usr/local/bin/dlv
9+
WORKDIR /root/
10+
11+
# Copy pre-built Linux debug binary.
12+
# Built via: make build-stovepipe-linux-debug
13+
COPY .docker-bin/stovepipe-debug ./stovepipe
14+
15+
EXPOSE 8080 2345
16+
17+
CMD ["dlv", "exec", "./stovepipe", "--headless", "--listen=:2345", "--api-version=2", "--accept-multiclient"]

0 commit comments

Comments
 (0)