Skip to content

microshift-io/microshift-nightly COPR: RPM with rhocp-mirror-beta configs#203

Open
pmtk wants to merge 5 commits intomicroshift-io:mainfrom
pmtk:copr-deps-2
Open

microshift-io/microshift-nightly COPR: RPM with rhocp-mirror-beta configs#203
pmtk wants to merge 5 commits intomicroshift-io:mainfrom
pmtk:copr-deps-2

Conversation

@pmtk
Copy link
Contributor

@pmtk pmtk commented Feb 15, 2026

Addresses: #165

Summary by CodeRabbit

  • New Features

    • Add workflow option to choose COPR repository and new nightly jobs that build and publish dependency and CNI packages automatically.
  • Documentation

    • Simplified installation: no beta mirror requirement; install a packaged dependencies bundle via the system package manager before MicroShift/CNI packages.
  • Chores

    • Added tooling and container updates to produce and publish dependency and CNI RPMs, plus improved build invocation, error handling, and output persistence.

@pmtk pmtk requested a review from a team as a code owner February 15, 2026 18:49
@coderabbitai
Copy link

coderabbitai bot commented Feb 15, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Parameterizes the nightly COPR workflow with a COPR repo input, adds jobs and scripts to build/publish MicroShift dependencies and CNI plugins to COPR, updates COPR CLI container and Makefile targets to use a mounted secret, and changes installer docs/scripts to install a microshift-io-dependencies package instead of creating local COPR repos.

Changes

Cohort / File(s) Summary
GitHub workflow
.github/workflows/nightly-copr.yaml
Add copr-repo-name workflow input; make COPR_REPO_NAME dynamic; add build-dependencies-rpm job that checks out upstream, detects OKD tag, and triggers COPR builds for dependencies and CNI (conditional run).
CNI packaging
src/copr/cni/build.sh, src/copr/cni/containernetworking-plugins.spec
Add script and spec to assemble arch-specific CNI binaries, produce SRPM, push to COPR, wait for build result and regenerate repos.
Dependencies packaging
src/copr/microshift-io-dependencies.sh
Add script that derives OKD version, generates a .spec embedding RHOCp repo versions, checks COPR for existing package, builds SRPM and regenerates repos.
COPR tooling & container
src/copr/copr.mk, src/copr/copr-cli.Containerfile, src/copr/create-build.sh
Makefile: add copr-dependencies & copr-cni targets and standardize mounting COPR secret at a target path; Containerfile: install copr-cli/jq/rpm-build and copy build scripts; create-build.sh: remove explicit --config, add build-id error handling and persist build id.
Installer docs & quick install
docs/run.md, src/quickrpm.sh
Remove RHOCP beta-mirror repo creation/cleanup steps; install microshift-io-dependencies via dnf before MicroShift and kindnet; adjust install flow accordingly.
Build orchestration helpers
src/copr/, src/copr/cni/
Add new scripts/specs and wire them into the containerized COPR build flow via Makefile and Containerfile changes.

Sequence Diagram(s)

sequenceDiagram
    participant GH as GitHub Actions
    participant Repo as Upstream Repo
    participant Detect as detect-okd-version Action
    participant CLI as COPR CLI Container
    participant COPR as COPR Service

    GH->>Repo: checkout upstream
    GH->>Detect: run to detect OKD tag
    Detect-->>GH: OKD tag
    GH->>CLI: invoke `copr-dependencies` (mount secret at target path)
    CLI->>COPR: query package existence
    alt package missing
        CLI->>COPR: upload SRPM & create build
        COPR-->>CLI: build status (watch)
        CLI->>COPR: regenerate repos
    else package exists
        COPR-->>CLI: indicate existing build
    end
    GH->>CLI: invoke `copr-cni` (mount secret)
    CLI->>COPR: upload CNI SRPM & create build
    COPR-->>CLI: build status (watch)
    CLI->>COPR: regenerate repos
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested reviewers

  • ggiguash
🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title refers to COPR configuration and rhocp-mirror-beta, but the actual changes focus on building dependency and CNI RPMs, not rhocp-mirror-beta configs. Consider a more accurate title like 'Add COPR build support for MicroShift dependencies and CNI plugins' to better reflect the actual changes.
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 (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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

@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: 7

🤖 Fix all issues with AI agents
In `@docs/run.md`:
- Around line 44-47: Replace the incorrect package name
"microshift-io-dependencies-repo" in the installation command with the correct
package "microshift-io-dependencies" so the docs match the spec and quickrpm.sh
usage; update the line that currently runs sudo dnf install -y
microshift-io-dependencies-repo to sudo dnf install -y
microshift-io-dependencies in docs/run.md.

In `@src/copr/cni/build.sh`:
- Around line 50-59: The unquoted ${version} variable is used in several path
constructions (mkdir, tar -C, cp, tar czf, mv) in build.sh and triggers
shellcheck SC2086; update every occurrence to use quoted expansions like
"${version}" (e.g., containernetworking-plugins-"${version}"/x86_64) so paths
with spaces or glob chars are safe, and ensure all related commands (mkdir, tar
-C, cp, tar czf, mv) reference the quoted form consistently.

In `@src/copr/copr-cli.Containerfile`:
- Around line 3-7: The RUN installation line installs the wrong package name
"rpmbuild"; replace it with the correct Fedora package "rpm-build" in the RUN
command that installs "copr-cli jq rpmbuild" (so the token "rpmbuild" in that
RUN should be changed to "rpm-build") and keep the rest of the flags and cleanup
unchanged.

In `@src/copr/copr.mk`:
- Around line 120-126: The copr-cni make target is missing a .PHONY declaration,
uses the interactive -ti flags in the podman run, and the file lacks a final
newline; update the Makefile to add copr-cni to the .PHONY list (alongside other
phony targets), remove the -ti flags from the podman run invocation in the
copr-cni recipe so it runs non-interactively, and ensure the file ends with a
trailing newline character so POSIX tools behave correctly.
- Around line 112-118: Add a .PHONY declaration for the copr-dependencies
target, remove the interactive TTY flags (-ti) from the podman run invocation
(use --rm only, or gate -t behind a tty check if colored output is needed), and
document or provide a default for OKD_VERSION_TAG in the Makefile variables/help
section so the copr-dependencies target has a defined value; update references
to COPR_SECRET_NAME and COPR_CLI_IMAGE only as needed to match the existing
variable names.

In `@src/copr/microshift-io-dependencies.sh`:
- Around line 26-37: The if condition incorrectly uses command substitution
causing SC2091 (if $(...) executes stdout rather than the pipeline exit status);
change the condition to test the pipeline directly—invoke the pipeline starting
with copr-cli list-packages "${COPR_REPO_NAME}" | jq -r '.[].name' | grep -q
"${_package_name}" in the if statement (without $()), so the exit code controls
the branch; keep the inner logic that sets existing_package_version (from
copr-cli get-package ... | jq -r
'.latest_succeeded_build.source_package.version') and compares it to
"${pkg_version}-1" as before.
- Around line 88-91: The script currently calls copr-cli build with a local
.spec path (copr-cli build "${COPR_REPO_NAME}" "${dest}/${_package_name}.spec"),
but copr-cli expects an SRPM or URL; change the flow to create an SRPM from the
spec (e.g., run rpmbuild -ba /path/to/"${_package_name}.spec" or the project's
SRPM build command to produce an .src.rpm) and then call copr-cli build with
that SRPM path (copr-cli build "${COPR_REPO_NAME}"
"/path/to/${_package_name}-*.src.rpm"); keep the subsequent copr-cli
regenerate-repos call the same. Ensure variables (COPR_REPO_NAME, dest,
_package_name) are used to locate the produced SRPM.
🧹 Nitpick comments (3)
src/copr/copr-cli.Containerfile (1)

9-10: containernetworking-plugins.spec is copied to both / and /cni/.

Line 9 copies the spec to / and line 10 copies it again to /cni/. The build.sh script references it relative to its own directory ($_scriptdir), which is /cni/. The copy to / on line 9 appears redundant.

Proposed fix
-COPY create-build.sh microshift-io-dependencies.sh cni/containernetworking-plugins.spec /
+COPY create-build.sh microshift-io-dependencies.sh /
 COPY cni/build.sh cni/containernetworking-plugins.spec /cni/
src/copr/microshift-io-dependencies.sh (1)

73-74: gpgcheck=0 disables signature verification on the repo.

The generated .repo files disable GPG checking. If this is intentional for beta mirrors, consider adding a comment in the spec explaining why.

src/copr/cni/build.sh (1)

41-42: No cleanup trap for temp_dir on early exit.

If the script fails between mktemp and the final rm -rf, the temp directory persists. Not critical in CI containers, but a trap would be more robust.

Suggested addition after line 41
 temp_dir="$(mktemp -d "/tmp/containernetworking-plugins-${version}.XXXXXX")"
+trap 'rm -rf "${temp_dir}"' EXIT
 cp "${_scriptdir}/containernetworking-plugins.spec" "${temp_dir}/"

Comment on lines +112 to +118
copr-dependencies: copr-cfg-ensure-podman-secret copr-cli
@echo "Building RPM with MicroShift dependencies repositories configuration"
sudo podman run \
--rm -ti \
--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
"${COPR_CLI_IMAGE}" \
/microshift-io-dependencies.sh "${OKD_VERSION_TAG}" "${COPR_REPO_NAME}"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Missing .PHONY and -ti will break in CI.

  1. Add .PHONY: copr-dependencies — every other target in this file declares it.
  2. -ti allocates a TTY + interactive stdin. GitHub Actions runners have no TTY, so this will fail or emit warnings. The other targets in this file use only --rm. Drop -ti (or use -t only if truly needed for colored output, gated on [ -t 0 ]).
  3. OKD_VERSION_TAG is undocumented in the help target and has no default — consider adding it to the variables section.
Proposed fix
+.PHONY: copr-dependencies
 copr-dependencies: copr-cfg-ensure-podman-secret copr-cli
 	`@echo` "Building RPM with MicroShift dependencies repositories configuration"
 	sudo podman run \
-		--rm -ti \
+		--rm \
 		--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
 		"${COPR_CLI_IMAGE}" \
 		/microshift-io-dependencies.sh "${OKD_VERSION_TAG}" "${COPR_REPO_NAME}"
🤖 Prompt for AI Agents
In `@src/copr/copr.mk` around lines 112 - 118, Add a .PHONY declaration for the
copr-dependencies target, remove the interactive TTY flags (-ti) from the podman
run invocation (use --rm only, or gate -t behind a tty check if colored output
is needed), and document or provide a default for OKD_VERSION_TAG in the
Makefile variables/help section so the copr-dependencies target has a defined
value; update references to COPR_SECRET_NAME and COPR_CLI_IMAGE only as needed
to match the existing variable names.

Comment on lines +120 to +126
copr-cni: copr-cfg-ensure-podman-secret copr-cli
@echo "Building RPM with CNI plugins"
sudo podman run \
--rm -ti \
--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
"${COPR_CLI_IMAGE}" \
/cni/build.sh "${COPR_REPO_NAME}"
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Same issues: missing .PHONY and -ti; also no trailing newline.

Same fixes as copr-dependencies above. Additionally, the file lacks a final newline which can cause POSIX tools to misbehave.

Proposed fix
+.PHONY: copr-cni
 copr-cni: copr-cfg-ensure-podman-secret copr-cli
 	`@echo` "Building RPM with CNI plugins"
 	sudo podman run \
-		--rm -ti \
+		--rm \
 		--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
 		"${COPR_CLI_IMAGE}" \
 		/cni/build.sh "${COPR_REPO_NAME}"
+
🤖 Prompt for AI Agents
In `@src/copr/copr.mk` around lines 120 - 126, The copr-cni make target is missing
a .PHONY declaration, uses the interactive -ti flags in the podman run, and the
file lacks a final newline; update the Makefile to add copr-cni to the .PHONY
list (alongside other phony targets), remove the -ti flags from the podman run
invocation in the copr-cni recipe so it runs non-interactively, and ensure the
file ends with a trailing newline character so POSIX tools behave correctly.

@pmtk pmtk changed the title microshift-io/microshift-nightly COPR: RPM with rhocp-mirror-beta config & CNIs microshift-io/microshift-nightly COPR: RPM with rhocp-mirror-beta configs Mar 5, 2026
@pmtk pmtk force-pushed the copr-deps-2 branch 3 times, most recently from 146d1e0 to 0afea9f Compare March 6, 2026 14:47
Copy link

@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

♻️ Duplicate comments (1)
src/copr/copr.mk (1)

115-128: ⚠️ Potential issue | 🟠 Major

Drop -ti from the new Podman runs.

These targets are called from GitHub Actions, where stdin is non-interactive. podman run --rm -ti ... commonly fails with “the input device is not a TTY”, so the new dependency/CNI jobs can die before either script starts.

Possible fix
 sudo podman run \
-		--rm -ti \
+		--rm \
 		--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
 		"${COPR_CLI_IMAGE}" \
 		/microshift-io-dependencies.sh "${OKD_VERSION_TAG}" "${COPR_REPO_NAME}"
@@
 sudo podman run \
-		--rm -ti \
+		--rm \
 		--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
 		"${COPR_CLI_IMAGE}" \
 		/cni/build.sh "${COPR_REPO_NAME}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/copr/copr.mk` around lines 115 - 128, The podman runs in the copr.mk
targets use the interactive flags "-ti" which cause failures in non-interactive
CI; remove the "-ti" flags from the podman run invocations used to launch
"${COPR_CLI_IMAGE}" (the run that executes /microshift-io-dependencies.sh and
the copr-cni run that executes /cni/build.sh) so the commands become
non-interactive and will not error with "input device is not a TTY" in GitHub
Actions.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/nightly-copr.yaml:
- Around line 17-56: Add the new job build-dependencies-rpm as a dependency of
the image/test job so the image build cannot start until both RPM producers
finish; specifically, update the build-and-test-microshift job to include needs:
[build-rpms, build-dependencies-rpm] (or append build-dependencies-rpm to
whatever existing needs list) so that build-dependencies-rpm (which contains the
CNI step) and build-rpms complete before metadata is consumed.

In `@src/copr/microshift-io-dependencies.sh`:
- Around line 39-82: The current logic builds rhocp_versions as a range and
writes a repo file that enables every minor from
${_minor_version_start}..${minor}, which allows dnf to pick newer incompatible
mirrors; change rhocp_versions to only include the single target minor (e.g.,
construct rhocp_versions="${major}.${minor}" instead of the seq loop) and update
the for-loop that emits the repo (the loop over %{rhocp_versions} and the repo
block using variable v) to only iterate that single minor so the generated
openshift-mirror-beta.repo enables just the exact matching OCP minor for the
MicroShift build.

---

Duplicate comments:
In `@src/copr/copr.mk`:
- Around line 115-128: The podman runs in the copr.mk targets use the
interactive flags "-ti" which cause failures in non-interactive CI; remove the
"-ti" flags from the podman run invocations used to launch "${COPR_CLI_IMAGE}"
(the run that executes /microshift-io-dependencies.sh and the copr-cni run that
executes /cni/build.sh) so the commands become non-interactive and will not
error with "input device is not a TTY" in GitHub Actions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 9cb861a8-b63f-416c-9c36-75947300d2b5

📥 Commits

Reviewing files that changed from the base of the PR and between 1884484 and 0afea9f.

📒 Files selected for processing (9)
  • .github/workflows/nightly-copr.yaml
  • docs/run.md
  • src/copr/cni/build.sh
  • src/copr/cni/containernetworking-plugins.spec
  • src/copr/copr-cli.Containerfile
  • src/copr/copr.mk
  • src/copr/create-build.sh
  • src/copr/microshift-io-dependencies.sh
  • src/quickrpm.sh
🚧 Files skipped from review as they are similar to previous changes (2)
  • docs/run.md
  • src/copr/create-build.sh

Copy link

@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/copr/copr.mk (1)

112-128: ⚠️ Potential issue | 🟡 Minor

Remove -ti flags—GitHub Actions runners have no TTY.

The -ti flags at lines 116 and 125 will fail or warn in CI. Also ensure file ends with a newline.

Proposed fix
 .PHONY: copr-dependencies
 copr-dependencies: copr-cfg-ensure-podman-secret copr-cli
 	`@echo` "Building RPM with MicroShift dependencies repositories configuration"
 	sudo podman run \
-		--rm -ti \
+		--rm \
 		--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
 		"${COPR_CLI_IMAGE}" \
 		/microshift-io-dependencies.sh "${OKD_VERSION_TAG}" "${COPR_REPO_NAME}"

 .PHONY: copr-cni
 copr-cni: copr-cfg-ensure-podman-secret copr-cli
 	`@echo` "Building RPM with CNI plugins"
 	sudo podman run \
-		--rm -ti \
+		--rm \
 		--secret ${COPR_SECRET_NAME},target=/root/.config/copr \
 		"${COPR_CLI_IMAGE}" \
 		/cni/build.sh "${COPR_REPO_NAME}"
+
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/copr/copr.mk` around lines 112 - 128, In the Makefile targets
copr-dependencies and copr-cni remove the interactive/TTY flags "-ti" from the
sudo podman run commands (the lines invoking "${COPR_CLI_IMAGE}" with
/microshift-io-dependencies.sh and /cni/build.sh) so CI runners without a TTY
won’t fail or warn, and add a trailing newline at the end of src/copr/copr.mk;
keep the rest of the podman invocation and secret/arg variables
(COPR_SECRET_NAME, COPR_CLI_IMAGE, COPR_REPO_NAME, OKD_VERSION_TAG) unchanged.
🧹 Nitpick comments (3)
src/copr/cni/build.sh (2)

41-84: Temp directory not cleaned on failure.

If the script fails between lines 41-82, the temp directory persists. Add a trap for cleanup.

Proposed fix
 temp_dir="$(mktemp -d "/tmp/containernetworking-plugins-${version}.XXXXXX")"
+trap 'rm -rf "${temp_dir}"' EXIT
 cp "${_scriptdir}/containernetworking-plugins.spec" "${temp_dir}/"

Then remove the explicit cleanup at the end:

 popd >/dev/null
-rm -rf "${temp_dir}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/copr/cni/build.sh` around lines 41 - 84, The temp directory created in
temp_dir="$(mktemp -d ...)" is not cleaned if the script exits early; add a
cleanup trap and function (e.g., cleanup() { popd >/dev/null || true; rm -rf
"${temp_dir}"; }) right after temp_dir is created and register it with trap
'cleanup' EXIT ERR to ensure popd and rm -rf run on any exit; then remove the
final explicit rm -rf/popd at the end (or keep popd only inside cleanup) so
cleanup is centralized and always runs even on failure.

27-27: Consider using jq --arg for variable interpolation.

While safe here (hardcoded value), the idiomatic jq approach avoids shell quoting issues:

Proposed fix
-cni_pkg="$(copr-cli list-packages "${COPR_REPO_NAME}" | jq -r '.[] | select(.name == "'${_package_name}'")')"
+cni_pkg="$(copr-cli list-packages "${COPR_REPO_NAME}" | jq -r --arg name "${_package_name}" '.[] | select(.name == $name)')"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/copr/cni/build.sh` at line 27, The command building cni_pkg uses shell
interpolation into jq which can be fragile; update the call that constructs
cni_pkg (the line invoking copr-cli list-packages "${COPR_REPO_NAME}" | jq -r
...) to pass the package name via jq's --arg (referencing _package_name and
COPR_REPO_NAME) and use that $arg inside the jq filter instead of embedding the
shell variable, ensuring safer/idiomatic variable interpolation.
src/copr/copr-cli.Containerfile (1)

9-10: Redundant spec file copy to /.

cni/containernetworking-plugins.spec is copied to both / (line 9) and /cni/ (line 10). The build.sh script only uses the /cni/ copy via ${_scriptdir}. Remove from line 9.

Proposed fix
-COPY create-build.sh microshift-io-dependencies.sh cni/containernetworking-plugins.spec /
+COPY create-build.sh microshift-io-dependencies.sh /
 COPY cni/build.sh cni/containernetworking-plugins.spec /cni/
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/copr/copr-cli.Containerfile` around lines 9 - 10, The Dockerfile copies
cni/containernetworking-plugins.spec twice—once to / and again to /cni/—but the
build uses the /cni/ location; remove the redundant copy from the first COPY
(the line that currently copies create-build.sh microshift-io-dependencies.sh
cni/containernetworking-plugins.spec /) so only create-build.sh and
microshift-io-dependencies.sh are copied there and leave the second COPY that
places cni/containernetworking-plugins.spec into /cni/ (used by cni/build.sh via
${_scriptdir}).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@src/copr/copr.mk`:
- Around line 112-128: In the Makefile targets copr-dependencies and copr-cni
remove the interactive/TTY flags "-ti" from the sudo podman run commands (the
lines invoking "${COPR_CLI_IMAGE}" with /microshift-io-dependencies.sh and
/cni/build.sh) so CI runners without a TTY won’t fail or warn, and add a
trailing newline at the end of src/copr/copr.mk; keep the rest of the podman
invocation and secret/arg variables (COPR_SECRET_NAME, COPR_CLI_IMAGE,
COPR_REPO_NAME, OKD_VERSION_TAG) unchanged.

---

Nitpick comments:
In `@src/copr/cni/build.sh`:
- Around line 41-84: The temp directory created in temp_dir="$(mktemp -d ...)"
is not cleaned if the script exits early; add a cleanup trap and function (e.g.,
cleanup() { popd >/dev/null || true; rm -rf "${temp_dir}"; }) right after
temp_dir is created and register it with trap 'cleanup' EXIT ERR to ensure popd
and rm -rf run on any exit; then remove the final explicit rm -rf/popd at the
end (or keep popd only inside cleanup) so cleanup is centralized and always runs
even on failure.
- Line 27: The command building cni_pkg uses shell interpolation into jq which
can be fragile; update the call that constructs cni_pkg (the line invoking
copr-cli list-packages "${COPR_REPO_NAME}" | jq -r ...) to pass the package name
via jq's --arg (referencing _package_name and COPR_REPO_NAME) and use that $arg
inside the jq filter instead of embedding the shell variable, ensuring
safer/idiomatic variable interpolation.

In `@src/copr/copr-cli.Containerfile`:
- Around line 9-10: The Dockerfile copies cni/containernetworking-plugins.spec
twice—once to / and again to /cni/—but the build uses the /cni/ location; remove
the redundant copy from the first COPY (the line that currently copies
create-build.sh microshift-io-dependencies.sh
cni/containernetworking-plugins.spec /) so only create-build.sh and
microshift-io-dependencies.sh are copied there and leave the second COPY that
places cni/containernetworking-plugins.spec into /cni/ (used by cni/build.sh via
${_scriptdir}).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f4b006fe-7cfd-4086-8518-a3ec324c2923

📥 Commits

Reviewing files that changed from the base of the PR and between 0afea9f and bb2c912.

📒 Files selected for processing (9)
  • .github/workflows/nightly-copr.yaml
  • docs/run.md
  • src/copr/cni/build.sh
  • src/copr/cni/containernetworking-plugins.spec
  • src/copr/copr-cli.Containerfile
  • src/copr/copr.mk
  • src/copr/create-build.sh
  • src/copr/microshift-io-dependencies.sh
  • src/quickrpm.sh
🚧 Files skipped from review as they are similar to previous changes (3)
  • src/quickrpm.sh
  • src/copr/microshift-io-dependencies.sh
  • docs/run.md

Copy link

@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

🧹 Nitpick comments (2)
src/copr/cni/build.sh (1)

41-44: Use an EXIT trap for temp-dir cleanup.

Cleanup currently runs only at the end of the success path. Add a trap so failures don’t leak temp directories.

Suggested refactor
 temp_dir="$(mktemp -d "/tmp/containernetworking-plugins-${version}.XXXXXX")"
 cp "${_scriptdir}/containernetworking-plugins.spec" "${temp_dir}/"
 
 pushd "${temp_dir}" >/dev/null
+cleanup() {
+    popd >/dev/null || true
+    rm -rf "${temp_dir}"
+}
+trap cleanup EXIT
@@
-popd >/dev/null
-rm -rf "${temp_dir}"

Also applies to: 83-84

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/copr/cni/build.sh` around lines 41 - 44, The script currently creates
temp_dir with temp_dir="$(mktemp -d ...)" and copies files then pushd into it,
but cleanup only runs on the success path; add an EXIT trap to remove the
temp_dir on script exit (and optionally on ERR) to avoid leaking directories:
define a cleanup function that pops the directory if needed and removes
"${temp_dir}", then register it with trap 'cleanup' EXIT (or trap 'cleanup' ERR
EXIT) immediately after temp_dir is created so any early exit also triggers
removal; update references around temp_dir, pushd/popd and the existing cleanup
at lines referencing 83-84 to rely on this trap.
.github/workflows/nightly-copr.yaml (1)

28-56: Consider deduplicating COPR-config bootstrap logic.

The same 2-line secret-file setup is repeated across jobs. A small composite action (or Make target wrapper) would reduce drift.

Also applies to: 78-108, 186-195

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/nightly-copr.yaml around lines 28 - 56, The COPR_CONFIG
secret-file bootstrap (echo "${COPR_CONFIG}" > /tmp/copr-config and the
surrounding env/COPR_CONFIG usage) is duplicated across multiple jobs (see the
jobs that call make copr-dependencies and make copr-cni); extract that two-line
setup into a reusable unit — either create a small composite GitHub Action
(e.g., actions/bootstrap-copr-config) or add a Makefile wrapper target (e.g.,
make copr-bootstrap) that writes the secret to /tmp/copr-config and exposes
COPR_CONFIG=/tmp/copr-config, then replace the repeated blocks in the jobs that
invoke the make targets copr-dependencies and copr-cni (and the other
occurrences you noted) to call the new action/target instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/nightly-copr.yaml:
- Around line 31-37: The workflow currently writes the COPR_CONFIG secret to
/tmp/copr-config via plain redirection (echo "${COPR_CONFIG}" >
/tmp/copr-config) in multiple run blocks, creating a world-readable file; change
each occurrence to create the file with restricted permissions using a command
that sets mode 600 (e.g., use install -m 600 or equivalent) so the file is only
readable by the runner user, keeping the same variable (COPR_CONFIG) and target
path (/tmp/copr-config) and update all five occurrences in the run sections that
contain the COPR_CONFIG write.

In `@src/copr/cni/build.sh`:
- Around line 18-25: The curl call that sets latest_tag should be made fail-fast
and validated: change the curl invocation used to populate latest_tag (the
command assigning latest_tag) to include error flags (-fsSL) and a retry option
(--retry with a small count) so network/API failures surface immediately, then
check that latest_tag is non-empty before using version (the variable derived
from latest_tag) and if it's empty print a clear error via echo to stderr and
exit non-zero; ensure the validation occurs right after the latest_tag
assignment and before computing version.

---

Nitpick comments:
In @.github/workflows/nightly-copr.yaml:
- Around line 28-56: The COPR_CONFIG secret-file bootstrap (echo
"${COPR_CONFIG}" > /tmp/copr-config and the surrounding env/COPR_CONFIG usage)
is duplicated across multiple jobs (see the jobs that call make
copr-dependencies and make copr-cni); extract that two-line setup into a
reusable unit — either create a small composite GitHub Action (e.g.,
actions/bootstrap-copr-config) or add a Makefile wrapper target (e.g., make
copr-bootstrap) that writes the secret to /tmp/copr-config and exposes
COPR_CONFIG=/tmp/copr-config, then replace the repeated blocks in the jobs that
invoke the make targets copr-dependencies and copr-cni (and the other
occurrences you noted) to call the new action/target instead.

In `@src/copr/cni/build.sh`:
- Around line 41-44: The script currently creates temp_dir with
temp_dir="$(mktemp -d ...)" and copies files then pushd into it, but cleanup
only runs on the success path; add an EXIT trap to remove the temp_dir on script
exit (and optionally on ERR) to avoid leaking directories: define a cleanup
function that pops the directory if needed and removes "${temp_dir}", then
register it with trap 'cleanup' EXIT (or trap 'cleanup' ERR EXIT) immediately
after temp_dir is created so any early exit also triggers removal; update
references around temp_dir, pushd/popd and the existing cleanup at lines
referencing 83-84 to rely on this trap.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 39a5a86f-080c-4e4a-8e4f-39c59464e7f2

📥 Commits

Reviewing files that changed from the base of the PR and between 30ae284 and f35b77f.

📒 Files selected for processing (9)
  • .github/workflows/nightly-copr.yaml
  • docs/run.md
  • src/copr/cni/build.sh
  • src/copr/cni/containernetworking-plugins.spec
  • src/copr/copr-cli.Containerfile
  • src/copr/copr.mk
  • src/copr/create-build.sh
  • src/copr/microshift-io-dependencies.sh
  • src/quickrpm.sh
🚧 Files skipped from review as they are similar to previous changes (5)
  • src/copr/copr.mk
  • docs/run.md
  • src/copr/create-build.sh
  • src/copr/microshift-io-dependencies.sh
  • src/copr/copr-cli.Containerfile

Comment on lines +18 to +25
latest_tag=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/containernetworking/plugins/releases/latest | jq -r '.tag_name')

echo "### containernetworking/plugins latest tag: '${latest_tag}'"
version="${latest_tag#v}"

Copy link

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:

# Check if file exists and read lines around 18-25
if [ -f src/copr/cni/build.sh ]; then
  echo "=== File exists ===" 
  wc -l src/copr/cni/build.sh
  echo "=== Lines 15-30 ===" 
  sed -n '15,30p' src/copr/cni/build.sh
else
  echo "File not found"
  find . -name "build.sh" -type f 2>/dev/null | head -20
fi

Repository: microshift-io/microshift

Length of output: 907


🏁 Script executed:

# Check if shellcheck is available and test the current code snippet
shellcheck --version 2>/dev/null || echo "shellcheck not available in sandbox"

Repository: microshift-io/microshift

Length of output: 206


🏁 Script executed:

# Create a test script with the current code snippet and check with shellcheck
cat > /tmp/current_code.sh << 'EOF'
#!/bin/bash
latest_tag=$(curl -L \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/containernetworking/plugins/releases/latest | jq -r '.tag_name')

echo "### containernetworking/plugins latest tag: '${latest_tag}'"
version="${latest_tag#v}"
EOF

echo "=== Shellcheck on current code ==="
shellcheck /tmp/current_code.sh || echo "Exit code: $?"

Repository: microshift-io/microshift

Length of output: 371


🏁 Script executed:

# Create a test script with the suggested fix and check with shellcheck
cat > /tmp/suggested_code.sh << 'EOF'
#!/bin/bash
latest_tag="$(curl -fsSL --retry 3 --retry-delay 2 \
  -H "Accept: application/vnd.github+json" \
  -H "X-GitHub-Api-Version: 2022-11-28" \
  https://api.github.com/repos/containernetworking/plugins/releases/latest | jq -r '.tag_name // empty')"

if [[ -z "${latest_tag}" ]]; then
  echo "ERROR: unable to resolve latest containernetworking/plugins tag"
  exit 1
fi

echo "### containernetworking/plugins latest tag: '${latest_tag}'"
version="${latest_tag#v}"
EOF

echo "=== Shellcheck on suggested code ==="
shellcheck /tmp/suggested_code.sh || echo "Exit code: $?"

Repository: microshift-io/microshift

Length of output: 376


🏁 Script executed:

# Verify the full file passes shellcheck
echo "=== Shellcheck on full file ==="
shellcheck src/copr/cni/build.sh || echo "Exit code: $?"

Repository: microshift-io/microshift

Length of output: 99


Add fail-fast validation for GitHub API response.

The current code silently accepts empty or null tag_name from the API, causing failures later in copr-cli calls with unclear error messages. Add curl error flags (-fsSL, --retry), validate that latest_tag is non-empty, and exit immediately if resolution fails.

Suggested fix
-latest_tag=$(curl -L \
+latest_tag="$(curl -fsSL --retry 3 --retry-delay 2 \
   -H "Accept: application/vnd.github+json" \
   -H "X-GitHub-Api-Version: 2022-11-28" \
-  https://api.github.com/repos/containernetworking/plugins/releases/latest | jq -r '.tag_name')
+  https://api.github.com/repos/containernetworking/plugins/releases/latest | jq -r '.tag_name // empty')"
+
+if [[ -z "${latest_tag}" ]]; then
+  echo "ERROR: unable to resolve latest containernetworking/plugins tag"
+  exit 1
+fi
📝 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
latest_tag=$(curl -L \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/containernetworking/plugins/releases/latest | jq -r '.tag_name')
echo "### containernetworking/plugins latest tag: '${latest_tag}'"
version="${latest_tag#v}"
latest_tag="$(curl -fsSL --retry 3 --retry-delay 2 \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/containernetworking/plugins/releases/latest | jq -r '.tag_name // empty')"
if [[ -z "${latest_tag}" ]]; then
echo "ERROR: unable to resolve latest containernetworking/plugins tag"
exit 1
fi
echo "### containernetworking/plugins latest tag: '${latest_tag}'"
version="${latest_tag#v}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/copr/cni/build.sh` around lines 18 - 25, The curl call that sets
latest_tag should be made fail-fast and validated: change the curl invocation
used to populate latest_tag (the command assigning latest_tag) to include error
flags (-fsSL) and a retry option (--retry with a small count) so network/API
failures surface immediately, then check that latest_tag is non-empty before
using version (the variable derived from latest_tag) and if it's empty print a
clear error via echo to stderr and exit non-zero; ensure the validation occurs
right after the latest_tag assignment and before computing version.

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.

1 participant