-
Notifications
You must be signed in to change notification settings - Fork 38.9k
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
Godep scripts cleanup #51766
Godep scripts cleanup #51766
Conversation
Adding do-not-merge/release-note-label-needed because the release note process has not been followed. |
c848ea5
to
f210a97
Compare
Godeps/Godeps.json
Outdated
@@ -1,11 +1,12 @@ | |||
{ | |||
"ImportPath": "k8s.io/kubernetes", | |||
"GoVersion": "go1.8", | |||
"GoVersion": "go1.9", |
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.
Are you running this locally? Master hasn't moved to go1.9 yet.
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.
blarch, will revert that part :)
Godeps/Godeps.json
Outdated
@@ -843,12 +844,12 @@ | |||
}, | |||
{ | |||
"ImportPath": "github.com/docker/distribution/digest", | |||
"Comment": "v2.4.0-rc.1-38-gcd27f17", | |||
"Comment": "v2.4.0-rc.1-38-gcd27f179", |
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 is the other reason to run godep in containers.. different git versions provided slightly different strings 😞 . Is this your local env, or inside a container?
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.
local. The problem with doing this in containers is that some envs (jenkins) are already containerized, and we end up with a tangle of "is this already in a container? call a different script" sort of hacks. I want to move this forward as "it works locally, where locally can be in-a-container or not" as the general MO. Running this inside a container requires YET ANOTHER script to avoid rsyncing over the state in between steps.
hack/godep-restore.sh
Outdated
kube::util::ensure_godep_version | ||
|
||
kube::log::status "Downloading dependencies - this might take a while" | ||
GOPATH="${GOPATH}:$(pwd)/staging" godep restore "$@" |
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.
Is there a reason you're using pwd over KUBE_ROOT?
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.
From an earlier rev. Will fix
GOPATH="${KUBE_TEMP}/go" go install . | ||
popd >/dev/null | ||
kube::log::status "Installing godep version ${GODEP_VERSION}" | ||
go install ./vendor/github.com/tools/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 like this solution :)
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.
there are others that can do the same - gazelle and kazel popped up. Later.
Cross build is broken: #51815 |
f210a97
to
9860e5d
Compare
hack/godep-save.sh
Outdated
echo "- hack/update-bazel.sh to recreate the BUILD files" | ||
echo "- hack/update-godep-licenses.sh if you added or removed a dependency!" | ||
kube::log::status "Running godep save - this might take a while" | ||
GOPATH="${GOPATH}:$(pwd)/staging" godep save "${REQUIRED_BINS[@]}" |
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.
KUBE_ROOT here instead of pwd?
This looks pretty good. Pulling down and testing locally. |
9860e5d
to
57bc9ca
Compare
Noticed #51819 while testing |
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.
Okay, kicked the tires on this in a bunch of ways, and it looks pretty solid. Couple things, then lgtm:
hack/godep-save.sh
Outdated
@@ -22,40 +22,65 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. | |||
source "${KUBE_ROOT}/hack/lib/init.sh" | |||
source "${KUBE_ROOT}/hack/lib/util.sh" | |||
|
|||
TMPPFX="_godep_tmp." |
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.
Suggested patch:
diff --git a/hack/godep-save.sh b/hack/godep-save.sh
index 3c04e341ab..400bdd0232 100755
--- a/hack/godep-save.sh
+++ b/hack/godep-save.sh
@@ -22,34 +22,35 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"
source "${KUBE_ROOT}/hack/lib/util.sh"
-TMPPFX="_godep_tmp."
-
kube::log::status "Ensuring prereqs"
kube::util::ensure_single_dir_gopath
kube::util::ensure_no_staging_repos_in_gopath
-
kube::util::ensure_godep_version
+kube::util::ensure-temp-dir
+
+GODEP_TMPPFX="${KUBE_TEMP}/_godep_tmp."
+
-function cleanup() {
- if [[ -d "${TMPPFX}vendor" ]]; then
- kube::log::error "${TMPPFX}vendor exists, restoring it"
+function kube::godep::cleanup() {
+ if [[ -d "${GODEP_TMPPFX}vendor" ]]; then
+ kube::log::error "${GODEP_TMPPFX}vendor exists, restoring it"
rm -rf vendor
- mv "${TMPPFX}vendor" vendor
+ mv "${GODEP_TMPPFX}vendor" vendor
fi
- if [[ -d "${TMPPFX}Godeps" ]]; then
- kube::log::error "${TMPPFX}Godeps exists, restoring it"
+ if [[ -d "${GODEP_TMPPFX}Godeps" ]]; then
+ kube::log::error "${GODEP_TMPPFX}Godeps exists, restoring it"
rm -rf Godeps
- mv "${TMPPFX}Godeps" Godeps
+ mv "${GODEP_TMPPFX}Godeps" Godeps
fi
}
-trap cleanup EXIT
+kube::util::trap_add kube::godep::cleanup EXIT
# Clear old state, but save it in case of error
if [[ -d vendor ]]; then
- mv vendor "${TMPPFX}vendor"
+ mv vendor "${GODEP_TMPPFX}vendor"
fi
if [[ -d Godeps ]]; then
- mv Godeps "${TMPPFX}Godeps"
+ mv Godeps "${GODEP_TMPPFX}Godeps"
fi
# Some things we want in godeps aren't code dependencies, so ./...
@@ -83,4 +84,4 @@ kube::log::status "Updating LICENSES file"
hack/update-godep-licenses.sh >/dev/null
# Clean up
-rm -rf "${TMPPFX}vendor" "${TMPPFX}Godeps"
+rm -rf "${GODEP_TMPPFX}vendor" "${GODEP_TMPPFX}Godeps"
diff --git a/hack/lib/util.sh b/hack/lib/util.sh
index 2b832335f1..4ddc7bbf99 100755
--- a/hack/lib/util.sh
+++ b/hack/lib/util.sh
@@ -85,7 +85,7 @@ kube::util::trap_add() {
if [[ -z "${existing_cmd}" ]]; then
new_cmd="${trap_add_cmd}"
else
- new_cmd="${existing_cmd};${trap_add_cmd}"
+ new_cmd="${trap_add_cmd};${existing_cmd}"
fi
# Assign the test
What this does:
- Uses ensure-temp-dir to create a system temp directory that gets cleaned up, out of tree (so that _godep_tmp dirs don't get left behind)
- Uses a more specific variable name
- Fixes ordering in the trap_add function so that more recently added traps will get completed first (such as restoring the vendor dir before the temp dir is cleaned up)
WDYT?
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.
KUBE_TEMP is not guaranteed to be on the same device, which could turn the mv
into a slow cp
. We could instead do _output/local/tmp/$RANDOM or something, if you feel strongly.
Will apply parts of your patch and we can discuss the rest. PTAL
Godeps/Godeps.json
Outdated
@@ -2281,7 +2292,7 @@ | |||
}, | |||
{ | |||
"ImportPath": "github.com/pmezard/go-difflib/difflib", | |||
"Rev": "d8ed2627bdf02c080bf22230dbb337003b7aba2d" | |||
"Rev": "f78a839676152fd9f4863704f5d516195c18fc14" |
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 change requires a hack/update-staging-godeps.sh
run on it to pick up in the staging repos too.
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.
Good point, Maybe I should undo this. This is where godep kind of stinks. Which is a better choice?
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.
There's no effective change between the two commits, so ¯_(ツ)_/¯:
https://github.com/pmezard/go-difflib/compare/f78a839676152fd9f4863704f5d516195c18fc14...d8ed2627bdf02c080bf22230dbb337003b7aba2d?expand=1
57bc9ca
to
3f3c129
Compare
hack/godep-save.sh
Outdated
@@ -22,40 +22,65 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/.. | |||
source "${KUBE_ROOT}/hack/lib/init.sh" | |||
source "${KUBE_ROOT}/hack/lib/util.sh" | |||
|
|||
GODEP_TMPPFX="_godep_save__tmp." |
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.
The other option here would be:
mkdir -p "${KUBE_ROOT}/_tmp/"
GODEP_TMPPFX="${KUBE_ROOT}/_tmp/_godep_save__tmp."
This would work too as /_tmp/
is in .gitignore and isn't rsync'd, but would be in tree so it would be on the same device.
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.
Does anything clean up _tmp ? is _output/local/tmp better or worse? Is that rsynced?
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'm not aware of anything that cleans up _tmp.
I think either of them would work, as the two are treated similarly by gitignore and rsync. The only folder that is touched by rsync is _output/dockerized/bin, and it's copied to _output/bin. _output is also used by the build-image and generating the release files.
_tmp on the other hand is used by doc generation, by jenkins, and by the godep-licences script:
kubernetes/hack/verify-godep-licenses.sh
Lines 31 to 41 in 44c5182
# create a nice clean place to put our new godeps | |
# must be in the user dir (e.g. KUBE_ROOT) in order for the docker volume mount | |
# to work with docker-machine on macs | |
mkdir -p "${KUBE_ROOT}/_tmp" | |
_tmpdir="$(mktemp -d "${KUBE_ROOT}/_tmp/kube-godep-licenses.XXXXXX")" | |
#echo "Created workspace: ${_tmpdir}" | |
function cleanup { | |
#echo "Removing workspace: ${_tmpdir}" | |
rm -rf "${_tmpdir}" | |
} | |
trap cleanup EXIT |
based on that, _tmp seems like the right candidate. also looks like some cleanup could be done in that verify script to match this one (but that could also be a separate 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.
pushed now with _tmp. We should probably add that to make clean
though.
Hmm.. this didn't happen for me locally. Going to clear out my gopath and try again:
That looks to be from adding godep to Godeps |
indeed. Let me pull off the last commit, we can deal with that on its own. It looks like godep is utterly failing to handle this. Surprise. |
3f3c129
to
4e02d0d
Compare
oh, this was my fault. I manually fixed one rev, but missed the other from the same repo. |
cee1a19
to
461284f
Compare
|
461284f
to
5d60eac
Compare
had to revert one |
"./..." | ||
) | ||
|
||
pushd "${KUBE_ROOT}" > /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.
Oh! I think that's because previously we were pushd'ing into KUBE_ROOT before start. We still used KUBE_ROOT in the original save command below.
5d60eac
to
9d292d7
Compare
@cblecker any clues on what was up in your env? |
74692de
to
52c62ac
Compare
@cblecker Now that 1.8 is locked and loaded, I'd like to get this in and see if it really hurts anyone besides you :) |
@thockin Sorry, day job has been getting in the way. I'll take another stab at it |
/retest bitbucket gave a 404. nice. |
hack/godep-save.sh
Outdated
exit 1 | ||
kube::util::ensure_godep_version | ||
|
||
TMPDIR=_tmp/godep-save.$RANDOM |
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.
Okay! Thanks for your patience @thockin. Debugged this, and the issue for me is the naming of this variable. Darwin uses TMPDIR
as a system ENVVAR. When this got to the updating bazel step, the kube::util::go_install_from_commit
function uses the system TMPDIR and everything blows up. If you rename this to something script-specific (e.g. TMPGODEPDIR
in my testing) then everything seems to run just fine.
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.
DONE!
52c62ac
to
ac4ffb1
Compare
/retest |
1 similar comment
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cblecker, thockin Associated issue: 44873 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest Review the full test history for this PR. |
/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. |
Automatic merge from submit-queue. Rewrite docs on godep This corresponds to kubernetes/kubernetes#51766 - do not merge until we get confirmation on that PR.
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>. Fix installation and use of vendored godep **What this PR does / why we need it**: Fixes the installation of the vendored godep to ensure that the binary ends up in the path when it's done. **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes #58975 **Special notes for your reviewer**: It looks like this broke in #51766, but didn't matter because our pinned version was the same as the latest version (so we didn't notice). This fixes it in my local env -- hopefully it will in CI too. **Release note**: ```release-note NONE ```
Another try at sanitizing godep scripts. Instead of messing with containers, or assuming anything about GOPATHs, let's just work with whatever GOPATH we are given. If you want sane godep/restore behavior you can use
./hack/run-in-gopath.sh ./hack/godep-restore.sh
. This will restore into your _output dir. You can update deps yourself, and then run./hack/run-in-gopath.sh ./hack/godep-save.sh
.xref #44873
This also checks out godep into your working GOPATH. Without this, we have to
go get
it every time. We should just vendor it.