Skip to content

quickstart: preflight-check podman and jq before execution#215

Merged
ggiguash merged 2 commits intomicroshift-io:mainfrom
mmahut:main
May 4, 2026
Merged

quickstart: preflight-check podman and jq before execution#215
ggiguash merged 2 commits intomicroshift-io:mainfrom
mmahut:main

Conversation

@mmahut
Copy link
Copy Markdown
Contributor

@mmahut mmahut commented Apr 18, 2026

Add check_prerequisites() to fail fast with actionable install instructions when podman version is outdated (<4.0) or jq is missing, rather than hitting a cryptic command-not-found mid-run. Package manager detection covers dnf, apt-get, and zypper.

Summary by CodeRabbit

  • Chores
    • Added automatic validation of required system tools at startup with clear error messages and immediate exit on failure.
    • Enforced a minimum Podman major version (set to 4) before container operations.
    • Gated resolution of the "latest" release tag: curl and jq are checked only when resolving non-local "latest" images.

@mmahut mmahut requested a review from a team as a code owner April 18, 2026 19:47
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 18, 2026

📝 Walkthrough

Walkthrough

Adds early host validation to src/quickstart.sh: introduces PODMAN_VMAJOR=4, check_prerequisites() and check_podman_version(); validations run after root check; curl/jq are validated only when resolving the GitHub “latest” tag for non-local images.

Changes

Cohort / File(s) Summary
Quickstart script updates
src/quickstart.sh
Added PODMAN_VMAJOR=4, new functions check_prerequisites() and check_podman_version(); invoke prerequisite and Podman-version checks immediately after root validation; only call check_prerequisites curl jq when TAG is latest for non-local images before using `curl

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding preflight validation checks for podman and jq before script execution.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/quickstart.sh`:
- Around line 38-51: The unconditional check for jq (and missing check for curl)
should be gated to the same condition used when fetching the remote latest-tag:
wrap or move the dependency checks so they run only when [[ "${IMAGE}" !=
localhost/* ]] && [ "${TAG}" == "latest" ]; add a curl availability check
(command -v curl &>/dev/null) alongside jq and emit the same user-friendly
install hints if either is missing; update the quickstart.sh block that
currently tests jq to be executed only under that IMAGE/TAG condition so local
or pinned-tag runs do not fail unnecessarily.
- Around line 28-35: Validate podman presence and robustly parse its version
into podman_version using a regex (e.g., extract first X.Y.Z numeric sequence
from `podman --version`) instead of assuming field 3, then compare full semantic
versions (not only podman_major) against "4.0.0" using a reliable comparator
(e.g., a small version_compare function that uses sort -V or compares numeric
fields) to decide failure; update the error message to include the detected
version and a short note that the script requires ≥4.0.0 because it relies on
features used later (e.g., `podman run --replace`), and keep the variable names
podman_version and podman_major (if still used) to locate the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7f56f021-c472-42b3-a872-c243a6cfa8e7

📥 Commits

Reviewing files that changed from the base of the PR and between f915e4c and 6e82d4b.

📒 Files selected for processing (1)
  • src/quickstart.sh

Comment thread src/quickstart.sh
Comment thread src/quickstart.sh Outdated
Comment thread src/quickstart.sh
Comment thread src/quickstart.sh
Comment thread src/quickstart.sh Outdated
@mmahut
Copy link
Copy Markdown
Contributor Author

mmahut commented Apr 22, 2026

@ggiguash thank you for great feedback, PR rebased.

Comment thread src/quickstart.sh Outdated
Add check_prerequisites() to fail fast with actionable install
instructions when podman (or an outdated version <4) or jq is
missing, rather than hitting a cryptic command-not-found mid-run.
Package manager detection covers dnf, apt-get, and zypper.
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (1)
src/quickstart.sh (1)

33-37: ⚠️ Potential issue | 🟡 Minor

Harden podman version parsing before numeric compare.

Line 34 assumes a fixed token position, and Line 37 does integer comparison without validating numeric input. A malformed version string can bypass the intended guard or emit test errors.

Suggested hardening
 function check_podman_version() {
-    local podman_version
-    podman_version="$(podman --version | awk '/^podman version /{print $3}')"
-    local podman_major
-    podman_major="$(echo "${podman_version}" | cut -d. -f1)"
-    if [ -z "${podman_major}" ] || [ "${podman_major}" -lt "${PODMAN_VMAJOR}" ]; then
+    local podman_version_output
+    podman_version_output="$(podman --version)"
+    local podman_version
+    podman_version="$(awk 'match($0, /[0-9]+([.][0-9]+)*/) { print substr($0, RSTART, RLENGTH); exit }' <<<"${podman_version_output}")"
+    local podman_major
+    podman_major="${podman_version%%.*}"
+    if [[ -z "${podman_major}" || ! "${podman_major}" =~ ^[0-9]+$ ]] || (( podman_major < PODMAN_VMAJOR )); then
         echo "ERROR: podman ${podman_version:-unknown} is too old (minimum required: ${PODMAN_VMAJOR}.0)"
         echo "Please upgrade podman and try again."
         exit 1
     fi
 }
#!/bin/bash
# Read-only verification: demonstrate current parsing fragility with variant version strings.
set -u

parse_current() {
  local out="$1"
  local podman_version
  podman_version="$(awk '/^podman version /{print $3}' <<<"$out")"
  local podman_major
  podman_major="$(echo "${podman_version}" | cut -d. -f1)"
  printf 'input=%q -> podman_version=%q podman_major=%q | ' "$out" "$podman_version" "$podman_major"
  if [ -z "${podman_major}" ] || [ "${podman_major}" -lt "4" ] 2>/dev/null; then
    echo "rejected"
  else
    echo "accepted"
  fi
}

parse_current "podman version 4.9.3"
parse_current "podman version v4.9.3"
parse_current "podman version unknown"

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 11d21bed-b038-44a7-bb7a-091da8094d73

📥 Commits

Reviewing files that changed from the base of the PR and between 59614f1 and 33c23a9.

📒 Files selected for processing (1)
  • src/quickstart.sh

@ggiguash
Copy link
Copy Markdown
Contributor

ggiguash commented May 3, 2026

@mmahut , I will approve this PR once #217 fix merges so that we can have a clean CI.

@ggiguash ggiguash merged commit bde3c43 into microshift-io:main May 4, 2026
17 of 19 checks passed
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.

2 participants