Skip to content
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

log submariner component's version on startup #2552

Merged
merged 2 commits into from
Jul 17, 2023

Conversation

cyclinder
Copy link
Contributor

@submariner-bot
Copy link
Contributor

🤖 Created branch: z_pr2552/cyclinder/version
🚀 Full E2E won't run until the "ready-to-test" label is applied. I will add it automatically once the PR has 2 approvals, or you can add it manually.

@cyclinder cyclinder marked this pull request as draft June 19, 2023 06:31
@cyclinder cyclinder marked this pull request as draft June 19, 2023 06:31
@nyechiel nyechiel linked an issue Jun 19, 2023 that may be closed by this pull request
pkg/version/version.go Outdated Show resolved Hide resolved
pkg/version/version.go Outdated Show resolved Hide resolved
pkg/version/version.go Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@cyclinder
Copy link
Contributor Author

Thanks for all your comments! @nirs

All comments have been addressed, But It's failed to image build, I'm not familiar with build code, it seems now submariner doesn't support go build with -ldflags? I'm trying to build it in my local, and it works.

cyclinder  submariner   ( version)  ♥ 15:00  make bin/%/submariner-route-agent                                                                                      
docker network create  -d bridge kind
Error response from daemon: network with name kind already exists
make: [bin/%/submariner-route-agent] Error 1 (ignored)
./.dapper   -- make  bin/%/submariner-route-agent
[+] Building 0.2s (8/8) FINISHED                                                                                                                                                                     
 => [internal] load build definition from Dockerfile.dapper                                                                                                                                     0.0s
 => => transferring dockerfile: 44B                                                                                                                                                             0.0s
 => [internal] load .dockerignore                                                                                                                                                               0.0s
 => => transferring context: 2B                                                                                                                                                                 0.0s
 => [internal] load metadata for quay.io/submariner/shipyard-dapper-base:devel                                                                                                                  0.0s
 => [1/4] FROM quay.io/submariner/shipyard-dapper-base:devel                                                                                                                                    0.0s
 => CACHED [2/4] WORKDIR /go/src/github.com/submariner-io/submariner                                                                                                                            0.0s
 => CACHED [3/4] RUN git config --global --add safe.directory /go/src/github.com/submariner-io/submariner                                                                                       0.0s
 => CACHED [4/4] RUN git config --global --add safe.directory /go/src/github.com/submariner-io/submariner/ovn-kubernetes                                                                        0.0s
 => exporting to image                                                                                                                                                                          0.0s
 => => exporting layers                                                                                                                                                                         0.0s
 => => writing image sha256:73287c580d965569832571e6ff0b32c86237c0954bb5ea21ba25b282cf2e5db8                                                                                                    0.0s
 => => naming to docker.io/library/submariner:version                                                                                                                                           0.0s

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them
Checking if Makefile.dapper is up to date
Checking if Dockerfile.dapper is up to date
GOARCH=bin/%/ \
LDFLAGS=-X github.com/submariner-io/submariner/pkg/version/version.gitCommitHash=a28429ee67f72047ce4e92efad8ec4eab5eed78f -X github.com/submariner-io/submariner/pkg/version/version.gitCommitDate=2023-06-24T14:52:48+08:00 \
/opt/shipyard/scripts/compile.sh bin/%/submariner-route-agent ./pkg/routeagent_driver
/bin/bash: line 1: github.com/submariner-io/submariner/pkg/version/version.gitCommitHash=a28429ee67f72047ce4e92efad8ec4eab5eed78f: No such file or directory
make: *** [Makefile:73: bin/%/submariner-route-agent] Error 127
make: *** [bin/%/submariner-route-agent] Error 2
cyclinder  submariner   ( version)  ♥ 15:00  LDFLAGS1="-X github.com/submariner-io/submariner/pkg/version/version.gitCommitHash=GIT_COMMIT_HASH -X github.com/submariner-io/submariner/pkg/version/version.gitCommitDate=GIT_COMMIT_DATE"
cyclinder  submariner   ( version)  ♥ 15:00  CGO_ENABLED=0 GOOS=linux ARCH=amd64 go build -trimpath  -ldflags "-s -w ${LDFLAGS1}" -o router  ./pkg/routeagent_driver
cyclinder  submariner   ( version)  ♥ 15:00  ls router                   
router
cyclinder  submariner   ( version)  ♥ 15:00  

