-
Notifications
You must be signed in to change notification settings - Fork 10
Fix empty gather logs due to script crash #33
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
Merged
jannfis
merged 8 commits into
redhat-developer:main
from
olivergondza:fix-eventually-empty-process-substitutions
Sep 4, 2025
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f8b55e4
fix(gather_gitops.sh): Unquote process substitutions delivering lists
olivergondza 976cbbe
fix(gather_gitops.sh): Replace process substitutions delivering lists…
olivergondza d617636
fix(gather_gitops.sh): Silent shellcheck false positive
olivergondza 25ff78f
fix(gather_gitops.sh): Fix receiving gitopsservices.pipelines.openshi…
olivergondza d8e1000
feat(test/compare.sh): Add verification
olivergondza 272f170
feat(test/compare.sh): Shellcheck
olivergondza 490ce44
feat(gather_gitops.sh): Do not issue errors when gitops not installed
olivergondza 85ba013
fix(gather_gitops.sh): Handle no csv,sub,ip explicitly
olivergondza File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #!/usr/bin/env bash | ||
| # https://github.com/olivergondza/bash-strict-mode | ||
| set -eEuo pipefail | ||
| s=declare_out_of_trap_script # Workaround for https://github.com/koalaman/shellcheck/issues/3287 | ||
| trap 's=$?; echo >&2 "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR | ||
|
|
||
| function main() { | ||
| if [[ $# -ne 2 ]]; then | ||
| echo >&2 "Usage: $0 [IMAGE_A] [IMAGE_B]" | ||
| exit 1 | ||
| fi | ||
| local img_a=$1 | ||
| local img_b=$2 | ||
|
|
||
| inv_a="$(mktemp -d gitops-must-gather-A-XXXX)" | ||
| inv_b="$(mktemp -d gitops-must-gather-B-XXXX)" | ||
| trap 'rm -rf "${inv_a}" "${inv_b}"' EXIT | ||
|
|
||
| gather "$img_a" "$inv_a" | ||
| gather "$img_b" "$inv_b" | ||
|
|
||
| diff --color=auto --recursive \ | ||
| --ignore-matching-lines="resourceVersion: " \ | ||
| "${inv_a}" "${inv_b}" | ||
| } | ||
|
|
||
| function gather() { | ||
| image=$1 | ||
| dir=$2 | ||
|
|
||
| if ! oc adm must-gather --image="$image" --dest-dir="${dir}" 2>&1 | tee "${dir}/oc-adm-output.log"; then | ||
| echo >&2 "Failed gathering for $image" | ||
| return 1 | ||
| fi | ||
|
|
||
| sanitize "$image" "$dir" | ||
| } | ||
|
|
||
| function sanitize() { | ||
| image=$1 | ||
| dir=$2 | ||
|
|
||
| # Unify names of the directories its name is based on image name | ||
| mv "$dir"/*-sha256-* "$dir/__RESOURCES__" | ||
|
|
||
| # In log files, drop image name, generated resource names, timestamp, line numbers, and transfer metrics | ||
| sed -i -r \ | ||
| -e "s~${image}~__IMAGE_TAG__~g" \ | ||
| -e "s~must-gather-[a-z0-9]{5}~must-gather-XXXXX~g" \ | ||
| -e 's~[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+Z~__TIMESTAMP__~g' \ | ||
| -e 's~gather_gitops:[0-9]+~gather_gitops:LL~g' \ | ||
| -e '/total size is .* speedup is .*/d' \ | ||
| -e '/sent .* received .* bytes\/sec/d' \ | ||
| "$dir/oc-adm-output.log" "$dir/must-gather.logs" "$dir/__RESOURCES__/gather.logs" "$dir/__RESOURCES__/gather_gitops.log" | ||
|
|
||
| # Timestamps are not going to match, just test there is the same number of them | ||
| ts="$(wc -l < "$dir/timestamp")" | ||
| echo "$ts" > "$dir/timestamp" | ||
| ts="$(wc -l < "$dir/__RESOURCES__/timestamp")" | ||
| echo "$ts" > "$dir/__RESOURCES__/timestamp" | ||
| } | ||
|
|
||
| main "$@" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 not work since #23.