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

Add build date #14957

Merged
merged 19 commits into from
Apr 19, 2022
Merged

Add build date #14957

merged 19 commits into from
Apr 19, 2022

Conversation

ccapurso
Copy link
Contributor

@ccapurso ccapurso commented Apr 7, 2022

Core Vault Changes
The concept of a BuildDate has been added to the version package. This will ultimately be used for Vault Enterprise licensing but has also been added to existing endpoints and commands as follows:

  • sys/seal-status now includes a build_date field
  • sys/version-history now includes a build_date field per version entry
  • vault version will denote the build date of the CLI binary, for example Vault v1.11.0-dev1 ('e07f614b1493c70a76591abcbb84424682ad8adf+CHANGES'), built 2022-04-07T13:35:26Z
  • vault status (which uses sys/seal-status) will include Build Date when using --format=table and a build_date field when using --format=json
  • vault version-history (which uses sys/version-history) will include a Build Date when using --format=table. Using --format=json will output the raw sys/version-history response accounting for that endpoint's modified response outlined above.

The sys/version-history endpoint is backed by the core/versions storage entries. These entries are stored as JSON so accounting for the build date simply required providing an extra key. Upon startup, these entries are cached. The cache used to be a map[string]time.Time but has been modified in a future-proof way to allow for information other than the installation time.

Build Tooling Changes

  • scripts/build_date.sh was added to fetch the RFC3339-formatted timestamp of the last commit to provide a stable build date across platforms
  • scripts/build.sh has been modified to provide a build flag via -ldflags for github.com/hashicorp/vault/sdk/version.BuildDate using the build_date.sh script noted above
  • scripts/windows/build.bat has also been modified to set the build date via -ldflags but does so without a separate script
  • The build Make target has been modified to accept a VAULT_BUILD_DATE
  • A get-build-date job has been added to the GitHub build workflows which will call scripts/build_date.sh and provide the generated string as an output
  • The build-* jobs in the GitHub build workflows use the build-date output from above to specify VAULT_BUILD_DATE for make build
  • Verified CI builds by temporarily adding this branch to branches list in .github/workflows/build.yml, subsequently created custom release binary to verify that BuildDate is set properly
  • Verified scripts/windows/build.bat changes on Windows VM

Example output:

❯ vault version
Vault v1.11.0-dev1 ('e07f614b1493c70a76591abcbb84424682ad8adf+CHANGES'), built 2022-04-07T13:35:26Z
❯ vault status
Key             Value
---             -----
Seal Type       shamir
Initialized     true
Sealed          false
Total Shares    1
Threshold       1
Version         1.11.0-dev1
Build Date      2022-04-07T13:35:26Z
Storage Type    inmem
Cluster Name    vault-cluster-e49e8815
Cluster ID      3ff45c8c-cc98-4160-71c0-7078a8efe2ba
HA Enabled      false
❯ vault version-history

Note:
Use of this command requires a server running Vault 1.10.0 or greater.
Version tracking was added in 1.9.0. Earlier versions have not been tracked.


Version  Installation Time     Build Date
-------  -----------------     ----------
1.11.0   2022-04-12T13:37:00Z  2022-04-07T13:35:26

@vercel vercel bot temporarily deployed to Preview – vault-storybook April 7, 2022 17:35 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 7, 2022 17:35 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 7, 2022 18:25 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 7, 2022 18:25 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 7, 2022 19:34 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 7, 2022 19:34 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 7, 2022 20:44 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 7, 2022 20:45 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 8, 2022 12:33 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 8, 2022 12:33 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 8, 2022 13:41 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 8, 2022 13:41 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 8, 2022 14:09 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 8, 2022 14:09 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 8, 2022 15:06 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 8, 2022 15:06 Inactive
@ccapurso ccapurso marked this pull request as ready for review April 12, 2022 19:42
@ccapurso ccapurso requested review from hghaf099, a team, kpenfound and claire-labry and removed request for a team April 12, 2022 19:42
@vercel vercel bot temporarily deployed to Preview – vault April 12, 2022 20:09 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 12, 2022 20:09 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 12, 2022 20:16 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 12, 2022 20:16 Inactive
Copy link
Contributor

@modrake modrake left a comment

Choose a reason for hiding this comment

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

The build changes here look good - if you were feeling extra you could validate the build date string when it is set, but it's an unlikely failure, happy to save it for if it ever crops up outside my pessimistic take 😂

@ccapurso
Copy link
Contributor Author

ccapurso commented Apr 13, 2022

could validate the build date string

@modrake, you and I share the same pessimistic take on this 😂. My hope is to write a release smoke test to verify that the build date is set and properly formatted.

Copy link
Contributor

@sarahethompson sarahethompson left a comment

Choose a reason for hiding this comment

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

LGTM!

@ccapurso ccapurso requested a review from a team April 18, 2022 20:59
Copy link
Contributor

@hghaf099 hghaf099 left a comment

Choose a reason for hiding this comment

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

LGTM

@ccapurso ccapurso merged commit 203b1ad into main Apr 19, 2022
@ccapurso ccapurso deleted the add-build-date branch April 19, 2022 18:28
kitography pushed a commit that referenced this pull request Apr 24, 2022
* add BuildDate to version base

* populate BuildDate with ldflags

* include BuildDate in FullVersionNumber

* add BuildDate to seal-status and associated status cmd

* extend core/versions entries to include BuildDate

* include BuildDate in version-history API and CLI

* fix version history tests

* fix sys status tests

* fix TestStatusFormat

* remove extraneous LD_FLAGS from build.sh

* add BuildDate to build.bat

* fix TestSysUnseal_Reset

* attempt to add build-date to release builds

* add branch to github build workflow

* add get-build-date to build-* job needs

* fix release build command vars

* add missing quote in release build command

* Revert "add branch to github build workflow"

This reverts commit b835699.

* add changelog entry
schultz-is pushed a commit that referenced this pull request Apr 27, 2022
* add BuildDate to version base

* populate BuildDate with ldflags

* include BuildDate in FullVersionNumber

* add BuildDate to seal-status and associated status cmd

* extend core/versions entries to include BuildDate

* include BuildDate in version-history API and CLI

* fix version history tests

* fix sys status tests

* fix TestStatusFormat

* remove extraneous LD_FLAGS from build.sh

* add BuildDate to build.bat

* fix TestSysUnseal_Reset

* attempt to add build-date to release builds

* add branch to github build workflow

* add get-build-date to build-* job needs

* fix release build command vars

* add missing quote in release build command

* Revert "add branch to github build workflow"

This reverts commit b835699.

* add changelog entry
schultz-is pushed a commit that referenced this pull request May 2, 2022
* add BuildDate to version base

* populate BuildDate with ldflags

* include BuildDate in FullVersionNumber

* add BuildDate to seal-status and associated status cmd

* extend core/versions entries to include BuildDate

* include BuildDate in version-history API and CLI

* fix version history tests

* fix sys status tests

* fix TestStatusFormat

* remove extraneous LD_FLAGS from build.sh

* add BuildDate to build.bat

* fix TestSysUnseal_Reset

* attempt to add build-date to release builds

* add branch to github build workflow

* add get-build-date to build-* job needs

* fix release build command vars

* add missing quote in release build command

* Revert "add branch to github build workflow"

This reverts commit b835699.

* add changelog entry
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.

4 participants