Skip to content

feat: add prepare and cleanup steps for rhaiis project - #106

Closed
MML-coder wants to merge 17 commits into
openshift-psap:mainfrom
MML-coder:rhaiis-prepare-steps
Closed

feat: add prepare and cleanup steps for rhaiis project#106
MML-coder wants to merge 17 commits into
openshift-psap:mainfrom
MML-coder:rhaiis-prepare-steps

Conversation

@MML-coder

@MML-coder MML-coder commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Rewrite prepare_rhaiis.py with a 9-step prepare sequence:
    • Cluster-level: NFD, GPU operator, KServe (via RHOAI) — skips if CSV already exists to avoid triggering upgrades
    • Per-run: namespace with forge labels, SA, SCC (anyuid), vault-based image pull secret, model PVC
  • Add config.d/platform.yaml with operator specs, DSC config, SCC/PVC/vault settings
  • Add vault definition psap-rhaiis-image-pull for container registry credentials
  • Update ci.py with preflight CRD validation for KServe
  • Enhanced cleanup: also deletes InferenceServices and ServingRuntimes
  • Default image_pull_secret: rhaiis-image-pull — no longer needs FournosJob override

Cluster-side prerequisite

The vault secret vault-psap-rhaiis-image-pull must exist in psap-secrets on psap-automation with the fournos.dev/vault-entry=true label. See Fournos README "Adding a project vault secret" section.

Test plan

  • Full pipeline rhaiis-mlflow-full-tfsnx succeeded on forge-smoke-testing
  • Operators skipped (already installed) — prepare completed in ~22s
  • SCC policy applied, image pull secret created from vault, PVC created
  • Preflight passed (KServe CRDs found)
  • Test phase completed (~41m), post-cleanup + export succeeded

Summary by CodeRabbit

  • New Features
    • Added comprehensive orchestration preflight validation to check required CRDs and the target namespace, and optionally verify image pull secrets and storage.
    • Expanded orchestration setup to install/bootstrapping required operators and configure the benchmark namespace, service account, SCC policy, image pull secret, and model PVC when configured.
    • Extended cleanup with an option to also remove cluster operator subscriptions.
  • Bug Fixes
    • Improved failure handling so preflight now correctly returns non-zero when checks fail, preventing misleading “success” outcomes.
  • Chores
    • Updated platform and Vault configuration, including the image pull secret name and newly added registry credentials Vault.

The completed pipellne https://mlflow.apps.psap-automation.ibm.rhperfscale.org/#/experiments/233/runs/34cd9812b0a84004a6b2cfd58d23b436/artifacts?workspace=default

On the forge-smoke-testing, all operators were already installed, so the prepare step validated their presence by checking for existing CSVs and skipped installation:

  1. Operator nfd already installed in openshift-nfd, skipping
  2. Operator gpu-operator-certified already installed in nvidia-gpu-operator, skipping
  3. Operator rhcl-operator already installed in redhat-ods-operator, skipping
  4. Operator rhods-operator already installed in redhat-ods-operator, skipping

@openshift-ci

openshift-ci Bot commented Jul 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kpouget for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

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

This PR adds a cluster preflight validator, expands RHAIIS platform/Vault config, and replaces the orchestration entrypoints with operator bootstrap, namespace provisioning, secret/PVC creation, and cleanup of benchmark and operator resources.

Changes

RHAIIS platform preparation

Layer / File(s) Summary
CRD and namespace preflight
projects/rhaiis/orchestration/ci.py, projects/rhaiis/orchestration/runtime_config.py
preflight now loads platform config, checks required CRDs, namespace, image pull secret, and PVC existence, and returns 1 on failures or 0 on success; adds get_platform_config().
Platform config and Vault inputs
projects/rhaiis/orchestration/config.d/platform.yaml, projects/rhaiis/orchestration/config.d/rhaiis.yaml, projects/rhaiis/orchestration/config.yaml, vaults/psap-rhaiis-image-pull.yaml
Adds operator, KServe, label, prepare, cleanup, and required CRD settings; updates the deployment image pull secret; registers a Vault entry for pull credentials.
Prepare and cleanup entry points
projects/rhaiis/orchestration/prepare_rhaiis.py
Reworks the top-level orchestration flow to verify oc access, run operator setup, provision runtime resources, and optionally clean up subscriptions and benchmark resources.
Operator subscription helpers
projects/rhaiis/orchestration/prepare_rhaiis.py
Adds operator spec derivation, CSV lookup, and subscription installation logic with success and error handling.
NFD, GPU operator, and KServe preparation
projects/rhaiis/orchestration/prepare_rhaiis.py
Adds operator bootstrap flows for NFD and GPU, plus KServe setup through RHCL/RHOAI and DataScienceCluster application.
Namespace, secret, and PVC provisioning
projects/rhaiis/orchestration/prepare_rhaiis.py
Adds namespace creation with labels, service account and SCC setup, image pull secret creation from Vault content, and model PVC rendering/application.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ci.py
  participant runtime_config
  participant OpenShift Cluster

  ci.py->>runtime_config: get_platform_config()
  ci.py->>OpenShift Cluster: oc_resource_exists for CRDs and namespace
  ci.py->>OpenShift Cluster: oc_resource_exists for image pull secret and PVC
  ci.py->>ci.py: collect errors, return status
Loading
sequenceDiagram
  participant prepare_rhaiis.py
  participant OpenShift Cluster
  participant Vault

  prepare_rhaiis.py->>OpenShift Cluster: oc whoami
  prepare_rhaiis.py->>OpenShift Cluster: install/bootstrap operators
  prepare_rhaiis.py->>OpenShift Cluster: create namespace, service account, SCC binding
  prepare_rhaiis.py->>Vault: resolve image pull secret content path
  prepare_rhaiis.py->>OpenShift Cluster: create dockerconfigjson secret and model PVC
  prepare_rhaiis.py->>OpenShift Cluster: delete runtime resources during cleanup
Loading

Possibly related PRs

  • openshift-psap/forge#68: Also introduces the RHAIIS CI/orchestration workflow that this PR extends with preflight and richer cleanup behavior.
  • openshift-psap/forge#89: Also touches projects/rhaiis/orchestration/ci.py cleanup handling and the prepare_rhaiis.cleanup(...) call path.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding prepare and cleanup support for the rhaiis project.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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.

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

🤖 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 `@projects/rhaiis/orchestration/config.d/platform.yaml`:
- Around line 31-34: The SCC is currently bound to a hardcoded service account
that may never be created because `rhaiis.deploy.service_account_name` can be
empty and `ensure_service_account()` skips creation in that case. Update
`prepare.scc.service_account` to use the same source of truth as the deploy
service account, or give `rhaiis.deploy.service_account_name` a non-empty
default so both `prepare.scc` and `ensure_service_account()` reference a real,
consistent service account.

In `@projects/rhaiis/orchestration/prepare_rhaiis.py`:
- Around line 71-80: The _operator_csv_exists helper is treating any matching
CSV name as installed, which can skip operator installation before the CSV is
ready. Update _operator_csv_exists in prepare_rhaiis.py to inspect CSV status
and only return true when the matching CSV is in Succeeded phase, then make the
operator-installation check around the current package/CSV handling use that
readiness check instead of name matching alone.
- Around line 93-101: The call to cluster_deploy_operator.run in
prepare_rhaiis.py passes an unsupported artifact_dirname_suffix keyword, which
will raise TypeError before operator installation starts. Remove that argument
from the run invocation and keep the remaining parameters aligned with the
actual cluster_deploy_operator.run signature, using the existing package,
namespace, and operator_spec fields.
- Around line 216-217: The success log in prepare_rhaiis.py is unconditional
because the `oc("adm", "policy", "add-scc-to-user", ...)` call uses
`check=False`, so failures can still be reported as applied. Update the
`prepare_rhaiis` flow around the SCC binding call to either let the command
raise on failure or explicitly inspect the return status and only emit
`logger.info("Applied SCC %s to SA %s in %s", ...)` when the `oc adm policy`
operation succeeds.
- Around line 291-298: The `prepare_rhaiis` flow currently skips PVC creation
and still returns success when `deploy_cfg.storage_pvc` is set but
`model_pvc.storage_class` is missing, leaving the deployment without its
required volume. Update the PVC handling in `prepare_rhaiis` so that a
configured model PVC is treated as required: if the PVC is expected but cannot
be provisioned because `storage_class` is absent, raise an error or fail the
prepare step instead of logging a warning and returning. Keep the early-exit
only for cases where no model PVC was requested.
- Around line 240-248: The image pull secret lookup in prepare_rhaiis.py
currently logs and returns when vault content is missing, which allows prepare
to succeed even though deploy_cfg.image_pull_secret was requested. Update the
secret-creation flow around the vault.get_vault_content_path check to treat
missing Vault content or an absent dockerconfig_path as a hard failure for the
configured image pull secret, and make the prepare_rhaiis path raise/abort
instead of returning silently. Use the existing vault_name, vault_content, and
deploy_cfg.image_pull_secret handling in this function 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: defaults

Review profile: CHILL

Plan: Pro

Run ID: a733fb85-6249-44b6-af25-ed6f83154feb

📥 Commits

Reviewing files that changed from the base of the PR and between 48ac14c and 8ee72fe.

📒 Files selected for processing (7)
  • projects/rhaiis/orchestration/ci.py
  • projects/rhaiis/orchestration/config.d/platform.yaml
  • projects/rhaiis/orchestration/config.d/rhaiis.yaml
  • projects/rhaiis/orchestration/config.yaml
  • projects/rhaiis/orchestration/prepare_rhaiis.py
  • projects/rhaiis/orchestration/runtime_config.py
  • vaults/psap-rhaiis-image-pull.yaml

Comment thread projects/rhaiis/orchestration/config.d/platform.yaml Outdated
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py Outdated
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py Outdated
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py Outdated
Comment on lines +291 to +298
pvc_cfg = prepare_cfg.get("model_pvc", {})
storage_class = pvc_cfg.get("storage_class", "")
size = pvc_cfg.get("size", "300Gi")
access_mode = pvc_cfg.get("access_mode", "ReadWriteOnce")

if not storage_class:
logger.warning("No storage_class configured for model PVC, skipping creation")
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Fail prepare when a configured model PVC cannot be provisioned.

When deploy_cfg.storage_pvc is set and the PVC does not already exist, missing model_pvc.storage_class leaves the run without its required volume while prepare still exits 0.

Proposed fix
     if not storage_class:
-        logger.warning("No storage_class configured for model PVC, skipping creation")
-        return
+        raise ValueError(
+            "platform.prepare.model_pvc.storage_class is required when rhaiis.deploy.storage_pvc is configured"
+        )
📝 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
pvc_cfg = prepare_cfg.get("model_pvc", {})
storage_class = pvc_cfg.get("storage_class", "")
size = pvc_cfg.get("size", "300Gi")
access_mode = pvc_cfg.get("access_mode", "ReadWriteOnce")
if not storage_class:
logger.warning("No storage_class configured for model PVC, skipping creation")
return
pvc_cfg = prepare_cfg.get("model_pvc", {})
storage_class = pvc_cfg.get("storage_class", "")
size = pvc_cfg.get("size", "300Gi")
access_mode = pvc_cfg.get("access_mode", "ReadWriteOnce")
if not storage_class:
raise ValueError(
"platform.prepare.model_pvc.storage_class is required when rhaiis.deploy.storage_pvc is configured"
)
🤖 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 `@projects/rhaiis/orchestration/prepare_rhaiis.py` around lines 291 - 298, The
`prepare_rhaiis` flow currently skips PVC creation and still returns success
when `deploy_cfg.storage_pvc` is set but `model_pvc.storage_class` is missing,
leaving the deployment without its required volume. Update the PVC handling in
`prepare_rhaiis` so that a configured model PVC is treated as required: if the
PVC is expected but cannot be provisioned because `storage_class` is absent,
raise an error or fail the prepare step instead of logging a warning and
returning. Keep the early-exit only for cases where no model PVC was requested.

Comment thread projects/rhaiis/orchestration/ci.py Outdated
Comment on lines +91 to +94
REQUIRED_CRDS = [
"inferenceservices.serving.kserve.io",
"servingruntimes.serving.kserve.io",
]

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.

