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

Build-related flags for executables built from source #1401

Closed
Adirio opened this issue Mar 2, 2020 · 10 comments · Fixed by #1814
Closed

Build-related flags for executables built from source #1401

Adirio opened this issue Mar 2, 2020 · 10 comments · Fixed by #1814
Labels
kind/documentation Categorizes issue or PR as related to documentation. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Milestone

Comments

@Adirio
Copy link
Contributor

Adirio commented Mar 2, 2020

Description

Currently, when kubebuilder is built from source, kubebuilder version yields:

Version: version.Version{KubeBuilderVersion:"unknown", KubernetesVendor:"unknown", GitCommit:"$Format:%H$", BuildDate:"1970-01-01T00:00:00Z", GoOs:"unknown", GoArch:"unknown"}

These variables are set as part of the automated build process, but they are never stored in the release branch. they can be found in

var (
kubeBuilderVersion = "unknown"
kubernetesVendorVersion = "unknown"
goos = "unknown"
goarch = "unknown"
gitCommit = "$Format:%H$" // sha1 from git, output of $(git rev-parse HEAD)
buildDate = "1970-01-01T00:00:00Z" // build date in ISO8601 format, output of $(date -u +'%Y-%m-%dT%H:%M:%SZ')
)

Feature request

Set these flags as part of the development process instead so that, if kubebuilder is built from a release branch, even if it is from source, this fields will be set to provide useful information.

There are three types of variables:

  1. kubeBuilderVersion: should be set in the branch.
  2. Those that should be set in the build process:
    1. goos: can't be stored in the release branch as there is no one branch per target.
    2. goarch: same.
    3. gitCommit: the git commit sha1 can't be obtained before commiting the release, so it needs to be set afterwards.
    4. buildDate: obvious reasons.
  3. kubernetesVendorVersion: has no meaning when building from source.

/kind feature
/kind documentation

@Adirio Adirio added the kind/feature Categorizes issue or PR as related to a new feature. label Mar 2, 2020
@k8s-ci-robot k8s-ci-robot added the kind/documentation Categorizes issue or PR as related to documentation. label Mar 2, 2020
@Adirio
Copy link
Contributor Author

Adirio commented Mar 2, 2020

The four variables in the second group could be set as part of the make build target.

@mengqiy
Copy link
Member

mengqiy commented Mar 3, 2020

kubernetesVendorVersion indicates the version of the testing tools (kube-apiserver and kubectl) shipped in a release.
It's not useful when building from source.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jun 1, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jul 1, 2020
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@Adirio
Copy link
Contributor Author

Adirio commented Oct 27, 2020

/reopen
/remove-lifecycle rotten

@k8s-ci-robot
Copy link
Contributor

@Adirio: Reopened this issue.

In response to this:

/reopen
/remove-lifecycle rotten

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot reopened this Oct 27, 2020
@k8s-ci-robot k8s-ci-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Oct 27, 2020
@Adirio
Copy link
Contributor Author

Adirio commented Oct 27, 2020

/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added the lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. label Oct 27, 2020
@camilamacedo86 camilamacedo86 added this to the next milestone Nov 3, 2020
@Adirio
Copy link
Contributor Author

Adirio commented Nov 11, 2020

@estroz suggested some commands to fetch this data and I would like to expand on them:

  • kubeBuilderVersion: git describe --tags --dirty --broken
  • kubernetesVendorVersion: I'm not sure if this is currently relevant.
  • goos: go env GOOS
  • goarch: go env GOARCH
  • gitCommit: git rev-parse HEAD
  • buildDate: date -u +'%Y-%m-%dT%H:%M:%SZ' <-- This is not Windows compatible :(

P.S.: I removed the --always flag from his suggested git describe command as we already include the commit, so no reason to default to the commit if a tag couldn't be found. I also added the --broken flag which should hopefully never happen but better safe than sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/documentation Categorizes issue or PR as related to documentation. kind/feature Categorizes issue or PR as related to a new feature. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants