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

hack/bin/integration-cleanup.sh: Use jq magic instead of bash #1432

Merged
merged 5 commits into from
Apr 7, 2021

Conversation

akshaymankar
Copy link
Member

For some reason the the bash expression to calculate time fails in CI and helm
now supports outputting json, so I swapped bash magic with jq magic. It more
robust, hopefully it is also more understandable.

For some reason the the bash expression to calculate time fails in CI and helm
now supports outputting json, so I swapped bash magic with jq magic. It more
robust, hopefully it is also more understandable.
Copy link
Contributor

@lucendio lucendio left a comment

Choose a reason for hiding this comment

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

LGTM

)
| select ( .parsedTime < (now - 3 * 60 * 60))
| [.name, .namespace]
| @tsv
Copy link
Contributor

Choose a reason for hiding this comment

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

question: why tabs?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think jq can either output a json array, a csv or a tsv. Out of these I thought tsv was the most compatible with bash as I can awk '{print $1}'. Do you have a better idea?

Copy link
Contributor

Choose a reason for hiding this comment

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

I just stumbled upon it and was curious, as FS usually defaults to space.

date_s=$(date_seconds "$date_str")
diff=$(( $date_now - $date_s ))
if [ $diff -ge 7200 ]; then
echo "test release '$name' older than 2 hours; deleting..."
Copy link
Contributor

Choose a reason for hiding this comment

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

wanna keep that echo statement in some modified form?

Copy link
Member

@jschaul jschaul left a comment

Choose a reason for hiding this comment

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

There were some problems with the script still

  • it errors if releases is an empty string:
./hack/bin/integration-cleanup.sh
test release '' older than 2 hours; deleting...
Error: uninstall: Release name is invalid: 

I added a commit which should fix that.

@akshaymankar
Copy link
Member Author

The tests are failing because this incorrectly deletes releases deployed less than 2 hours ago, I will look into that.

@akshaymankar
Copy link
Member Author

Maybe I was a fool to assume jq is safer than bash 😢 c225f41

@jschaul
Copy link
Member

jschaul commented Apr 7, 2021

All green now, it seems!

@akshaymankar akshaymankar merged commit d93e256 into develop Apr 7, 2021
@akshaymankar akshaymankar deleted the akshaymankar/fix-cleanup branch April 7, 2021 11:15
This was referenced May 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants