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

Fill in version information #962

Merged
merged 6 commits into from
Feb 9, 2022
Merged

Fill in version information #962

merged 6 commits into from
Feb 9, 2022

Conversation

andyasp
Copy link
Contributor

@andyasp andyasp commented Jan 28, 2022

What this PR does:
I wasn't sure if this was the best way to go about fixing this, but I gave it a try. I added reviewers who I've seen discussing this issue.

Fills in the BuildUser and BuildDate fields when printing --version. date isn't consistent between GNU/BSD utils, so a complicated format string was used instead of GNU's -Is (would using gdate be better?). There's no particular reason to use ISO-8601.

In addition, I swapped the Makefile to also set the values directly rather than through main. That wasn't a necessary change, it just seemed cleaner, but it would negatively impact #951

Which issue(s) this PR fixes:

Fixes #860 when using the Makefile

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Makefile Outdated Show resolved Hide resolved
cmd/mimir/main.go Outdated Show resolved Hide resolved
Makefile Outdated
@@ -17,6 +17,9 @@ GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)

HOSTNAME := $(shell hostname)
BUILD_USER := $(shell id -un)@$(HOSTNAME)
# Date in ISO 8601
BUILD_DATE := $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
Copy link
Contributor

Choose a reason for hiding this comment

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

This will for sure prevent our builds from being reproducible. Not too sure if they are right now.

I suggest to use the commit date of the latest commit hash

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a good point. I'm not sure about the current state of reproducible builds either but I'll make the change to the commit date.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Swapped to git log -1 --format=%cI

Copy link
Member

Choose a reason for hiding this comment

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

"build date" and "commit date" are two different things, and I would expect to see time being updated on rebuilds.

I just tried to build this locally, and got:

./cmd/mimir/mimir -version
Mimir, version 1.10.0-rc.0 (branch: pull/962, revision: 550a5c367)
  build user:       [email protected]
  build date:       2022-01-31T11:09:21-05:00
  go version:       go1.17.5
  platform:         darwin/arm64

Even though it's 2nd of February today. It may be better to skip build date, rather than include wrong information in the binary.

Copy link
Member

Choose a reason for hiding this comment

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

(I think this may also be super-confusing for users, who check out some old revision, and build it.)

Copy link
Member

Choose a reason for hiding this comment

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

Furthermore build user is already "random", when building in the container:

Mimir, version 1.10.0-rc.0 (branch: pull/962, revision: 550a5c367)
  build user:       root@5e8907569246
  build date:       2022-01-31T11:09:21-05:00
  go version:       go1.17.3
  platform:         darwin/arm64

Maybe the solution is to simply not print build user and build date, and keep them empty.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was thinking about this yesterday as well after committing that change and I agree with you. Including any user/hostname would be a hurdle towards reproducible builds as well and "build date" is confusing with a commit date.

Copy link
Member

@jdbaldry jdbaldry left a comment

Choose a reason for hiding this comment

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

LGTM

Makefile Outdated Show resolved Hide resolved
@andyasp andyasp marked this pull request as draft February 2, 2022 18:37
BuildUser and BuildDate are now filled. Swapped the Makefile to also
set the values directly rather than through main, although this was
not a necessary change.
@andyasp andyasp marked this pull request as ready for review February 2, 2022 20:40
Copy link
Member

@pstibrany pstibrany 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, thank you!

@@ -46,9 +39,6 @@ var configHash *prometheus.GaugeVec = prometheus.NewGaugeVec(
)

func init() {
version.Version = Version
version.Branch = Branch
version.Revision = Revision
prometheus.MustRegister(version.NewCollector("cortex"))
Copy link
Member

Choose a reason for hiding this comment

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

Shall we change cortex to mimir here? It would change cortex_build_info to mimir_build_info, and this needs to be documented in CHANGELOG. I don't see this metric used anywhere in our jsonnet or internal tooling. (Can be separate PR too)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that makes a lot of sense given that this is no longer cortex build information. Probably best to do it in another PR though since I'm unaware of what the plans are for metric renaming.

Copy link
Member

Choose a reason for hiding this comment

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

In general we plan to keep metrics as-is. However in this specific case, I think it makes sense to rename. But we can discuss that separately.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Opened #1022

@pstibrany pstibrany enabled auto-merge (squash) February 9, 2022 10:52
@pstibrany pstibrany merged commit 790c8a9 into main Feb 9, 2022
@pstibrany pstibrany deleted the aasp/version-information branch February 9, 2022 10:56
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.

Developer builds do not report proper versions
5 participants