Skip to content

[bug] Fix the version module path in ldflags #6990

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

Merged
merged 1 commit into from
Apr 6, 2025

Conversation

developer-guy
Copy link
Contributor

I noticed that you have changed the version module path so we have to update the path in the ldflags too:

* Move pkg/version to internal/version ([@danish9039](https://github.com/danish9039) in [#6913](https://github.com/jaegertracing/jaeger/pull/6913))

@developer-guy developer-guy requested a review from a team as a code owner April 6, 2025 16:33
@developer-guy developer-guy requested a review from albertteoh April 6, 2025 16:33
@developer-guy developer-guy changed the title fix the version module path in ldflags BUG: fix the version module path in ldflags Apr 6, 2025
Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

Thanks. Is there a way to have this code fail on the wrong paths?

@developer-guy
Copy link
Contributor Author

I'm not sure how we could test this sorry :(

Copy link

codecov bot commented Apr 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.99%. Comparing base (06840ac) to head (cadb892).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6990   +/-   ##
=======================================
  Coverage   95.99%   95.99%           
=======================================
  Files         346      346           
  Lines       20429    20429           
=======================================
  Hits        19611    19611           
  Misses        616      616           
  Partials      202      202           
Flag Coverage Δ
badger_v1 10.53% <ø> (ø)
badger_v2 2.18% <ø> (ø)
cassandra-4.x-v1-manual 15.84% <ø> (ø)
cassandra-4.x-v2-auto 2.17% <ø> (ø)
cassandra-4.x-v2-manual 2.17% <ø> (ø)
cassandra-5.x-v1-manual 15.84% <ø> (ø)
cassandra-5.x-v2-auto 2.17% <ø> (ø)
cassandra-5.x-v2-manual 2.17% <ø> (ø)
elasticsearch-6.x-v1 20.76% <ø> (ø)
elasticsearch-7.x-v1 20.84% <ø> (ø)
elasticsearch-8.x-v1 21.02% <ø> (ø)
elasticsearch-8.x-v2 2.18% <ø> (ø)
grpc_v1 11.61% <ø> (ø)
grpc_v2 8.47% <ø> (ø)
kafka-3.x-v1 10.82% <ø> (ø)
kafka-3.x-v2 2.18% <ø> (ø)
memory_v2 2.18% <ø> (ø)
opensearch-1.x-v1 20.89% <ø> (ø)
opensearch-2.x-v1 20.89% <ø> (ø)
opensearch-2.x-v2 2.18% <ø> (ø)
tailsampling-processor 0.59% <ø> (ø)
unittests 94.79% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@developer-guy
Copy link
Contributor Author

we could write another script where we could test the build time injection like the following:

#!/bin/bash
set -e

go build -ldflags="-X 'main.version=$1'" -o app main.go
output=$(./app)

if [[ "$output" == "Version: $1" ]]; then
    echo "✅ PASS: Injected version correctly: $output"
else
    echo "❌ FAIL: Unexpected version: $output"
    exit 1
fi

then we could run it as another step in the release workflows.

@yurishkuro yurishkuro added this pull request to the merge queue Apr 6, 2025
@yurishkuro
Copy link
Member

we could write another script where we could test the build time injection like the following:

would you like to add this in another PR? It doesn't need to be a separate script, just an extra check in the build process, perhaps in build-jaeger in scripts/makefiles/BuildBinaries.mk

@yurishkuro yurishkuro changed the title BUG: fix the version module path in ldflags [bug] Fix the version module path in ldflags Apr 6, 2025
@yurishkuro yurishkuro removed this pull request from the merge queue due to a manual request Apr 6, 2025
@yurishkuro yurishkuro added this pull request to the merge queue Apr 6, 2025
Merged via the queue into jaegertracing:main with commit 7e41a23 Apr 6, 2025
57 checks passed
github-merge-queue bot pushed a commit that referenced this pull request May 3, 2025
## Which problem is this PR solving?
- Resolves #7090

## Description of the changes
- Add validation to the build step that the version number is correctly
embedded in the binary

## How was this change tested?
- When reverting the fix done in #6990 the build fails:
```
$ make build-jaeger
echo "building binary for $(go env GOOS)-$(go env GOARCH)"; CGO_ENABLED=0 installsuffix=cgo go build -trimpath   -o ./cmd/jaeger/jaeger-darwin-arm64   -ldflags "-X   github.com/jaegertracing/jaeger/pkg/version.commitSHA=687207be86edb688436f8ef6c4383968a0ec1855 -X   github.com/jaegertracing/jaeger/pkg/version.latestVersion=v2.5.0 -X   github.com/jaegertracing/jaeger/pkg/version.date=2025-05-02T18:47:48Z" ./cmd/jaeger
building binary for darwin-arm64
❌ ERROR: version mismatch: want=v2.5.0, have=
make: *** [build-jaeger] Error 1
```

---------

Signed-off-by: Yuri Shkuro <[email protected]>
amilbcahat pushed a commit to amilbcahat/jaeger that referenced this pull request May 4, 2025
I noticed that you have changed the version module path so we have to
update the path in the ldflags too:
https://github.com/jaegertracing/jaeger/blob/06840acda4e6ea5cec5afaa19356125595904231/CHANGELOG.md?plain=1#L86

Signed-off-by: Batuhan Apaydin <[email protected]>
amilbcahat pushed a commit to amilbcahat/jaeger that referenced this pull request May 4, 2025
…racing#7092)

## Which problem is this PR solving?
- Resolves jaegertracing#7090

## Description of the changes
- Add validation to the build step that the version number is correctly
embedded in the binary

## How was this change tested?
- When reverting the fix done in jaegertracing#6990 the build fails:
```
$ make build-jaeger
echo "building binary for $(go env GOOS)-$(go env GOARCH)"; CGO_ENABLED=0 installsuffix=cgo go build -trimpath   -o ./cmd/jaeger/jaeger-darwin-arm64   -ldflags "-X   github.com/jaegertracing/jaeger/pkg/version.commitSHA=687207be86edb688436f8ef6c4383968a0ec1855 -X   github.com/jaegertracing/jaeger/pkg/version.latestVersion=v2.5.0 -X   github.com/jaegertracing/jaeger/pkg/version.date=2025-05-02T18:47:48Z" ./cmd/jaeger
building binary for darwin-arm64
❌ ERROR: version mismatch: want=v2.5.0, have=
make: *** [build-jaeger] Error 1
```

---------

Signed-off-by: Yuri Shkuro <[email protected]>
amilbcahat pushed a commit to amilbcahat/jaeger that referenced this pull request May 4, 2025
I noticed that you have changed the version module path so we have to
update the path in the ldflags too:
https://github.com/jaegertracing/jaeger/blob/06840acda4e6ea5cec5afaa19356125595904231/CHANGELOG.md?plain=1#L86

Signed-off-by: Batuhan Apaydin <[email protected]>
Signed-off-by: amol-verma-allen <[email protected]>
amilbcahat pushed a commit to amilbcahat/jaeger that referenced this pull request May 4, 2025
…racing#7092)

## Which problem is this PR solving?
- Resolves jaegertracing#7090

## Description of the changes
- Add validation to the build step that the version number is correctly
embedded in the binary

## How was this change tested?
- When reverting the fix done in jaegertracing#6990 the build fails:
```
$ make build-jaeger
echo "building binary for $(go env GOOS)-$(go env GOARCH)"; CGO_ENABLED=0 installsuffix=cgo go build -trimpath   -o ./cmd/jaeger/jaeger-darwin-arm64   -ldflags "-X   github.com/jaegertracing/jaeger/pkg/version.commitSHA=687207be86edb688436f8ef6c4383968a0ec1855 -X   github.com/jaegertracing/jaeger/pkg/version.latestVersion=v2.5.0 -X   github.com/jaegertracing/jaeger/pkg/version.date=2025-05-02T18:47:48Z" ./cmd/jaeger
building binary for darwin-arm64
❌ ERROR: version mismatch: want=v2.5.0, have=
make: *** [build-jaeger] Error 1
```

---------

Signed-off-by: Yuri Shkuro <[email protected]>
Signed-off-by: amol-verma-allen <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants