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 version support for all binaries #162

Merged
merged 11 commits into from
Aug 17, 2021

Conversation

amwat
Copy link
Contributor

@amwat amwat commented Aug 7, 2021

also add support for writing metadata.json similar to what kubetest does in existing prow jobs.

fixes: #108

For deployers:
the shim GitTag won't be present for out-of-tree providers instead inject an env KUBETEST2_VERSION from the shim to the deployers.

For testers:
Went the route of overwriting metadata in testers.
alternative was to enforce all testers support a --version flag and detect it similar to --help, but is unnecessarily restrictive.

/cc @BenTheElder @spiffxp

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 7, 2021
@amwat
Copy link
Contributor Author

amwat commented Aug 7, 2021

I would recommend reviewing by commit

@@ -44,6 +44,10 @@ func (d *Deployer) Init() error {

// Initialize should only be called by init(), behind a sync.Once
func (d *Deployer) Initialize() error {
if d.ClusterVersion == "" && d.LegacyClusterVersion != "" {
klog.Warningf("--version is deprecated please use --cluster-version")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

fyi @chizhg

Copy link
Contributor

Choose a reason for hiding this comment

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

ACK

if err2 != nil {
return err2
}
if err := meta.Add("kubetest-version", os.Getenv("KUBETEST2_VERSION")); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this currently tries to match with
kubernetes/test-infra#20886 (comment)

Copy link
Member

@BenTheElder BenTheElder left a comment

Choose a reason for hiding this comment

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

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 10, 2021
@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 10, 2021
kubetest2-gke/deployer/deployer.go Outdated Show resolved Hide resolved
@@ -44,6 +44,10 @@ func (d *Deployer) Init() error {

// Initialize should only be called by init(), behind a sync.Once
func (d *Deployer) Initialize() error {
if d.ClusterVersion == "" && d.LegacyClusterVersion != "" {
klog.Warningf("--version is deprecated please use --cluster-version")
Copy link
Contributor

Choose a reason for hiding this comment

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

ACK

Copy link
Member

@spiffxp spiffxp left a comment

Choose a reason for hiding this comment

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

Overall LGTM, mostly questions

The change I'm requesting is the one @chizhg pointed out

@@ -29,7 +29,8 @@ type UpOptions struct {
NumNodes int `flag:"~num-nodes" desc:"For use with gcloud commands to specify the number of nodes for the cluster."`
ImageType string `flag:"~image-type" desc:"The image type to use for the cluster."`
ReleaseChannel string `desc:"Use a GKE release channel, could be one of empty, rapid, regular and stable - https://cloud.google.com/kubernetes-engine/docs/concepts/release-channels"`
Version string `desc:"Use a specific GKE version e.g. 1.16.13.gke-400, 'latest' or ''. If --build is specified it will default to building kubernetes from source."`
ClusterVersion string `desc:"Use a specific GKE version e.g. 1.16.13.gke-400, 'latest' or ''. If --build is specified it will default to building kubernetes from source."`
LegacyClusterVersion string `flag:"~version,deprecated" desc:"Use --cluster-version instead"`
Copy link
Member

Choose a reason for hiding this comment

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

When will this get removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

most likely in the release afterwards. (v0.2.0)

Comment on lines +169 to +171
metadataJSON, err := os.Create(
filepath.Join(opts.RunDir(), "metadata.json"),
)
Copy link
Member

Choose a reason for hiding this comment

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

Any reason this can't match the behavior of pkg.testers.metadata.WriteVersionToMetadata and preserve an existing metadata if it happens to exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can, but atleast at this point kubetest2 itself doesn't expect any metadata.json to be written out to the run specific output directory by itself.

Comment on lines +116 to +123
// DeployerWithVersion allows the deployer to specify it's version
type DeployerWithVersion interface {
Deployer

// Version determines the version of the deployer binary
Version() string
}

Copy link
Member

Choose a reason for hiding this comment

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

What would be involved in making Version() part of Deployer? Seeing three different DeployerWithFoo interfaces makes me wonder if it keeps things simpler to fold into core

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's something we can add in v0.2.0
Currently, all out of tree deployers won't have Version() and will break the core interface.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 17, 2021
Copy link
Member

@spiffxp spiffxp left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 17, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: amwat, BenTheElder, spiffxp

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:
  • OWNERS [BenTheElder,amwat,spiffxp]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@amwat
Copy link
Contributor Author

amwat commented Aug 17, 2021

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 17, 2021
@k8s-ci-robot k8s-ci-robot merged commit 67b31b5 into kubernetes-sigs:master Aug 17, 2021
@amwat amwat deleted the version branch August 17, 2021 23:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a version command
5 participants