I would be very grateful if you could help me.

Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
pkg/version/version.go Outdated Show resolved Hide resolved
pkg/version/version.go Outdated Show resolved Hide resolved
@nirs
Copy link

nirs commented Jun 24, 2023

GOARCH=bin/%/
LDFLAGS=-X github.com/submariner-io/submariner/pkg/version/version.gitCommitHash=a28429ee67f72047ce4e92efad8ec4eab5eed78f -X github.com/submariner-io/submariner/pkg/version/version.gitCommitDate=2023-06-24T14:52:48+08:00
/opt/shipyard/scripts/compile.sh bin/%/submariner-route-agent ./pkg/routeagent_driver
/bin/bash: line 1: github.com/submariner-io/submariner/pkg/version/version.gitCommitHash=a28429ee67f72047ce4e92efad8ec4eab5eed78f: No such file or directory

Because LDFLAGS= value was not quoted, we tried to execute:

github.com/submariner-io/submariner/pkg/version/version.gitCommitHash=a28429ee67f72047ce4e92efad8ec4eab5eed78f

@cyclinder cyclinder force-pushed the version branch 3 times, most recently from 88c6fe2 to 1896043 Compare June 25, 2023 13:44
@cyclinder cyclinder marked this pull request as ready for review June 25, 2023 13:59
@cyclinder
Copy link
Contributor Author

Thanks again for your comments. I believe the CI can pass this time.

Makefile Outdated Show resolved Hide resolved
Makefile Show resolved Hide resolved
pkg/version/version.go Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@cyclinder cyclinder force-pushed the version branch 2 times, most recently from d18da3d to fbe6add Compare June 26, 2023 06:03
@dfarrell07 dfarrell07 added the backport This change requires a backport to eligible release branches label Jun 27, 2023
Copy link

@nirs nirs left a comment

Choose a reason for hiding this comment

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

Looks good except the change in default version and unneeded export in the makefile.

Makefile Outdated Show resolved Hide resolved
@cyclinder cyclinder force-pushed the version branch 3 times, most recently from 6bcf626 to 40941be Compare July 6, 2023 02:07
@dfarrell07 dfarrell07 added the ready-to-test When a PR is ready for full E2E testing label Jul 10, 2023
Copy link

@nirs nirs left a comment

Choose a reason for hiding this comment

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

Strange that LDFLAGS =-X github.com/submariner-io/submariner/pkg/version.Version= works but it will be easy to change such details later if needed.

@cyclinder
Copy link
Contributor Author

Oh,I think it's nit here, it should be version rather than Version.

@cyclinder cyclinder force-pushed the version branch 2 times, most recently from fb4e6f8 to 780b180 Compare July 11, 2023 01:52
pkg/version/version.go Outdated Show resolved Hide resolved
pkg/version/version.go Outdated Show resolved Hide resolved
pkg/version/version.go Outdated Show resolved Hide resolved
@cyclinder cyclinder force-pushed the version branch 2 times, most recently from c7e90c8 to 7963f19 Compare July 14, 2023 02:29
@cyclinder
Copy link
Contributor Author

Thanks all @nirs @tpantelis

Makefile Outdated Show resolved Hide resolved
@skitt skitt enabled auto-merge (rebase) July 17, 2023 15:49
@skitt skitt merged commit fb660d9 into submariner-io:devel Jul 17, 2023
36 checks passed
@submariner-bot
Copy link
Contributor

🤖 Closed branches: [z_pr2552/cyclinder/version]

@dfarrell07
Copy link
Member

Backported to 0.15: #2615
Doesn't backport cleanly to 0.14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport This change requires a backport to eligible release branches backport-handled ready-to-test When a PR is ready for full E2E testing
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Submariner components should log their version on startup
6 participants