Skip to content

Comments

Add kit directory validation during installation#352

Closed
sayalibhavsar wants to merge 1 commit intoredhat-performance:mainfrom
sayalibhavsar:gh-323
Closed

Add kit directory validation during installation#352
sayalibhavsar wants to merge 1 commit intoredhat-performance:mainfrom
sayalibhavsar:gh-323

Conversation

@sayalibhavsar
Copy link
Contributor

Description

This PR adds inline validation to install.sh that checks for missing kit files/directories specified in config templates and displays clear warnings during installation.

Before/After Comparison

Before: Installation completed silently even if required kits were missing, causing wrappers to fail later without clear indication why.
After: Installation displays a formatted warning listing all missing kits with their paths and guidance on how to resolve the issue.

Documentation Check

No documentation updates needed as this is a non-blocking warning feature that enhances existing installation behavior without changing user workflows.

Clerical Stuff

This closes #323
Relates to JIRA: RPOPC-700

@qodo-code-review
Copy link

Review Summary by Qodo

Add kit directory validation during installation

✨ Enhancement

Grey Divider

Walkthroughs

Description
• Adds inline validation to check for missing kit directories during installation
• Parses template files to extract upload_extra paths using yq
• Displays formatted warning with missing kit locations and resolution guidance
• Handles both array and string formats for upload_extra configuration
Diagram
flowchart LR
  A["Installation Complete"] --> B["Parse Config Templates"]
  B --> C["Extract upload_extra Paths"]
  C --> D["Check Path Existence"]
  D --> E{Missing Kits?}
  E -->|Yes| F["Display Formatted Warning"]
  E -->|No| G["Continue"]
  F --> G
Loading

Grey Divider

File Changes

1. bin/install.sh ✨ Enhancement +70/-0

Add kit directory validation with warning display

• Added kit directory validation logic after installation record is written
• Iterates through all template files in config directory matching pattern *_template.yml
• Extracts upload_extra field from each template using yq, handling both array and string formats
• Collects missing kit paths and displays comprehensive warning with template names, paths, and
 resolution guidance

bin/install.sh


Grey Divider

Qodo Logo

@qodo-code-review
Copy link

qodo-code-review bot commented Feb 24, 2026

Code Review by Qodo

🐞 Bugs (3) 📘 Rule violations (1) 📎 Requirement gaps (1)

Grey Divider


Action required

1. /home/uploads check missing 📎 Requirement gap ⛯ Reliability
Description
The installer changes add kit-path validation but do not check whether /home/uploads exists or
emit the required non-blocking warning message. This fails the required installer visibility
behavior when /home/uploads is missing.
Code

bin/install.sh[R212-280]

+# Validate kit directories specified in templates
+echo ""
+echo "Validating kit directories..."
+
+missing_kits=()
+config_dir=$(readlink -f "config")
+
+for template_file in config/*_template.yml; do
+    # Skip if no files match the pattern
+    [ -e "$template_file" ] || continue
+
+    template_name=$(basename "$template_file")
+
+    # Extract upload_extra value using yq
+    upload_extra=$(yq -r '.upload_extra // "none"' "$template_file" 2>/dev/null || echo "none")
+
+    # Skip if upload_extra is 'none', empty, or null
+    if [[ "$upload_extra" == "none" ]] || [[ -z "$upload_extra" ]] || [[ "$upload_extra" == "null" ]]; then
+        continue
+    fi
+
+    # Check if upload_extra is an array or a string
+    is_array=$(yq -r '.upload_extra | type' "$template_file" 2>/dev/null || echo "null")
+
+    if [[ "$is_array" == "array" ]]; then
+        # It's an array, process each element
+        while IFS= read -r path; do
+            if [[ "$path" != "none" ]] && [[ -n "$path" ]]; then
+                if [[ ! -e "$path" ]]; then
+                    missing_kits+=("$template_name:$path")
+                fi
+            fi
+        done < <(yq -r '.upload_extra[]' "$template_file" 2>/dev/null)
+    else
+        # It's a string, split by spaces
+        IFS=' ' read -ra paths <<< "$upload_extra"
+        for path in "${paths[@]}"; do
+            if [[ "$path" != "none" ]] && [[ -n "$path" ]]; then
+                if [[ ! -e "$path" ]]; then
+                    missing_kits+=("$template_name:$path")
+                fi
+            fi
+        done
+    fi
+done
+
+# Display warning if there are missing kits
+if [ ${#missing_kits[@]} -gt 0 ]; then
+    echo ""
+    echo "======================================================================"
+    echo "WARNING: Missing Kit Directories"
+    echo "======================================================================"
+    echo ""
+    echo "The following kit files/directories specified in templates do not exist:"
+    echo ""
+    for entry in "${missing_kits[@]}"; do
+        template=$(echo "$entry" | cut -d':' -f1)
+        path=$(echo "$entry" | cut -d':' -f2-)
+        echo "  - $template: $path"
+    done
+    echo ""
+    echo "These kits are required for certain benchmarks to run properly."
+    echo "Wrappers depending on these kits may fail until they are provided."
+    echo ""
+    echo "Please ensure the required kits are placed at the specified locations"
+    echo "or update the template files in $config_dir to reflect the correct paths."
+    echo "======================================================================"
+    echo ""
+fi
Evidence
Compliance ID 7 requires an explicit /home/uploads existence check and a specific (or functionally
equivalent) non-blocking warning; the added validation/warning block only reports missing kit paths
from templates and contains no /home/uploads check or message.

Installer warns when /home/uploads directory is missing
bin/install.sh[212-280]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The installer must warn (non-blocking) when `/home/uploads` is missing, but the current changes only validate kit paths from templates and do not implement the required `/home/uploads` warning.

## Issue Context
Compliance requires the installer to check for `/home/uploads` and print the message: `Warning: /home/uploads directory not found. Some wrappers may fail until it is created.` (or functionally equivalent) without aborting installation.

## Fix Focus Areas
- bin/install.sh[209-285]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. yq not on PATH 🐞 Bug ⛯ Reliability
Description
The validation calls yq immediately after installing it via pip3 --user, but the script never
adds the user bin dir to PATH. If yq is not already on PATH, the validation silently treats
all templates as having no upload_extra, defeating the PR’s goal.
Code

bin/install.sh[R225-226]

+    # Extract upload_extra value using yq
+    upload_extra=$(yq -r '.upload_extra // "none"' "$template_file" 2>/dev/null || echo "none")
Evidence
yq is installed using pip3 install --user (typically to ~/.local/bin), but the script later
instructs users to ensure ~/.local/bin is on PATH, implying it may not be during the install
run. The validation invokes yq directly and suppresses errors, so missing yq results in silently
skipping validation.

bin/install.sh[127-132]
bin/install.sh[225-226]
bin/install.sh[282-284]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The new validation invokes `yq` but `yq` is installed via `pip3 --user` and may not be on `PATH` during the same script run. Because stderr is suppressed and a fallback value is used, the validation can silently do nothing.

### Issue Context
`pip --user` installs executables under the Python user base (commonly `~/.local/bin`). The script itself later tells the user to ensure `~/.local/bin` is on their PATH, but validation happens before that guidance.

### Fix Focus Areas
- bin/install.sh[127-138]
- bin/install.sh[212-256]

### Suggested approach
- After the pip installs, add something like:
 - `USER_BASE_BIN=&quot;$(python3 -m site --user-base)/bin&quot;; export PATH=&quot;$USER_BASE_BIN:$PATH&quot;`
- Before running validation, do:
 - `command -v yq &gt;/dev/null || { echo &quot;Skipping kit validation: yq not found on PATH&quot;; skip block; }`
- Avoid silently treating missing `yq` as `upload_extra=none`; emit a clear warning when skipping validation.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Comma parsing mismatch 🐞 Bug ✓ Correctness
Description
For string-valued upload_extra, the validation splits only on spaces. This conflicts with existing
docs and runtime parsing which treat upload_extra as a comma-separated list; comma-separated
strings will be treated as a single path and incorrectly reported missing.
Code

bin/install.sh[R246-248]

+        # It's a string, split by spaces
+        IFS=' ' read -ra paths <<< "$upload_extra"
+        for path in "${paths[@]}"; do
Evidence
Documentation defines upload_extra as a comma-separated list and existing execution/validation
logic normalizes commas to spaces before iterating. The new validation does not normalize commas in
the string case, so inputs like a,b won’t be split into two paths.

bin/install.sh[245-248]
docs/test_config_files.md[124-127]
bin/burden[823-829]
bin/burden[3020-3026]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The validation’s string parsing only splits on spaces, but `upload_extra` is documented and used elsewhere as comma-separated. This causes false positives (e.g., `/a.tar,/b.tar` checked as a single non-existent path).

### Issue Context
Existing logic in `bin/burden` replaces commas with spaces before iterating. Docs also specify comma-separated.

### Fix Focus Areas
- bin/install.sh[245-255]
- docs/test_config_files.md[124-127]
- bin/burden[823-829]

### Suggested approach
- In the string branch, normalize commas:
 - `upload_extra_norm=&quot;${upload_extra//,/ }&quot;`
 - then split on default IFS whitespace: `read -r -a paths &lt;&lt;&lt; &quot;$upload_extra_norm&quot;`
- Consider applying the same normalization to array elements too (defensive), if an element itself contains commas.
- Add a small comment noting supported delimiters: comma and/or whitespace.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


View more (1)
4. Config path assumption 🐞 Bug ⛯ Reliability
Description
The validation uses readlink -f "config" and globs config/*_template.yml relative to the current
working directory. Under set -e, running the installer from a different directory can cause
readlink to fail and abort installation after packages were already installed.
Code

bin/install.sh[R216-220]

+missing_kits=()
+config_dir=$(readlink -f "config")
+
+for template_file in config/*_template.yml; do
+    # Skip if no files match the pattern
Evidence
The script enables set -eu and then resolves config via readlink -f and iterates over
config/*_template.yml as a relative path. If config doesn’t exist relative to the current
working directory, readlink -f exits non-zero and set -e terminates the script.

bin/install.sh[20-20]
bin/install.sh[216-221]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The validation assumes it is run from repo root (`config/...`). With `set -e`, `readlink -f config` will abort the install if invoked from another directory, potentially leaving a partial install.

### Issue Context
The installer uses relative paths for config templates but does not `cd` to the repo root.

### Fix Focus Areas
- bin/install.sh[20-21]
- bin/install.sh[216-221]
- bin/install.sh[219-256]

### Suggested approach
- Compute repo root from script location:
 - `REPO_ROOT=&quot;$(cd &quot;$(dirname &quot;${BASH_SOURCE[0]}&quot;)/..&quot; &amp;&amp; pwd -P)&quot;`
 - `CONFIG_DIR=&quot;$REPO_ROOT/config&quot;`
- Use `CONFIG_DIR` everywhere:
 - `for template_file in &quot;$CONFIG_DIR&quot;/*_template.yml; do ...`
- Avoid a failing `readlink -f` under `set -e`:
 - Either drop it and use `$CONFIG_DIR` in messaging,
 - or guard: `config_dir=$(readlink -f &quot;$CONFIG_DIR&quot; 2&gt;/dev/null || echo &quot;$CONFIG_DIR&quot;)`
- Optionally skip validation with a clear warning if `$CONFIG_DIR` doesn’t exist.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

5. readlink/yq errors hidden 📘 Rule violation ⛯ Reliability
Description
The new validation suppresses yq errors (redirected to /dev/null and defaulting to
none/null), which can silently skip validation when templates are unreadable/invalid. Also,
config_dir=$(readlink -f "config") can cause an unexpected installer exit if config cannot be
resolved, instead of degrading gracefully with an actionable warning.
Code

bin/install.sh[R217-244]

+config_dir=$(readlink -f "config")
+
+for template_file in config/*_template.yml; do
+    # Skip if no files match the pattern
+    [ -e "$template_file" ] || continue
+
+    template_name=$(basename "$template_file")
+
+    # Extract upload_extra value using yq
+    upload_extra=$(yq -r '.upload_extra // "none"' "$template_file" 2>/dev/null || echo "none")
+
+    # Skip if upload_extra is 'none', empty, or null
+    if [[ "$upload_extra" == "none" ]] || [[ -z "$upload_extra" ]] || [[ "$upload_extra" == "null" ]]; then
+        continue
+    fi
+
+    # Check if upload_extra is an array or a string
+    is_array=$(yq -r '.upload_extra | type' "$template_file" 2>/dev/null || echo "null")
+
+    if [[ "$is_array" == "array" ]]; then
+        # It's an array, process each element
+        while IFS= read -r path; do
+            if [[ "$path" != "none" ]] && [[ -n "$path" ]]; then
+                if [[ ! -e "$path" ]]; then
+                    missing_kits+=("$template_name:$path")
+                fi
+            fi
+        done < <(yq -r '.upload_extra[]' "$template_file" 2>/dev/null)
Evidence
Compliance ID 3 requires handling failure points with meaningful context and avoiding silent
failures; the added code explicitly discards yq errors and uses readlink -f without a safe
fallback, which can hide actionable problems or terminate the script in edge cases.

Rule 3: Generic: Robust Error Handling and Edge Case Management
bin/install.sh[217-217]
bin/install.sh[226-226]
bin/install.sh[234-234]
bin/install.sh[244-244]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The new template validation can silently skip checks when `yq` fails (errors are suppressed), and it may unexpectedly abort if `readlink -f config` fails.

## Issue Context
This validation is intended to be a non-blocking warning feature. Failures to parse templates or resolve paths should produce clear warnings (what failed and which file), and the installer should continue when possible.

## Fix Focus Areas
- bin/install.sh[217-244]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

ⓘ The new review experience is currently in Beta. Learn more

Grey Divider

Qodo Logo

@sayalibhavsar sayalibhavsar self-assigned this Feb 24, 2026
@sayalibhavsar sayalibhavsar added the group_review_lgtm Indicates approval after a group review meeting label Feb 24, 2026
Comment on lines +212 to +280
# Validate kit directories specified in templates
echo ""
echo "Validating kit directories..."

missing_kits=()
config_dir=$(readlink -f "config")

for template_file in config/*_template.yml; do
# Skip if no files match the pattern
[ -e "$template_file" ] || continue

template_name=$(basename "$template_file")

# Extract upload_extra value using yq
upload_extra=$(yq -r '.upload_extra // "none"' "$template_file" 2>/dev/null || echo "none")

# Skip if upload_extra is 'none', empty, or null
if [[ "$upload_extra" == "none" ]] || [[ -z "$upload_extra" ]] || [[ "$upload_extra" == "null" ]]; then
continue
fi

# Check if upload_extra is an array or a string
is_array=$(yq -r '.upload_extra | type' "$template_file" 2>/dev/null || echo "null")

if [[ "$is_array" == "array" ]]; then
# It's an array, process each element
while IFS= read -r path; do
if [[ "$path" != "none" ]] && [[ -n "$path" ]]; then
if [[ ! -e "$path" ]]; then
missing_kits+=("$template_name:$path")
fi
fi
done < <(yq -r '.upload_extra[]' "$template_file" 2>/dev/null)
else
# It's a string, split by spaces
IFS=' ' read -ra paths <<< "$upload_extra"
for path in "${paths[@]}"; do
if [[ "$path" != "none" ]] && [[ -n "$path" ]]; then
if [[ ! -e "$path" ]]; then
missing_kits+=("$template_name:$path")
fi
fi
done
fi
done

# Display warning if there are missing kits
if [ ${#missing_kits[@]} -gt 0 ]; then
echo ""
echo "======================================================================"
echo "WARNING: Missing Kit Directories"
echo "======================================================================"
echo ""
echo "The following kit files/directories specified in templates do not exist:"
echo ""
for entry in "${missing_kits[@]}"; do
template=$(echo "$entry" | cut -d':' -f1)
path=$(echo "$entry" | cut -d':' -f2-)
echo " - $template: $path"
done
echo ""
echo "These kits are required for certain benchmarks to run properly."
echo "Wrappers depending on these kits may fail until they are provided."
echo ""
echo "Please ensure the required kits are placed at the specified locations"
echo "or update the template files in $config_dir to reflect the correct paths."
echo "======================================================================"
echo ""
fi

Choose a reason for hiding this comment

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

Action required

1. /home/uploads check missing 📎 Requirement gap ⛯ Reliability

The installer changes add kit-path validation but do not check whether /home/uploads exists or
emit the required non-blocking warning message. This fails the required installer visibility
behavior when /home/uploads is missing.
Agent Prompt
## Issue description
The installer must warn (non-blocking) when `/home/uploads` is missing, but the current changes only validate kit paths from templates and do not implement the required `/home/uploads` warning.

## Issue Context
Compliance requires the installer to check for `/home/uploads` and print the message: `Warning: /home/uploads directory not found. Some wrappers may fail until it is created.` (or functionally equivalent) without aborting installation.

## Fix Focus Areas
- bin/install.sh[209-285]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +225 to +226
# Extract upload_extra value using yq
upload_extra=$(yq -r '.upload_extra // "none"' "$template_file" 2>/dev/null || echo "none")

Choose a reason for hiding this comment

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

Action required

2. Yq not on path 🐞 Bug ⛯ Reliability

The validation calls yq immediately after installing it via pip3 --user, but the script never
adds the user bin dir to PATH. If yq is not already on PATH, the validation silently treats
all templates as having no upload_extra, defeating the PR’s goal.
Agent Prompt
### Issue description
The new validation invokes `yq` but `yq` is installed via `pip3 --user` and may not be on `PATH` during the same script run. Because stderr is suppressed and a fallback value is used, the validation can silently do nothing.

### Issue Context
`pip --user` installs executables under the Python user base (commonly `~/.local/bin`). The script itself later tells the user to ensure `~/.local/bin` is on their PATH, but validation happens before that guidance.

### Fix Focus Areas
- bin/install.sh[127-138]
- bin/install.sh[212-256]

### Suggested approach
- After the pip installs, add something like:
  - `USER_BASE_BIN="$(python3 -m site --user-base)/bin"; export PATH="$USER_BASE_BIN:$PATH"`
- Before running validation, do:
  - `command -v yq >/dev/null || { echo "Skipping kit validation: yq not found on PATH"; skip block; }`
- Avoid silently treating missing `yq` as `upload_extra=none`; emit a clear warning when skipping validation.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +246 to +248
# It's a string, split by spaces
IFS=' ' read -ra paths <<< "$upload_extra"
for path in "${paths[@]}"; do

Choose a reason for hiding this comment

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

Action required

3. Comma parsing mismatch 🐞 Bug ✓ Correctness

For string-valued upload_extra, the validation splits only on spaces. This conflicts with existing
docs and runtime parsing which treat upload_extra as a comma-separated list; comma-separated
strings will be treated as a single path and incorrectly reported missing.
Agent Prompt
### Issue description
The validation’s string parsing only splits on spaces, but `upload_extra` is documented and used elsewhere as comma-separated. This causes false positives (e.g., `/a.tar,/b.tar` checked as a single non-existent path).

### Issue Context
Existing logic in `bin/burden` replaces commas with spaces before iterating. Docs also specify comma-separated.

### Fix Focus Areas
- bin/install.sh[245-255]
- docs/test_config_files.md[124-127]
- bin/burden[823-829]

### Suggested approach
- In the string branch, normalize commas:
  - `upload_extra_norm="${upload_extra//,/ }"`
  - then split on default IFS whitespace: `read -r -a paths <<< "$upload_extra_norm"`
- Consider applying the same normalization to array elements too (defensive), if an element itself contains commas.
- Add a small comment noting supported delimiters: comma and/or whitespace.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Comment on lines +216 to +220
missing_kits=()
config_dir=$(readlink -f "config")

for template_file in config/*_template.yml; do
# Skip if no files match the pattern

Choose a reason for hiding this comment

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

Action required

4. Config path assumption 🐞 Bug ⛯ Reliability

The validation uses readlink -f "config" and globs config/*_template.yml relative to the current
working directory. Under set -e, running the installer from a different directory can cause
readlink to fail and abort installation after packages were already installed.
Agent Prompt
### Issue description
The validation assumes it is run from repo root (`config/...`). With `set -e`, `readlink -f config` will abort the install if invoked from another directory, potentially leaving a partial install.

### Issue Context
The installer uses relative paths for config templates but does not `cd` to the repo root.

### Fix Focus Areas
- bin/install.sh[20-21]
- bin/install.sh[216-221]
- bin/install.sh[219-256]

### Suggested approach
- Compute repo root from script location:
  - `REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"`
  - `CONFIG_DIR="$REPO_ROOT/config"`
- Use `CONFIG_DIR` everywhere:
  - `for template_file in "$CONFIG_DIR"/*_template.yml; do ...`
- Avoid a failing `readlink -f` under `set -e`:
  - Either drop it and use `$CONFIG_DIR` in messaging,
  - or guard: `config_dir=$(readlink -f "$CONFIG_DIR" 2>/dev/null || echo "$CONFIG_DIR")`
- Optionally skip validation with a clear warning if `$CONFIG_DIR` doesn’t exist.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

@sayalibhavsar sayalibhavsar deleted the gh-323 branch February 24, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

group_review_lgtm Indicates approval after a group review meeting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

zathras should warn if /home/uploads directory is missing

1 participant