Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function populate_artifact_dir() {
echo "Copying log bundle..."

current_time=$(date +%s)
cp "${dir}"/log-bundle-*.tar.gz "${ARTIFACT_DIR}/" 2>/dev/null
tar -xzf "${dir}"/log-bundle-*.tar.gz -C "${ARTIFACT_DIR}/" 2>/dev/null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="ci-operator/step-registry/ipi/install/install/ipi-install-install-commands.sh"

# Show shell header and around the target line, plus any log-bundle handling
echo "== File header =="
sed -n '1,80p' "$FILE" | nl -ba | sed 's/^/LINE /'

echo
echo "== log-bundle occurrences (with context) =="
rg -n "log-bundle" "$FILE" || true

echo
echo "== Around line 111 =="
sed -n '90,140p' "$FILE" | nl -ba | sed 's/^/LINE /'

Repository: openshift/release

Length of output: 140


🏁 Script executed:

#!/bin/bash
set -euo pipefail

# tar behavior experiment: simulate wildcard expansion into multiple archives
set -euo pipefail
tmp=$(mktemp -d)
echo "tmp=$tmp"
src="$tmp/src"
mkdir -p "$src"
dest="$tmp/dest"
mkdir -p "$dest"

# Create two distinct tar.gz archives
mkdir -p "$src/a" "$src/b"
echo "from a" > "$src/a/file-a.txt"
echo "from b" > "$src/b/file-b.txt"

# Need GNU tar to create .tar.gz
tar -czf "$tmp/log-bundle-1.tar.gz" -C "$src/a" file-a.txt
tar -czf "$tmp/log-bundle-2.tar.gz" -C "$src/b" file-b.txt

echo "== Extract using wildcard-expanded multi-archive argument (matches original pattern) =="
rm -rf "$dest"/*
# This replicates: tar -xzf "${dir}"/log-bundle-*.tar.gz -C "${ARTIFACT_DIR}/"
# where the glob expands to multiple .tar.gz paths.
tar -xzf "$tmp"/log-bundle-*.tar.gz -C "$dest" 2>&1 | head -n 50 || true

echo "Extracted files:"
find "$dest" -maxdepth 2 -type f -print | sed 's/^/ - /'
echo "Contents:"
for f in $(find "$dest" -type f | sort); do
  echo "---- $f"
  cat "$f"
done

echo
echo "== Extract using loop over each archive (proposed fix) =="
rm -rf "$dest"/*
for bundle in "$tmp"/log-bundle-*.tar.gz; do
  tar -xzf "$bundle" -C "$dest" 2>/dev/null
done
echo "Extracted files:"
find "$dest" -maxdepth 2 -type f -print | sed 's/^/ - /'

Repository: openshift/release

Length of output: 477


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "tar version:"
tar --version 2>/dev/null | head -n 5 || true

Repository: openshift/release

Length of output: 344


🌐 Web query:

GNU tar: behavior when extracting with -f and multiple archive filenames on command line treated as members

💡 Result:

In GNU tar, the -f (or --file) option is used to specify the archive file or device to operate on [1][2][3]. When you provide multiple -f options on the command line, GNU tar interprets them as successive volumes of a single multi-volume archive, not as multiple separate archives to extract simultaneously [1][4][5]. When extracting with -f, any arguments appearing on the command line that are not options (i.e., non-option arguments) are treated by GNU tar as the names of archive members to be extracted from that archive [6][7][8][9]. If no member names are provided as non-option arguments, GNU tar performs the operation on the entire contents of the archive [6][7]. In summary: - Multiple -f options: These define a sequence of volumes for a single multi-volume archive [1][4][5]. - Non-option arguments after -f: These are treated as the specific files (members) within that archive to act upon [6][7][9]. If you intend to extract from multiple distinct archive files, you must run separate tar commands for each archive, as GNU tar does not support extracting from multiple independent archive files in a single invocation [1][10]. Attempting to provide multiple filenames as arguments to a single -f option (e.g., tar -x -f archive1.tar archive2.tar) would result in tar treating 'archive2.tar' as an archive member name to look for inside 'archive1.tar', rather than as a separate archive file [6][7][3].

Citations:


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="ci-operator/step-registry/ipi/install/install/ipi-install-install-commands.sh"

echo "== Shebang/top 40 lines =="
sed -n '1,40p' "$FILE" | cat -n

echo
echo "== log-bundle related lines (near occurrences) =="
rg -n "log-bundle" "$FILE"

echo
echo "== Around line 100-130 (with line numbers) =="
awk 'NR>=90 && NR<=130 {printf "%4d: %s\n", NR, $0}' "$FILE"

Repository: openshift/release

Length of output: 4768


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="ci-operator/step-registry/ipi/install/install/ipi-install-install-commands.sh"
echo "== Around log-bundle workaround (240-320) =="
sed -n '240,320p' "$FILE" | nl -ba | sed 's/^/LINE /'

Repository: openshift/release

Length of output: 167


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="ci-operator/step-registry/ipi/install/install/ipi-install-install-commands.sh"
awk 'NR>=240 && NR<=320 {printf "%4d: %s\n", NR, $0}' "$FILE"

Repository: openshift/release

Length of output: 4408


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="ci-operator/step-registry/ipi/install/install/ipi-install-install-commands.sh"

echo "== log-bundle in this file =="
rg -n "log-bundle" "$FILE"

echo
echo "== Other occurrences repo-wide (limited) =="
rg -n "log-bundle-\\*\\.tar\\.gz" . -S || true

echo
echo "== Any creation of log bundles (tar -czf + log-bundle) repo-wide (limited) =="
rg -n "tar\\s+-c[^\\n]*log-bundle" . -S || true

echo
echo "== Any deletion/cleanup of log bundle archives repo-wide (limited) =="
rg -n "rm\\s+-f[^\\n]*log-bundle|rm\\s+-r[^\\n]*log-bundle" . -S || true

Repository: openshift/release

Length of output: 6274


🏁 Script executed:

#!/bin/bash
set -euo pipefail
FILE="ci-operator/step-registry/ipi/install/install/ipi-install-install-commands.sh"
rg -n "nullglob|shopt" "$FILE" || true

Repository: openshift/release

Length of output: 43


Fix log-bundle extraction when the glob matches multiple archives

At line 111, tar -xzf "${dir}"/log-bundle-*.tar.gz ... fails when the glob expands to more than one log-bundle-*.tar.gz (GNU tar treats the extra filenames as members of the first archive), so additional log bundles won’t be extracted into ${ARTIFACT_DIR}.

Suggested fix
-  tar -xzf "${dir}"/log-bundle-*.tar.gz -C "${ARTIFACT_DIR}/" 2>/dev/null
+  shopt -s nullglob
+  for bundle in "${dir}"/log-bundle-*.tar.gz; do
+    tar -xzf "${bundle}" -C "${ARTIFACT_DIR}/" 2>/dev/null
+  done
+  shopt -u nullglob
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
tar -xzf "${dir}"/log-bundle-*.tar.gz -C "${ARTIFACT_DIR}/" 2>/dev/null
shopt -s nullglob
for bundle in "${dir}"/log-bundle-*.tar.gz; do
tar -xzf "${bundle}" -C "${ARTIFACT_DIR}/" 2>/dev/null
done
shopt -u nullglob
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@ci-operator/step-registry/ipi/install/install/ipi-install-install-commands.sh`
at line 111, The single tar invocation using the glob
"${dir}"/log-bundle-*.tar.gz fails when the glob matches multiple archives;
replace that single command with logic that iterates over each matching file and
extracts them individually into "${ARTIFACT_DIR}" (i.e., for each file matching
"${dir}"/log-bundle-*.tar.gz, skip if no match, and run tar -xzf on that file
with -C "${ARTIFACT_DIR}" redirecting stderr as before) so each archive is
unpacked separately.

echo "Removing REDACTED info from log..."
sed '
s/password: .*/password: REDACTED/;
Expand Down