Skip to content

Conversation

pjh
Copy link
Contributor

@pjh pjh commented Apr 8, 2019

gsutil and gcloud are not in the same directory on my system and I don't see why they should have to be. This PR searches for gcloud both in the gsutil directory as well as wherever in the user's PATH it might be.

I've tested that this works on my own system and I think it shouldn't break any existing uses but hopefully reviewers with more bash experience can confirm (or tell me how to test).

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. area/release-eng Issues or PRs related to the Release Engineering subproject sig/release Categorizes an issue or PR as relevant to SIG Release. labels Apr 8, 2019
@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 8, 2019
@pjh
Copy link
Contributor Author

pjh commented Apr 8, 2019

/cc mtaufen

@k8s-ci-robot k8s-ci-robot requested a review from mtaufen April 8, 2019 19:21
lib/common.sh Outdated
# gcloud should be in the same place
GCLOUD=${GSUTIL/gsutil/gcloud}
for GCLOUD in "$GSUTIL/gsutil/gcloud" "$(which gcloud)"; do
[[ -x $GCLOUD ]] && break
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make this an if statement instead of the && shorthand?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@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 Apr 10, 2019
@mtaufen
Copy link
Contributor

mtaufen commented Apr 11, 2019

/lgtm

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

@dougm dougm left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dougm, mtaufen, pjh

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 Apr 15, 2019
@k8s-ci-robot k8s-ci-robot merged commit 69c23a9 into kubernetes:master Apr 15, 2019
@tpepper
Copy link

tpepper commented Apr 16, 2019

Multiple of us have this patched code working fine, but it seems like when it runs in GCloud it fails? @Bubblemelon and I both have a failure on what might be this change when we "gcbmbr stage master":

Step #1: Status: Downloaded newer image for gcr.io/kubernetes-release-test/k8s-cloud-builder:latest
Step #1: 
Step #1: anago: BEGIN main on 516e17c621c3 Tue Apr 16 17:03:11 UTC 2019
Step #1: 
Step #1: 
Step #1: ================================================================================
Step #1: WORKFLOW STEPS
Step #1: ================================================================================
Step #1: 
Step #1: ☐ 1 CHECK PREREQUISITES
Step #1: ☐ 2 SET BUILD CANDIDATE
Step #1: ☐ 3 PREPARE WORKSPACE
Step #1: ☐ 4 DISK SPACE CHECK
Step #1: ☐ 5 PREPARE AND TAG TREE
Step #1: ☐ 6 TAG/BUILD LOCAL KUBE CROSS
Step #1: 
Step #1: Checking/setting cloud tools: FAILED
Step #1: Releasing Kubernetes requires gsutil and gcloud. Please download,
Step #1: install and authorize through the Google Cloud SDK:
Step #1: 
Step #1: https://developers.google.com/cloud/sdk/
Step #1: 
Step #1: Exiting...
Step #1: 
Step #1: 
Step #1: anago: DONE main on 516e17c621c3 Tue Apr 16 17:03:11 UTC 2019 in 0s
Finished Step #1
ERROR
ERROR: build step 1 "gcr.io/kubernetes-release-test/k8s-cloud-builder" failed: exit status 1

@pjh
Copy link
Contributor Author

pjh commented Apr 16, 2019

Sorry for the breakage. I don't know why the script is failing to find gsutil and gcloud when run inside of the gcr.io/kubernetes-release-test/k8s-cloud-builder container. Tracking that down will either require rebuilding the container with some additional debug logging in the script, or exec'ing into the container and running the script manually with additional debug logging.

cherylfong on Slack has graciously offered to take a quick look at this. If that fails then I've sent #698 to rollback this change.

@calebamiles
Copy link
Contributor

@pjh. Please revert this change. The only context that really maters here is when this tooling is executed within GCB, the particulars of an arbitrary development machine should not be considered here.

@pjh
Copy link
Contributor Author

pjh commented Apr 16, 2019

The rollback has been merged: #698.

done

# gcloud should be in the same place
GCLOUD=${GSUTIL/gsutil/gcloud}
for GCLOUD in "${GSUTIL}/gsutil/gcloud" "$(which gcloud)"; do
Copy link

Choose a reason for hiding this comment

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

This is different in meaning because in the original code, ${GSUTIL/gsutil/gcloud}is doing a pattern substitution (brace expansion). In your change you are treating the slashes as path delimiters in a filesystem. So the first value in the list won't be executable (it most likely doesn't exist). And in the Docker container the path to gcloud is probably not in the PATH, so the second command probably fails too ("which" will fail).

That's probably why it broke in the container, is my guess.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

${GSUTIL/gsutil/gcloud}is doing a pattern substitution (brace expansion)

Wow, yeah I totally overlooked that. My fault for changing it without understanding its effects, but I had no idea bash could do pattern substitution in this manner, and just assumed that was a path.

Thanks for the explanation.

@listx
Copy link

listx commented Apr 19, 2019

Oops, looks like you already fixed this in #705. Sorry for the noise.

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. area/release-eng Issues or PRs related to the Release Engineering subproject 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. sig/release Categorizes an issue or PR as relevant to SIG Release. 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.

7 participants