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

use kube::util::find-binary to find kubectl #1844

Merged
merged 1 commit into from
Sep 11, 2020

Conversation

mikedanese
Copy link
Contributor

To centralize binary selection in k/k. Also drop the e2e.test copying
which is no longer needed according to the comment.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 11, 2020
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 11, 2020
@k8s-ci-robot k8s-ci-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Sep 11, 2020
@mikedanese mikedanese force-pushed the bzl branch 3 times, most recently from 035b1d0 to 29e025d Compare September 11, 2020 03:48
# This is run from k/k root, so shellcheck shouldn't expect to be able to
# follow hack/lib/util.sh.
# shellcheck disable=SC1091
kubectl_path="$(source hack/lib/util.sh; kube::util::find-binary '.test')"
Copy link
Member

Choose a reason for hiding this comment

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

we're going to be up a tree when we port this out of bash :|
#986 #1269

# TODO: remove this, it was fixed in 1.13+
mkdir -p '_output/bin/'
cp 'bazel-bin/test/e2e/e2e.test' '_output/bin/'
PATH="$(dirname "$(find "${PWD}/bazel-bin/" -name kubectl -type f)"):${PATH}"
Copy link
Member

Choose a reason for hiding this comment

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

why isn't this sufficient? most of the kube::util::find-binary logic is for the makefile output.
is there a non-executable file in bazel-bin named kubectl now?

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 suspect it would work fine to use find right now but I'm not very familiar with how we use the bazel cache and future changes (e.g. cross building in the same CI pool) might subtly cause issues. kube::util::find-binary is more complex but it does a reasonable job. I don't feel too strongly either way. Yet another option is to use cluster/kubectl.sh like other CI jobs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pushed a fourth option that doesn't depend on kube::util::find-binary

Copy link
Member

Choose a reason for hiding this comment

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

we can't cross build in bazel still because of CGO, we have never run cross build in CI.

locally might be unfortunate though ...

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

this was intentionally written in posix sh since the logic is simple.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched in order to source hack/lib/util.sh. Thought process: bash is fairly universal nowadays, used in most places in k/*, and all other shell scripts in this directory use bash. It can still be simple even if it's bash :)

@mikedanese mikedanese force-pushed the bzl branch 2 times, most recently from 747fb3a to f19df36 Compare September 11, 2020 04:30
@mikedanese
Copy link
Contributor Author

/retest

@mikedanese mikedanese force-pushed the bzl branch 2 times, most recently from 4d55270 to f19df36 Compare September 11, 2020 07:44
To centralize binary selection in k/k. Also drop the e2e.test copying
which is no longer needed according to the comment.
@mikedanese
Copy link
Contributor Author

cc @justaugustus

@@ -67,16 +67,16 @@ build_with_bazel() {
# make sure we have e2e requirements
bazel build //cmd/kubectl //test/e2e:e2e.test //vendor/github.com/onsi/ginkgo/ginkgo

kubectl_path="$(bazel aquery 'mnemonic("GoLink", //cmd/kubectl)' \
| grep '^ Outputs: \[.*\]$' \
| sed 's/^ Outputs: \[\(.*\)\]$/\1/')"
Copy link
Member

Choose a reason for hiding this comment

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

neat ...

@BenTheElder
Copy link
Member

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BenTheElder, mikedanese

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 11, 2020
@k8s-ci-robot k8s-ci-robot merged commit c4359a9 into kubernetes-sigs:master Sep 11, 2020
@mikedanese mikedanese deleted the bzl branch September 11, 2020 18:41
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/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants