-
Notifications
You must be signed in to change notification settings - Fork 111
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
Kubetest2 Version Addition #111
Kubetest2 Version Addition #111
Conversation
supriya-premkumar
commented
Mar 12, 2021
•
edited by amwat
Loading
edited by amwat
- Uses ldflags to capture HEAD rev in short form.
- Prints built commit version by default
- Adds --version support
- Fixes partially Add a version command #108
Welcome @supriya-premkumar! |
Hi @supriya-premkumar. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/assign @amwat @BenTheElder @dims |
aec704c
to
ac10ca5
Compare
/ok-to-test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
Code looks sound
/hold
Deferring to @amwat for approval
Looks like this gets version in the log. What needs to happen to get it in metadata.json and picked up by kettle?
Do we need multiple versions for different kubetest2 binaries? Deployer at one version tester at another sort of thing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/approve
Thank you for working on this!
lgtm after 2 suggestions
Also, we want to do this for all the deployer and tester binaries as well, but fine if it's not in this PR (in which case let's modify the PR description so that it won't close the issue.)
Makefile
Outdated
@@ -21,6 +21,8 @@ | |||
REPO_ROOT:=$(shell pwd) | |||
export REPO_ROOT | |||
OUT_DIR=$(REPO_ROOT)/bin | |||
# record the source commit in the binary, overridable | |||
COMMIT?=$(shell git rev-parse --short HEAD 2>/dev/null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COMMIT?=$(shell git rev-parse --short HEAD 2>/dev/null) | |
COMMIT?=$(shell git describe --tags --always --dirty 2>/dev/null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@amwat Just want to make sure that you won't see a -dirty
suffix if there are any untracked files.
-dirty
works only on tracked diffs. Is this the expectation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we can add that as well, that would be great :) but not a huge blocker.
maybe with git status --porcelain
and manually add a -dirty
suffix if we find untracked files?
We don't produce a Likely a good new functionality addition under Fine if it's a follow up and left out from this PR. |
ac10ca5
to
f5249f6
Compare
I didn't know that every deployer gets built as a separate binary. Let me fix that. |
f5249f6
to
5d70c64
Compare
/retest |
5d70c64
to
4c94ca1
Compare
4c94ca1
to
4526caf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handling deployers will be tricky since we want to support out of tree deployers/testers as well (but we'll be adding the functionality only to the in-tree ones).
I'm fine leaving out the deployer versions from this PR, can be done as a follow up.
What we'd want to achieve that is:
For deployers:
- add
BUILD_FLAGS
specifically in theinstall-deployer-%
make rule - populate a
var
at build time like we already are doing. - would be good to follow the same convention, say
var GitTag string
under respectivemain.go
- plumb this through by adding a new callback (for backwards compatibility)
func MainWithVersion(deployerName string, deployerVersion string, newDeployer types.NewDeployer)
. - modify
Run
to accept version (will be passed as empty fromMain
)func Run(deployerName string, deployerVersion string, newDeployer types.NewDeployer) error
->runE(cmd, args, deployerName, deployerVersion, newDeployer)
For testers:
- add
BUILD_FLAGS
specifically in theinstall-tester-%
make rule - populate a
var
at build time like we already are doing. - would be good to follow the same convention, say
var GitTag string
under respectivemain.go
- invoke the tester with
--version
similar to how we handle--help
for testers (but don't fail on errors) https://github.com/kubernetes-sigs/kubetest2/blob/master/pkg/app/cmd.go#L95-L105
@@ -47,7 +49,7 @@ SPACE:=$(subst ,, ) | |||
SHELL:=env PATH=$(subst $(SPACE),\$(SPACE),$(PATH)) $(SHELL) | |||
# ============================================================================== | |||
# flags for reproducible go builds | |||
BUILD_FLAGS?=-trimpath -ldflags="-buildid=" | |||
BUILD_FLAGS?=-trimpath -ldflags="-buildid= -X=sigs.k8s.io/kubetest2/pkg/app.GitTag=$(COMMIT)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unfortunately, handling the deployers won't be so straightforward :)
this will just always get the kubetest2 shim version. but we can have deployers built at different commits.
I was held up last week. I will work on it this week, thank you. |
4526caf
to
5135f73
Compare
5135f73
to
f369bc1
Compare
- Uses ldflags to capture HEAD rev in short form. - Prints built commit version by default - Adds --version support - Fixes 108
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getting the version for the main binary is a good start
/lgtm
/approve
/hold
modifying the PR description so it doesn't close the issue
@@ -67,6 +67,8 @@ func runE( | |||
opts.bindFlags(kubetest2Flags) | |||
artifacts.MustBindFlags(kubetest2Flags) | |||
|
|||
cmd.Printf("Running deployer %s version: %s\n", deployerName, shim.GitTag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add this after deployer versions are added
@@ -91,6 +93,7 @@ func runE( | |||
if err != nil { | |||
return fmt.Errorf("unable to find tester %v: %v", opts.test, err) | |||
} | |||
cmd.Printf("Running tester %s version: %s\n", opts.test, shim.GitTag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can add this after testers versions are added
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: amwat, supriya-premkumar The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
we might be able to get clever with https://golang.org/pkg/runtime/debug/#BuildInfo for out of tree stuff importing the repo |
// there should be at least one argument (the deployer) unless the user | ||
// is asking for help on the shim itself | ||
if len(args) < 1 { | ||
return cmd.Help() | ||
} | ||
|
||
// gracefully handle -h or --help if it is the only argument | ||
// gracefully handle help or version command if it is the only argument |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this feature, but if other arguments are set AND --help is included, it will try to deploy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no
Lines 139 to 143 in 96ab8c9
// print usage and return if no args are provided, or help is explicitly requested | |
if len(args) == 0 || opts.HelpRequested() { | |
cmd.Print(usage.String()) | |
return nil | |
} |
@amwat perhaps unhold and iterate? |
yeah, I think we can iterate on this /unhold |