this should be in the config file (it's easier to control the list from there)

Comment thread projects/rhaiis/orchestration/ci.py Outdated
from projects.core.dsl.utils.k8s import oc_resource_exists

logger.info("Starting preflight checks")
missing = [crd for crd in REQUIRED_CRDS if not oc_resource_exists("crd", crd)]

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.

will be updated with config.project.get_config("somewhere.required_crds") instead of REQUIRED_CRDS

Comment thread projects/rhaiis/orchestration/config.yaml
return 0


def cleanup() -> int:

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.

the cleanup should delete all the components that have been installed, to bring the cluster back to a fresh state
More or less at least. See in llm-d, for time sake I don't uninstall the GPU operator and a few other core operators

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.

I din't think this has been addressed

Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py Outdated
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py Outdated
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py Outdated
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py Outdated
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py Outdated
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py Outdated
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py Outdated
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py Outdated
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py Outdated
MML-coder added a commit to MML-coder/forge-1 that referenced this pull request Jul 7, 2026
- Remove check=False on SCC command (fail on error, not silently)
- Fail hard when vault/secret is missing (no silent swallow)
- Use oc create secret generic --from-file instead of base64 manifest
- Check CSV phase is Succeeded before skipping operator install
- SCC uses deploy_cfg.service_account_name as single source of truth
- Move REQUIRED_CRDS to platform.yaml config
- Move namespace/PVC labels to platform.yaml config
- Remove hardcoded defaults for PVC size/access_mode
- Let K8s use default storage class when not configured
- Add preflight validation for namespace, secret, PVC
MML-coder added 7 commits July 7, 2026 17:42
Rewrite prepare_rhaiis.py with a 9-step prepare sequence:
- Cluster-level: NFD, GPU operator, KServe (via RHOAI) installation
- Per-run: namespace, SA, SCC policy, vault-based image pull secret, PVC

Add config.d/platform.yaml with operator specs, DSC config, and
prepare settings (SCC, PVC storage class, vault references).

Add vault definition for rhaiis image pull credentials
(psap-rhaiis-image-pull) following existing Fournos vault pattern.

Update ci.py with @agent_review_on_failure decorators and preflight
CRD validation for KServe InferenceService/ServingRuntime.

Update cleanup to also delete InferenceServices and ServingRuntimes.
The decorator requires agentic config (model_key etc) that rhaiis
does not use. Remove it to unblock the prepare step.
Avoids triggering operator upgrades on clusters where operators are
already installed and working. Checks for existing CSV by package
name before calling cluster_deploy_operator.
- Remove check=False on SCC command (fail on error, not silently)
- Fail hard when vault/secret is missing (no silent swallow)
- Use oc create secret generic --from-file instead of base64 manifest
- Check CSV phase is Succeeded before skipping operator install
- SCC uses deploy_cfg.service_account_name as single source of truth
- Move REQUIRED_CRDS to platform.yaml config
- Move namespace/PVC labels to platform.yaml config
- Remove hardcoded defaults for PVC size/access_mode
- Let K8s use default storage class when not configured
- Add preflight validation for namespace, secret, PVC
@MML-coder
MML-coder force-pushed the rhaiis-prepare-steps branch from 60811ad to a133fc9 Compare July 7, 2026 21:43
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py
errors.append(f"PVC not found: {pvc_name} in {ns}")
elif pvc_name:
logger.info("PVC found: %s in %s", pvc_name, ns)

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.

the PVC can be created & populated in the test step (in addition to the prepare step)

@kpouget

kpouget commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

thanks, looks good overall, added some comments

MML-coder added 2 commits July 8, 2026 10:48
- Skip operator install with warning when CSV exists but is not
  Succeeded (Pending/Failed), avoiding 15-min timeout on stuck upgrades
- Add preflight validation for namespace, secret, PVC existence
- Move required CRDs to platform.yaml config
- Move namespace/PVC labels to platform.yaml config
- Remove hardcoded defaults for PVC size/access_mode
- Remove check=False on SCC (fail on error)
- Fail hard on missing vault content
- Use oc create secret generic --from-file
- Let K8s use default storage class when not configured
- SCC uses deploy_cfg.service_account_name as source of truth
Tab/newline escape sequences in jsonpath may not work across all
oc versions. Use = and ; as delimiters instead. Add logging when
a CSV is found to aid debugging.
Comment thread projects/rhaiis/orchestration/prepare_rhaiis.py
MML-coder added 4 commits July 8, 2026 11:24
Per Kevin's review: if an operator CSV is not Succeeded, prepare
must fail — continuing will just delay the failure to the test step.
Also fix CSV jsonpath parsing to use reliable separators.
- Add operator cleanup following llm-d pattern: deletes operator
  subscriptions/CSVs while respecting cleanup.preserve_operators config
- post_cleanup now runs both namespace and operator cleanup
- Add log message when service account is not configured
The cleanup was reading preserve_operators from root config path
which doesn't exist (it's under platform.cleanup). This caused
ALL operators to be deleted including NFD and GPU which should
have been preserved.
ServiceMesh is a cluster prerequisite, not a project concern.
Must not be deleted during cleanup.
@kpouget

kpouget commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@MML-coder can you disable the cleanup of the GPU Operator?
that helps to reduce the time to prepare the cluster

MML-coder added 4 commits July 9, 2026 11:21
Pinned channel installed an old GPU operator version incompatible
with the cluster's NVIDIA driver. Use stable channel to match
llm-d's approach.
All operators (NFD, GPU, ServiceMesh, RHCL, RHOAI) are cluster
prerequisites and must not be deleted during pipeline cleanup.
Only namespace-level test resources should be cleaned up.
Per Kevin's feedback: RHOAI should be cleaned up so other tests can
install their own version. Only GPU operator, NFD, and ServiceMesh
are preserved (slow to reinstall / cluster prerequisites).
@kpouget

kpouget commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@Harshith-umesh I think this one can be closed

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.

3 participants