-
Notifications
You must be signed in to change notification settings - Fork 38.8k
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
Vendor gazelle and kazel #57600
Vendor gazelle and kazel #57600
Conversation
3624b08
to
e9119ab
Compare
e9119ab
to
909244b
Compare
909244b
to
65f8090
Compare
Love the idea. Any idea why tests are failing? |
godep is not picking up a transitive dep - trying to figure out why. Some of teh bazel repos were renamed, and kazel uses the old name, so I wonder if something is confused. Of course, godep is useless... github.com/bazelbuild/buildifier is now github.com/bazelbuild/buildtools |
Just came across this.. was taking a look at the viability of this last week! The transitive dep issue is fixed in this one: kubernetes/repo-infra#54.. repo-infra doesn't have a dependency definition file at all, just a vendor dir.. but you can't vendor a vendor dir. @thockin: Is it safer to install these utils to a temp gopath, rather than clobber whatever version is in the running user's gopath? (my WIP branch: https://github.com/kubernetes/kubernetes/compare/master...cblecker:vendor-bazel-stuff?expand=1) |
I started installing to the phony local GOPATH, but I am torn on it. It's trivial to do (1 line). The godep scripts don't do that either. Open to opinion |
Indeed, it seems that godep satisfies itself with |
Ugh, I hate GOPATH. Non-hermetic no matter what I do. Kazel only builds because of it. If I run-in-gopath, then the missing dep is satisfied from GOPATH but ONLY IF I previously ran godep-restore. I really want different GOPATHs for different purposes... |
65f8090
to
333ef1e
Compare
Agreed that GOPATH and how golang handles symlinks is pretty terrible 😞 |
Need to re-run the godep imports, out of time for tonight. |
Godeps/Godeps.json
Outdated
"Rev": "737df20c53499fd84b67f04c6ca9ccdee2e77089" | ||
}, | ||
{ | ||
"ImportPath": "github.com/bazelbuild/rules_go/go/tools/gazelle/gazelle", |
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.
note for when you revisit this: the 0.8.0 tag in bazelbuild/bazel-gazelle
is compatible with the version of gazelle we're using now, and is preferred over the gazelle in rules_go
.
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 0.8.0
, but 0.8
matches the hash.
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Install gazelle from bazelbuild/bazel-gazelle instead of rules_go **What this PR does / why we need it**: downloads gazelle from its new home; it's being removed from `bazelbuild/rules_go`. It also removes @spiffxp's workaround from a few weeks ago. **Special notes for your reviewer**: these should really be vendored (#57600), but this prevents us from running into issues in the meantime. **Release note**: ```release-note NONE ``` /approve no-issue /assign @BenTheElder
333ef1e
to
a63c889
Compare
Pushed with updated gazelle and repo-infra that satisfies godep. |
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.
I think this might finally be ready for final rebase and merge.
Note we're now using gazelle 0.10.1 in k/k. I've also ensured that the master branch of kazel now builds with the version of bazelbuild/buildtools vendored by gazelle.
hack/update-bazel.sh
Outdated
578e73e57d6a4054ef933db1553405c9284322c7 | ||
# Install tools we need, but only from vendor/... | ||
go install ./vendor/github.com/bazelbuild/bazel-gazelle/cmd/gazelle | ||
if ! which gazelle >/dev/null 2>&1; then |
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.
this seems pretty fragile - it's can be possible that $GOPATH/bin
is not in your PATH, but there might already be a gazelle installed in $PATH
anyway, which will cause this to pass unexpectedly.
Maybe instead set GOBIN="${KUBE_OUTPUT_BINPATH}"
(i.e. $KUBE_ROOT/_output/bin
) before running go install
?
this is what I did for kubernetes/test-infra#7429 and kubernetes/repo-infra#65 and it seems to be working well.
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.
Not a bad idea. I forgot we have that.
Rebased & revendored. Let's see... |
Oh, hah, verify-bazel.sh is also diffing
|
I have a feeling that the method I use in #59210 would work here. Because we install it, then record the path it was installed to for re-use, it doesn't try to do things like install it a second time into temp paths. |
/retest |
hack/verify-bazel.sh
Outdated
@@ -40,7 +40,7 @@ mkdir -p "${_tmp_kuberoot}/.." | |||
cp -a "${KUBE_ROOT}" "${_tmp_kuberoot}/.." | |||
|
|||
cd "${_tmp_kuberoot}" | |||
GOPATH="${_tmp_gopath}" ./hack/update-bazel.sh | |||
GOPATH="${_tmp_gopath}" PATH="${_tmp_gopath}/bin:${PATH}" ./hack/update-bazel.sh | |||
|
|||
diff=$(diff -Naupr "${KUBE_ROOT}" "${_tmp_kuberoot}" || true) |
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.
I think adding an exclude on _output
to the diff
should fix the remaining failure:
diff --git a/hack/verify-bazel.sh b/hack/verify-bazel.sh
index 4a110ebad0..132428fc12 100755
--- a/hack/verify-bazel.sh
+++ b/hack/verify-bazel.sh
@@ -42,7 +42,7 @@ cp -a "${KUBE_ROOT}" "${_tmp_kuberoot}/.."
cd "${_tmp_kuberoot}"
GOPATH="${_tmp_gopath}" PATH="${_tmp_gopath}/bin:${PATH}" ./hack/update-bazel.sh
-diff=$(diff -Naupr "${KUBE_ROOT}" "${_tmp_kuberoot}" || true)
+diff=$(diff -Naupr -x '_output' "${KUBE_ROOT}" "${_tmp_kuberoot}" || true)
if [[ -n "${diff}" ]]; then
echo "${diff}" >&2
w00t! it's green. |
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.
Mostly fine. One question, and one potential request for follow up.
github.com/bazelbuild/bazel-gazelle/cmd/gazelle \ | ||
0.10.1 | ||
# Ensure that we find the binaries we build before anything else. | ||
export GOBIN="${KUBE_OUTPUT_BINPATH}" |
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.
Do we need to export this? I don't like modifying a user's environment beyond the life of the script. There's a couple other cases that you're doing this too, so I'm not sure if it's strictly a requirement.
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.
export
exists for the life of the shell, not longer. Maybe I misunderstand. I did not put it in a generic place that gets sourced, for this reason.
$ echo $FOO; (export FOO=foo; echo $FOO; (export FOO=bar; echo $FOO); echo $FOO); echo $FOO
foo
bar
foo
GP="$(echo $GOPATH | cut -f1 -d:)" | ||
hash -r # force bash to clear PATH cache | ||
PATH="${GP}/bin:${PATH}" | ||
if ! which godep >/dev/null 2>&1; then |
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.
I don't like that there is inconsistency between the way we handle godep, and the way we are handling gazelle/kazel/misspell.
It's not enough of a dislike to block this PR that we badly need, but I'd really like if we could unify on a single way (maybe via a helper util function) to install a specific version of a go app from vendor, use it in the context of the script, with as little pollution of the environment as possible. Maybe I'll look at this in a follow up PR?
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 could set GOBIN in init.sh or something, and then always call $GOBIN/godep
But as long as we're checking the version of godep, it shouldn't matter. I agree it would be cleaner to be consistent. Our scripts are a mess here.
function gobin() {
echo "${KUBE_OUTPUT_BINPATH}"
}
function go_install() {
GOBIN="$(gobin)" go install "$@"
}
function run_private() {
PATH="$(gobin):${PATH}" "$@"
}
function run_global() {
"$@"
}
go_install ./vendor/github.com/tools/godep/
run_private godep save
alternatively, make teh callers of ensure_godep_version
pass the path to the godep they are using, and they can pass ${GOBIN}/godep
?
Agree it should be a followup
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cblecker, thockin 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 |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
@@ -17,6 +17,7 @@ openapi_library( | |||
"pkg/kubelet/apis/kubeletconfig/v1beta1", | |||
"pkg/proxy/apis/kubeproxyconfig/v1alpha1", | |||
"pkg/version", | |||
"vendor/github.com/kubernetes/repo-infra/kazel", |
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.
welp, the openapi generator in kazel is picking up itself, erroneously. I'll fix this.
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.
thanks
…57600-#62499-upstream-release-1.10 Automatic merge from submit-queue. Automated cherry pick of #61575: Remove all upstream BUILD, BUILD.bazel, and WORKSPACE #57600: Vendor gazelle #62499: Update kazel to include openapi tag detection fix Cherry pick of #61575 #57600 #62499 on release-1.10. #61575: Remove all upstream BUILD, BUILD.bazel, and WORKSPACE #57600: Vendor gazelle #62499: Update kazel to include openapi tag detection fix This is an alternative to #64928, and would fix #64925. We can't just cherry-pick #57600, since there was a prerequisite PR and a fixup PR afterwards.
Rather that relying on upstream git repos that can break, vendor it all. These are NOT head of tree, respectively - they are some backrev forms that were previously being used.