Skip to content

OCPBUGS-83863: Strip debug symbols from Go binaries#92

Open
sdodson wants to merge 1 commit into
openshift:masterfrom
sdodson:strip-go-binaries
Open

OCPBUGS-83863: Strip debug symbols from Go binaries#92
sdodson wants to merge 1 commit into
openshift:masterfrom
sdodson:strip-go-binaries

Conversation

@sdodson
Copy link
Copy Markdown
Member

@sdodson sdodson commented May 25, 2026

Summary

  • Set LDFLAGS = -s -w in Makefile after including release-tools/build.make to strip DWARF debug info and symbol tables

Impact

The csi-livenessprobe image (310 MB) contains one unstripped Go binary:

  • livenessprobe (26.9 MB)

Stripping typically reduces Go binary size by 20-30%, reducing container image pull time during node scale-up.

Test plan

  • Verify image builds successfully
  • Verify binary is stripped
  • Verify livenessprobe functions correctly

Summary by CodeRabbit

  • Chores
    • Optimized build configuration for improved executable efficiency.

Set LDFLAGS to -s -w after including release-tools/build.make to strip
DWARF debug info and symbol tables. This typically reduces binary size
by 20-30%, which reduces container image pull time during node scale-up.

rh-pre-commit.version: 2.4.0
rh-pre-commit.check-secrets: ENABLED
@openshift-ci-robot openshift-ci-robot added jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. labels May 25, 2026
@openshift-ci-robot
Copy link
Copy Markdown

@sdodson: This pull request references Jira Issue OCPBUGS-83863, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target version (5.0.0) matches configured target version for branch (5.0.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, POST)

The bug has been updated to refer to the pull request using the external bug tracker.

Details

In response to this:

Summary

  • Set LDFLAGS = -s -w in Makefile after including release-tools/build.make to strip DWARF debug info and symbol tables

Impact

The csi-livenessprobe image (310 MB) contains one unstripped Go binary:

  • livenessprobe (26.9 MB)

Stripping typically reduces Go binary size by 20-30%, reducing container image pull time during node scale-up.

Test plan

  • Verify image builds successfully
  • Verify binary is stripped
  • Verify livenessprobe functions correctly

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f9f3c2d8-0d49-44e2-affe-8f07b6ed93f8

📥 Commits

Reviewing files that changed from the base of the PR and between 4d5e959 and 093ed28.

📒 Files selected for processing (1)
  • Makefile

Walkthrough

This PR adds linker flags to the Makefile that instruct the compiler to strip symbol and debug information from the final binary, reducing the output file size during the build process.

Changes

Build Configuration

Layer / File(s) Summary
Linker flags for binary stripping
Makefile
LDFLAGS variable is set to -s -w, enabling symbol and debug info stripping during the build.

🎯 1 (Trivial) | ⏱️ ~2 minutes

🚥 Pre-merge checks | ✅ 12
✅ Passed checks (12 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding LDFLAGS = -s -w to strip debug symbols from Go binaries, which is the core purpose of this PR.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed PR does not use Ginkgo tests. The codebase uses standard Go testing.T framework, not Ginkgo. This check for Ginkgo test name stability is not applicable.
Test Structure And Quality ✅ Passed PR modifies only Makefile (adds LDFLAGS) and adds standard Go unit tests, not Ginkgo tests. Check for Ginkgo test quality is not applicable.
Microshift Test Compatibility ✅ Passed PR does not add any Ginkgo e2e tests. It only modifies Makefile to add LDFLAGS variable for binary stripping. MicroShift compatibility check applies only to new e2e tests.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR only modifies Makefile to add LDFLAGS for binary stripping; no Ginkgo e2e tests are added or modified. The check is not applicable to this non-test repository.
Topology-Aware Scheduling Compatibility ✅ Passed PR only adds linker flags to strip debug symbols from the binary. No deployment manifests, controllers, or scheduling constraints are modified, so the topology check doesn't apply.
Ote Binary Stdout Contract ✅ Passed The -s -w linker flags only affect binary debug symbols, not runtime code or stdout. Livenessprobe is a CSI sidecar, not an OTE test binary.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed PR only modifies Makefile to set LDFLAGS; no Ginkgo e2e tests are added, so IPv6/disconnected network check is not applicable.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested review from dfajmon and mpatlasov May 25, 2026 15:30
@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 25, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: sdodson
Once this PR has been reviewed and has the lgtm label, please assign rhrmo for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 25, 2026

@sdodson: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/verify-commits 093ed28 link true /test verify-commits

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Comment thread Makefile
all: build

include release-tools/build.make
LDFLAGS = -s -w
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Starting a few separate threads)
Why is it necessary in the livenessprobe and not other OCP images? IIRC, we don't stripe any CSI sidecar and most probably no OCP image.

Is there any document that says that OCP binaries need to be stripped?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on that now openshift/enhancements#2021

Comment thread Makefile
all: build

include release-tools/build.make
LDFLAGS = -s -w
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is upstream Makefile. If we really need to strip the binary, it would be better to export this env, var in Dockerfile.openshift.rhel7, which we already <carry>, and it won't conflict with any upstream changes to the Makefile.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK I can refactor toward that

Comment thread Makefile
all: build

include release-tools/build.make
LDFLAGS = -s -w
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And please use UPSTREAM: <carry>: in the commit message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

jira/valid-bug Indicates that a referenced Jira bug is valid for the branch this PR is targeting. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants