-
Notifications
You must be signed in to change notification settings - Fork 43
SANDBOX-1561 | feature: Makefile targets to build the operator in debug mode #720
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SANDBOX-1561 | feature: Makefile targets to build the operator in debug mode #720
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: MikelAlejoBR The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
WalkthroughAdds Delve-based debugging: two debug Dockerfiles, a build target producing non-optimized debug binaries, entrypoint logic to launch the operator under Delve when enabled, and Make targets to build/push debug images (debugger exposed on port 50000). Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Dev as Developer
participant Container as Container / Entrypoint
participant Delve as Delve (dlv)
participant Operator as member-operator
Dev->>Container: start container (ENV: DEBUG_MODE set or unset)
alt DEBUG_MODE set
Container->>Delve: exec dlv --headless --listen=:50000 --accept-multiclient --api-version=2 -- ./member-operator +args
Delve->>Operator: spawn operator (debug-friendly build)
else DEBUG_MODE empty
Container->>Operator: exec ./member-operator +args
end
Note over Delve,Operator: Port 50000 exposed for debugger connection
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks✅ Passed checks (3 passed)
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (2)
🧰 Additional context used🧠 Learnings (2)📓 Common learnings📚 Learning: 2026-01-02T20:13:02.289ZApplied to files:
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
🧹 Nitpick comments (1)
make/podman.mk (1)
15-19: Consider more robust Go version extraction.The current approach uses
go version | awk '{print $$3}'to extract the Go version. While this works for the standard output format, it's fragile and lacks error handling.🔎 More robust version extraction
-podman-image-debug: build-debug - $(Q) podman build --platform ${IMAGE_PLATFORM} --build-arg GOLANG_VERSION="$$(go version | awk '{print $$3}')" --file build/Dockerfile.debug --tag ${IMAGE} . - $(Q) podman build --platform ${IMAGE_PLATFORM} --build-arg GOLANG_VERSION="$$(go version | awk '{print $$3}')" --file build/Dockerfile.webhook.debug --tag ${WEBHOOK_IMAGE} . +GOLANG_VERSION := $(shell go version | awk '{print $$3}' || echo "go1.21.0") + +podman-image-debug: build-debug + $(Q) podman build --platform ${IMAGE_PLATFORM} --build-arg GOLANG_VERSION="${GOLANG_VERSION}" --file build/Dockerfile.debug --tag ${IMAGE} . + $(Q) podman build --platform ${IMAGE_PLATFORM} --build-arg GOLANG_VERSION="${GOLANG_VERSION}" --file build/Dockerfile.webhook.debug --tag ${WEBHOOK_IMAGE} .This approach:
- Extracts the version once and reuses it
- Provides a fallback if the command fails
- Makes the version visible and easier to override if needed
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
build/Dockerfile.debugbuild/Dockerfile.webhook.debugbuild/bin/entrypointmake/go.mkmake/podman.mk
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build & push operator bundles & dashboard image for e2e tests
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #720 +/- ##
=======================================
Coverage 63.12% 63.12%
=======================================
Files 48 48
Lines 3604 3604
=======================================
Hits 2275 2275
Misses 1181 1181
Partials 148 148 🚀 New features to boost your workflow:
|
22c9fee to
917e1b2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
♻️ Duplicate comments (2)
build/Dockerfile.debug (1)
24-25: Pin the Delve version for reproducibility.This concern was raised in a previous review. Using
@latestmakes builds non-reproducible.build/Dockerfile.webhook.debug (1)
24-25: Pin the Delve version for reproducibility.This concern was raised in a previous review. Use the same pinned version as
build/Dockerfile.debugfor consistency.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
build/Dockerfile.debugbuild/Dockerfile.webhook.debugbuild/bin/entrypointmake/go.mkmake/podman.mk
🚧 Files skipped from review as they are similar to previous changes (3)
- build/bin/entrypoint
- make/go.mk
- make/podman.mk
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Build & push operator bundles & dashboard image for e2e tests
🔇 Additional comments (2)
build/Dockerfile.debug (1)
27-55: Final stage looks good.The multi-stage build correctly:
- Uses ubi-minimal for a smaller image
- Sets up a non-root user (UID 1001)
- Copies only the necessary artifacts (operator binary, Delve, entrypoint scripts)
- Exposes the debug port 50000
build/Dockerfile.webhook.debug (1)
27-55: Final stage is properly configured for webhook debugging.The configuration mirrors
build/Dockerfile.debugappropriately, with webhook-specific paths (member-operator-webhookbinary and user).
917e1b2 to
fc412ad
Compare
In order to be able to debug the operator live in the local cluster, we need the binary to be executed with Delve instead, and we need it to be built without any code optimizations or minimization so that the breakpoints work. For that purpose, new Dockerfiles are added which can build the images that way, and the corresponding Make targets make it easy to kick off the whole process with a single command. The Makefile targets also enable the "toolchain-e2e" repository to easily build the "debug" images. SANDBOX-1561
7952b4c to
cde5155
Compare
xcoulon
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
Sorry if I'm late in the game, but how can we enable/switch to the debug build?
Also, do we need an extra service and route to connect to the debug port?
|
No worries at all 😄 These changes enable deploying this, the host operator and the registration service with debuggers listening by issuing a You can also individually build and push every operator with the
In principle I have been playing with the |
Nice!
Ah, I assume this works with OpenShift Local, but probably not with a temp cluster on AWS? 🤔 |
I only had local development in mind, but surely I think we can make it work in a temp cluster too. In fact in the beginning I was creating services for everything but I ended up discarding that because I thought that they weren't needed for local dev... I might present this thing first and if everybody likes it and wants to go forward I can go ahead and extend it for temp clusters too, if that sounds okay! |
looks good, let's focus on OpenShift Local for now ;) |
|
|
Closing in favor of #721. |




In order to be able to debug the operator live in the local cluster, we need the binary to be executed with Delve instead, and we need it to be built without any code optimizations or minimization so that the breakpoints work.
For that purpose, new Dockerfiles are added which can build the images that way, and the corresponding Make targets make it easy to kick off the whole process with a single command.
The Makefile targets also enable the "toolchain-e2e" repository to easily build the "debug" images.
Related PRs
Jira ticket
[SANDBOX-1561]
Summary by CodeRabbit
New Features
Chores
✏️ Tip: You can customize this high-level summary in your review settings.