Skip to content

Comments

Add extended version info#159

Merged
vponomaryov merged 1 commit intoscylladb:masterfrom
dimakr:extended_version_info
Mar 3, 2025
Merged

Add extended version info#159
vponomaryov merged 1 commit intoscylladb:masterfrom
dimakr:extended_version_info

Conversation

@dimakr
Copy link
Contributor

@dimakr dimakr commented Feb 23, 2025

This change introduces 2 new CLI options to report the versions of scylla-bench and scylla-gocql-driver:

  • -version for printing the versions info in human readable format
  • -version-json for printing the versions info in JSOn format

For both scylla-bench and driver version the layered approach of extracting informaion is used

  • scylla-bench version info is initially read from vars set via ldflags, if those were explicitly provided. Otherwise it falls back to getting VCS info from build info.
  • driver version info in the 1st place is read from env. vars, if those were explicitly provided. Otherwise it tries to read the released version info. Then it tries to parse pseudo-version format, if version has it. Then it falls back to raw version string.

Example of the new CLI options results:

❯ ./scylla-bench -version
scylla-bench:
    version: v0.1.24-dev-438fcfe2
    commit sha: 438fcfe2d336f23a5fa931910a60f14c3e099641
    commit date: 2025-02-25T17:50:57Z
scylla-gocql-driver:
    version: v1.14.4
    commit sha: 2be0988d03e67a530c29c9cae13ddac47358a45a
    commit date: 2024-09-19T11:47:32Z
❯ ./scylla-bench -version-json
{
  "scylla-bench": {
    "version": "v0.1.24-dev-438fcfe2",
    "commit_date": "2025-02-25T17:50:57Z",
    "commit_sha": "438fcfe2d336f23a5fa931910a60f14c3e099641"
  },
  "scylla-driver": {
    "version": "v1.14.4",
    "commit_date": "2024-09-19T11:47:32Z",
    "commit_sha": "2be0988d03e67a530c29c9cae13ddac47358a45a"
  }
}

@dimakr
Copy link
Contributor Author

dimakr commented Feb 23, 2025

Initially was preparing this change with go1.18 on my setup, and for local source/repo it was able to get version details from build info as is, i.e. the VCS info was automatically included in the binary by default so debug.ReadBuildInfo() was providing everything needed.
But in newer go versions (i tried 1.24) that info is not included automatically, so the VCS info should be provided via ldflags anyway.

@dimakr
Copy link
Contributor Author

dimakr commented Feb 23, 2025

The step of setting the version information during the build of the tool is due to be added after the PR that updates the makefile and Dockerfile is merged (#158)

@dimakr dimakr force-pushed the extended_version_info branch 2 times, most recently from 438fcfe to b48a6f9 Compare February 28, 2025 12:35
This change introduces a pair of CLI options - `-version` and `-version-json` - to
print the verions of scylla-bench and gocql driver, in human-readable or JSON
formats respectively.

Closes: scylladb#156
@dimakr dimakr force-pushed the extended_version_info branch from b48a6f9 to 2085a06 Compare February 28, 2025 13:39
@dimakr dimakr marked this pull request as ready for review February 28, 2025 13:42
@dimakr
Copy link
Contributor Author

dimakr commented Feb 28, 2025

The linting step check is failing due to check is missed in makefile (as mentioned here - #158 (comment))

@dimakr
Copy link
Contributor Author

dimakr commented Feb 28, 2025

Some tests of getting version info when building scylla-bench differently:
local go build with non released changes in the scylla-bench:

❯ go build -o scylla-bench
❯ ./scylla-bench -version
scylla-bench:
    version: v0.1.24-dev-438fcfe2
    commit sha: 438fcfe2d336f23a5fa931910a60f14c3e099641
    commit date: 2025-02-25T17:50:57Z
scylla-gocql-driver:
    version: v1.14.4
    commit sha: 2be0988d03e67a530c29c9cae13ddac47358a45a
    commit date: 2024-09-19T11:47:32Z

make build

❯ make build
Building static scylla-bench
❯ ./build/scylla-bench -version
scylla-bench:
    version: v0.1.24-3-g438fcfe
    commit sha: 438fcfe2d336f23a5fa931910a60f14c3e099641
    commit date: 2025-02-25T17:50:57Z
scylla-gocql-driver:
    version: v1.14.4
    commit sha: 2be0988d03e67a530c29c9cae13ddac47358a45a
    commit date: 2024-09-19T11:47:32Z

make build with custom driver version

❯ GOCQL_REPO="github.com/sylwiaszunejko/gocql" GOCQL_VERSION="8b2446c67341fa15b131a1a91b067e023df0c7c6" make build-with-custom-gocql-version
Using custom gocql commit "8b2446c67341fa15b131a1a91b067e023df0c7c6"
Building static scylla-bench
❯ ./build/scylla-bench -version
scylla-bench:
    version: v0.1.24-3-g438fcfe
    commit sha: 438fcfe2d336f23a5fa931910a60f14c3e099641
    commit date: 2025-02-25T17:50:57Z
scylla-gocql-driver:
    version: 8b2446c67341
    commit sha: 8b2446c67341
    commit date: 2025-02-24T13:33:28Z

local go build from scylla-bench released/tagged version:

❯ git checkout tags/v0.1.24
❯ go build -o scylla-bench
❯ ./scylla-bench -version
scylla-bench:
    version: v0.1.24
    commit sha: 90c26d05657f02121355cf3e5aa6f68e557d2e3f
    commit date: 2024-11-05T12:53:41Z
scylla-gocql-driver:
    version: v1.14.1
    commit sha: 790b1a82673b718296187de5186eef5a6d00b62f
    commit date: 2024-06-19T08:09:28Z

@dimakr dimakr requested a review from fruch February 28, 2025 13:49
@dimakr dimakr self-assigned this Feb 28, 2025
@dimakr dimakr requested a review from vponomaryov February 28, 2025 13:52
Copy link
Contributor

@fruch fruch left a comment

Choose a reason for hiding this comment

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

LGTM

@fruch fruch requested review from dkropachev and soyacz March 2, 2025 13:11
@fruch
Copy link
Contributor

fruch commented Mar 3, 2025

@soyacz @vponomaryov
can you give one last view on this one, before we merge it ?

@fruch
Copy link
Contributor

fruch commented Mar 3, 2025

@CodeLieutenant

the pipeline here is broken, can you look into it ?

@CodeLieutenant
Copy link
Contributor

Fixed on master

Copy link
Contributor

@vponomaryov vponomaryov left a comment

Choose a reason for hiding this comment

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

LGTM

@vponomaryov vponomaryov merged commit 2ad6721 into scylladb:master Mar 3, 2025
1 check failed
@dimakr dimakr deleted the extended_version_info branch April 21, 2025 15:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants