Skip to content

SDCICD-1864 Add bonfire CLI wrapper for ephemeral ROSA HCP cluster lifecycle#3274

Open
YiqinZhang wants to merge 1 commit into
openshift:mainfrom
YiqinZhang:SDCICD-1864
Open

SDCICD-1864 Add bonfire CLI wrapper for ephemeral ROSA HCP cluster lifecycle#3274
YiqinZhang wants to merge 1 commit into
openshift:mainfrom
YiqinZhang:SDCICD-1864

Conversation

@YiqinZhang

@YiqinZhang YiqinZhang commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Introduces pkg/common/ephemeral — a new package that wraps the bonfire CLI and oc for managing ephemeral ROSA HCP cluster namespaces on the eng-prod management cluster.

JIRA: https://issues.redhat.com/browse/SDCICD-1864
Co-authored-by: Cursor

Summary by CodeRabbit

  • New Features
    • Added a new CLI for managing ephemeral ROSA HCP cluster namespaces.
    • You can now check for required tools, log in to a cluster, create and release reservations, fetch secret values, and clean up temporary access files.
    • The CLI also captures command output and environment settings to make external command execution more reliable.

@openshift-merge-bot

Copy link
Copy Markdown
Contributor

There are test jobs defined for this repository which are not configured to run automatically. Comment /test ? to see a list of all defined jobs. Review these jobs and use /test <job> to manually trigger jobs most likely to be impacted by the proposed changes.Comment /pipeline required to trigger all required & necessary jobs.

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: eddfa5b5-7582-498d-b6f0-b36d78ff8fd3

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

@openshift-ci

openshift-ci Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: YiqinZhang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 8, 2026
@YiqinZhang

Copy link
Copy Markdown
Contributor Author

/override ci/prow/hypershift-pr-check

@openshift-ci

openshift-ci Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@YiqinZhang: Overrode contexts on behalf of YiqinZhang: ci/prow/hypershift-pr-check

Details

In response to this:

/override ci/prow/hypershift-pr-check

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (2)
pkg/common/ephemeral/bonfire.go (2)

56-72: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Pin the crc-bonfire pip package version.

pip install --quiet crc-bonfire installs whatever is currently latest, risking unreproducible/broken builds if a new release changes behavior.

♻️ Suggested fix
-	if _, err := c.cmd.Run(ctx, nil, "pip", "install", "--quiet", "crc-bonfire"); err != nil {
+	if _, err := c.cmd.Run(ctx, nil, "pip", "install", "--quiet", "crc-bonfire==<pinned-version>"); err != nil {
🤖 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 `@pkg/common/ephemeral/bonfire.go` around lines 56 - 72, The InstallBonfire
method currently installs crc-bonfire without a version pin, which makes builds
non-reproducible. Update the pip install call in CLI.InstallBonfire to use a
fixed crc-bonfire version or otherwise source the version from a constant/config
so the installed package is stable across runs. Keep the existing LookPath
checks and logging, and only change the package spec used in the c.cmd.Run
invocation.

162-185: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Consider validating the parsed namespace format.

The heuristic returns the last non-log-prefixed line verbatim. A silent bonfire output-format change could yield a bogus "namespace" that later gets passed unchecked into ReleaseNamespace/GetSecretValue. A light regex check (e.g. ^ephemeral-[a-z0-9]+$) before returning would fail fast instead of propagating garbage.

🤖 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 `@pkg/common/ephemeral/bonfire.go` around lines 162 - 185, The parseNamespace
helper currently returns the last non-log-prefixed line without verifying it is
actually a namespace, so add a lightweight format check before returning from
parseNamespace. Validate the candidate string against the expected ephemeral
namespace pattern (for example, the ephemeral- prefix plus lowercase
alphanumerics) and return only if it matches; otherwise keep scanning or return
empty so invalid output does not flow into ReleaseNamespace or GetSecretValue.
🤖 Prompt for all review comments with 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.

Inline comments:
In `@pkg/common/ephemeral/bonfire.go`:
- Line 89: The Bonfire kubeconfig setup is always forcing TLS verification off
via the insecure skip flag. Update the ephemeral cluster configuration in
bonfire.go so this setting is configurable instead of hardcoded, with the
default keeping TLS verification enabled; use the relevant bonfire/kubeconfig
construction path around the insecure skip TLS option to make the flag optional.
- Line 56: The logging in CLI.InstallBonfire and the related helper calls still
uses stdlib log, which violates the structured logging guideline. Add a
logr.Logger to CLI (or pass one into InstallBonfire) and replace each
log.Print/log.Printf usage in this file with logger.Info/logger.Error calls
using structured key/value fields instead of formatted strings. Keep the changes
localized to the CLI methods and any helpers they call so all logging in this
file goes through logr/klog.
- Around line 76-95: The Login method in CLI is exposing the bearer token by
passing it directly to oc login via argv. Replace this token-in-arguments flow
with a file-backed kubeconfig/authentication approach in Login so the secret is
not visible to local process inspection, and keep the existing validation and
logging around serverURL and successful authentication.

---

Nitpick comments:
In `@pkg/common/ephemeral/bonfire.go`:
- Around line 56-72: The InstallBonfire method currently installs crc-bonfire
without a version pin, which makes builds non-reproducible. Update the pip
install call in CLI.InstallBonfire to use a fixed crc-bonfire version or
otherwise source the version from a constant/config so the installed package is
stable across runs. Keep the existing LookPath checks and logging, and only
change the package spec used in the c.cmd.Run invocation.
- Around line 162-185: The parseNamespace helper currently returns the last
non-log-prefixed line without verifying it is actually a namespace, so add a
lightweight format check before returning from parseNamespace. Validate the
candidate string against the expected ephemeral namespace pattern (for example,
the ephemeral- prefix plus lowercase alphanumerics) and return only if it
matches; otherwise keep scanning or return empty so invalid output does not flow
into ReleaseNamespace or GetSecretValue.
🪄 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: Repository YAML (base), Central YAML (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 5ea6770d-9614-4012-b659-f213f85ef51c

📥 Commits

Reviewing files that changed from the base of the PR and between 4a6edd8 and fe518a3.

📒 Files selected for processing (1)
  • pkg/common/ephemeral/bonfire.go

Comment thread pkg/common/ephemeral/bonfire.go
Comment thread pkg/common/ephemeral/bonfire.go
Comment thread pkg/common/ephemeral/bonfire.go Outdated
@YiqinZhang

Copy link
Copy Markdown
Contributor Author

/override ci/prow/hypershift-pr-check

@openshift-ci

openshift-ci Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@YiqinZhang: Overrode contexts on behalf of YiqinZhang: ci/prow/hypershift-pr-check

Details

In response to this:

/override ci/prow/hypershift-pr-check

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci

openshift-ci Bot commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

@YiqinZhang: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@YiqinZhang

Copy link
Copy Markdown
Contributor Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant