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

Fix install_kustomize.sh #5190

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

bewing
Copy link

@bewing bewing commented Jun 5, 2023

Github recently changed their API to sometimes remove whitespace from JSON responses. This commit updates the find_release_url bash function to use grep's --only-matching option to return just the browser_download_url keys and values regardless of whitespace.

I was able to test the regex against old and new by passing the JSON document through jq first:

$ curl -s --header "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/kubernetes-sigs/kustomize/releases | grep -o '"browser_download_url":[[:space:]]*"[^" ]\+linux_amd64
[^" ]\+' | cut -d '"' -f 4 | sort -V
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.4/kustomize_v4.5.4_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.5/kustomize_v4.5.5_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.6/kustomize_v4.5.6_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.7/kustomize_v4.5.7_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.0/kustomize_v5.0.0_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.1/kustomize_v5.0.1_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.2/kustomize_v5.0.2_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.3/kustomize_v5.0.3_linux_amd64.tar.gz

$ curl -s --header "Authorization: Bearer $GITHUB_TOKEN" https://api.github.com/repos/kubernetes-sigs/kustomize/releases | jq . | grep -o '"browser_download_url":[[:space:]]*"[^" ]\+linu
x_amd64[^" ]\+' | cut -d '"' -f 4 | sort -V
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.4/kustomize_v4.5.4_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.5/kustomize_v4.5.5_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.6/kustomize_v4.5.6_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v4.5.7/kustomize_v4.5.7_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.0/kustomize_v5.0.0_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.1/kustomize_v5.0.1_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.2/kustomize_v5.0.2_linux_amd64.tar.gz
https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/v5.0.3/kustomize_v5.0.3_linux_amd64.tar.gz

closes #4769

@k8s-ci-robot k8s-ci-robot added do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jun 5, 2023
@k8s-ci-robot
Copy link
Contributor

Welcome @bewing!

It looks like this is your first PR to kubernetes-sigs/kustomize 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/kustomize has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Jun 5, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @bewing. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 5, 2023
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Jun 5, 2023
@bewing bewing force-pushed the install_fix branch 2 times, most recently from b5e9c16 to 3cd15fa Compare June 5, 2023 21:40
@bewing bewing changed the title fix install_kustomize.sh Fix install_kustomize.sh Jun 5, 2023
Copy link

@oxr463 oxr463 left a comment

Choose a reason for hiding this comment

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

Works on my end:

/bin/bash ./hack/install_kustomize.sh
v5.0.3
kustomize installed to /home/oxr463/src/kustomize/kustomize

Copy link

@Aisuko Aisuko left a comment

Choose a reason for hiding this comment

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

approved

@Aisuko
Copy link

Aisuko commented Jun 30, 2023

I have tested it too. It works for me.

@Aisuko ➜ /workspaces/kustomize (install_fix) $ /bin/bash ./hack/install_kustomize.sh
v5.1.0
kustomize installed to /workspaces/kustomize/kustomize

@Aisuko
Copy link

Aisuko commented Jun 30, 2023

/assign

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 20, 2024
@oxr463
Copy link

oxr463 commented Jan 20, 2024

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 20, 2024
@antoooks
Copy link
Contributor

Thanks for your kontribution @bewing !

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 31, 2024
Github recently changed their API to remove whitespace from JSON
responses.  This commit updates the find_release_url bash function to
use grep's --only-matching option to return just the
browser_download_url keys and values regardless of whitespace.
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: Aisuko, bewing, oxr463
Once this PR has been reviewed and has the lgtm label, please assign varshaprasad96 for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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

@bewing
Copy link
Author

bewing commented Mar 31, 2024

@ncapps or @KnVerey can I get a review of this PR?

@ncapps
Copy link
Contributor

ncapps commented Apr 2, 2024

Hi,

Thank you for your contribution. I am not able to reproduce the issue described in #4769.

The install_kustomize.sh script appears to be installing the correct kustomize version on my machine. I am using the zsh shell.

zsh --version
zsh 5.9 (x86_64-apple-darwin23.0)

grep --version
grep (BSD grep, GNU compatible) 2.6.0-FreeBSD
# Install kustomize version 5.3.0 in tmp directory
$ ./hack/install_kustomize.sh 5.3.0 tmp
v5.3.0
kustomize installed to /Users/nick/go/src/github.com/ncapps/kustomize/tmp/kustomize

# Verify kustomize 5.3.0 is installed
$ tmp/kustomize version
v5.3.0

# Install kustomize version 5.2.1 in tmp directory
$ ./hack/install_kustomize.sh 5.2.1 tmp
v5.2.1
kustomize installed to /Users/nick/go/src/github.com/ncapps/kustomize/tmp/kustomize

# Verify kustomize 5.2.1 is installed
$ tmp/kustomize version             
v5.2.1

@bewing
Copy link
Author

bewing commented Apr 2, 2024

I'm still seeing single-line output from the Github API in my location (Chicago, IL)

$ dig AAAA +short github.com
$ dig +short github.com
140.82.114.3

$ curl -s https://api.github.com/repos/kubernetes-sigs/kustomize/releases | wc -l
0


$ hack/install_kustomize.sh
tar (child): ./kustomize_v*_linux_amd64.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

hack/install_kustomize.sh fails intermittently
7 participants