Skip to content

chore(rbac): add events:create and jobs:patch/get permissions for EvalHub - #842

Merged
ruivieira merged 2 commits into
trustyai-explainability:dev/RHAI-277from
ruivieira:RHAI-277
Aug 1, 2026
Merged

chore(rbac): add events:create and jobs:patch/get permissions for EvalHub#842
ruivieira merged 2 commits into
trustyai-explainability:dev/RHAI-277from
ruivieira:RHAI-277

Conversation

@ruivieira

@ruivieira ruivieira commented Aug 1, 2026

Copy link
Copy Markdown
Member

Add two new ClusterRoles for the EvalHub ServiceAccount:

  • evalhub-events: grants events create, so the EvalHub server can emit Kubernetes Events against backing Job resources on evaluation lifecycle transitions (EvaluationStarted, EvaluationCompleted, EvaluationFailed, EvaluationThresholdViolated)
  • evalhub-jobs-writer extended with get and patch verbs, so the server can read-modify-patch the trustyai.opendatahub.io/evaluation-phase label on running Jobs

Both new ClusterRoleBindings are added to the OPA policy allowlist. No functional code changes; this is the RBAC prerequisite for RHAI-277.

Summary by CodeRabbit

  • Bug Fixes
    • EvalHub can now create and publish Kubernetes events.
    • Improved job management permissions, including retrieving and updating batch jobs.
    • Added RBAC configuration to ensure EvalHub event access is correctly authorized across supported deployments.

…lHub ServiceAccount

Add two new ClusterRoles for the EvalHub ServiceAccount:
- evalhub-events: grants events create, so the EvalHub server can emit
  Kubernetes Events against backing Job resources on evaluation lifecycle
  transitions (EvaluationStarted, EvaluationCompleted, EvaluationFailed,
  EvaluationThresholdViolated)
- evalhub-jobs-writer extended with get and patch verbs, so the server can
  read-modify-patch the trustyai.opendatahub.io/evaluation-phase label on
  running Jobs

Both new ClusterRoleBindings are added to the OPA policy allowlist.
No functional code changes; this is the RBAC prerequisite for RHAI-277.
@ruivieira ruivieira self-assigned this Aug 1, 2026
@ruivieira ruivieira added the kind/enhancement New feature or request label Aug 1, 2026
@openshift-ci

openshift-ci Bot commented Aug 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:

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 Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

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

Review profile: CHILL

Plan: Pro Plus

Run ID: 4d6a21aa-7159-4725-ae0d-f6ec667c5ede

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:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This change adds EvalHub event RBAC resources, registers them in Kustomize, updates RBAC policy allowlists, and permits the jobs writer role to get and patch batch jobs.

Changes

EvalHub RBAC

Layer / File(s) Summary
Event permissions and registration
config/components/evalhub/rbac/evalhub_events_role.yaml, config/components/evalhub/rbac/evalhub_events_binding.yaml, config/components/evalhub/kustomization.yaml, policy/rbac.rego
Adds the evalhub-events ClusterRole and binding. Registers both resources. Adds prefixed and unprefixed binding allowlist entries.
Batch job writer permissions
config/components/evalhub/rbac/evalhub_jobs_writer_role.yaml
Adds get and patch permissions for batch jobs.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested labels: lgtm

Suggested reviewers: robgeada, abeltramo

🚥 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 summarizes the main EvalHub RBAC changes: event creation and job get/patch permissions.
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.

@ruivieira

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 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 `@config/components/evalhub/rbac/evalhub_events_role.yaml`:
- Around line 15-17: Add the patch verb to the core events rule in the EvalHub
events RBAC configuration, preserving the existing create permission so
EventRecorder can update existing event objects.
🪄 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 Plus

Run ID: c40c7e65-db5a-4f7c-b9ce-d7cb7c7c9ef0

📥 Commits

Reviewing files that changed from the base of the PR and between 73073b4 and 6652404.

📒 Files selected for processing (5)
  • config/components/evalhub/kustomization.yaml
  • config/components/evalhub/rbac/evalhub_events_binding.yaml
  • config/components/evalhub/rbac/evalhub_events_role.yaml
  • config/components/evalhub/rbac/evalhub_jobs_writer_role.yaml
  • policy/rbac.rego

Comment thread config/components/evalhub/rbac/evalhub_events_role.yaml Outdated
@ruivieira
ruivieira merged commit 6c493ae into trustyai-explainability:dev/RHAI-277 Aug 1, 2026
6 checks passed
@ruivieira
ruivieira deleted the RHAI-277 branch August 1, 2026 12:42
ruivieira added a commit that referenced this pull request Aug 6, 2026
…lHub (#842) (#843)

* chore(rbac): add events:create and jobs:patch/get permissions for EvalHub ServiceAccount

Add two new ClusterRoles for the EvalHub ServiceAccount:
- evalhub-events: grants events create, so the EvalHub server can emit
  Kubernetes Events against backing Job resources on evaluation lifecycle
  transitions (EvaluationStarted, EvaluationCompleted, EvaluationFailed,
  EvaluationThresholdViolated)
- evalhub-jobs-writer extended with get and patch verbs, so the server can
  read-modify-patch the trustyai.opendatahub.io/evaluation-phase label on
  running Jobs

Both new ClusterRoleBindings are added to the OPA policy allowlist.
No functional code changes; this is the RBAC prerequisite for RHAI-277.

* fix(rbac): add patch verb to evalhub-events ClusterRole for EventRecorder deduplication
ruivieira added a commit that referenced this pull request Aug 6, 2026
…n failures (RHAI-278) (#846)

* chore(rbac): add events:create and jobs:patch/get permissions for EvalHub (#842)

* chore(rbac): add events:create and jobs:patch/get permissions for EvalHub ServiceAccount

Add two new ClusterRoles for the EvalHub ServiceAccount:
- evalhub-events: grants events create, so the EvalHub server can emit
  Kubernetes Events against backing Job resources on evaluation lifecycle
  transitions (EvaluationStarted, EvaluationCompleted, EvaluationFailed,
  EvaluationThresholdViolated)
- evalhub-jobs-writer extended with get and patch verbs, so the server can
  read-modify-patch the trustyai.opendatahub.io/evaluation-phase label on
  running Jobs

Both new ClusterRoleBindings are added to the OPA policy allowlist.
No functional code changes; this is the RBAC prerequisite for RHAI-277.

* fix(rbac): add patch verb to evalhub-events ClusterRole for EventRecorder deduplication

* feat(evalhub): emit events for job infrastructure failures (#844)

* feat(evalhub): emit events for job infrastructure failures

Patch evaluation-phase=Failed label and evaluation-status annotation on
Job resources. Include deduplication logic to skip event emission if the
EvalHub server has already marked the failure.

* fix(evalhub): emit EvaluationFailed event only after successful EvalHub POST

* test(evalhub): add lifecycle unit tests for failure reconciler event emission (RHOAIENG-80114) (#845)

* feat(evalhub): emit events for job infrastructure failures

Patch evaluation-phase=Failed label and evaluation-status annotation on
Job resources. Include deduplication logic to skip event emission if the
EvalHub server has already marked the failure.

* fix(evalhub): emit EvaluationFailed event only after successful EvalHub POST

* test(evalhub): add lifecycle unit tests for failure reconciler event emission (RHOAIENG-80114)

Cover the full Reconcile() path for EvalHubEvaluationJobFailureReconciler and
EvalHubEvaluationFailedKueueWorkloadsReconciler using fake.Client and
record.FakeRecorder. Tests use a local httptest.Server to absorb EvalHub
POST calls and an interceptor to capture the evaluation-phase=Failed label
patch before job deletion.

Cases added:
- dedup: server already set evaluation-phase=Failed → no operator event
- OOM-killed adapter container → EvaluationFailed event + label patch + job cleanup
- ErrImagePull on init container → EvaluationFailed event + label patch + job cleanup
- Kueue QuotaReserved=Inadmissible → EvaluationFailed event + job label + workload annotation

* fix(evalhub): prevent duplicate POST and Event on Kueue workload retry

Annotate the Workload before emitting the Event and patching Job labels
so that workloadFailedEventAlreadyReported acts as the primary dedup
gate on retry. Previously, if both patchJobFailureLabels and
annotateWorkloadReported failed after a successful POST, the next
reconcile would re-POST to EvalHub and re-emit the Event.

* fix(evalhub): retry Job failure labels after partial Workload commit

When the Workload annotation succeeds but patchJobFailureLabels fails,
the Job permanently lacks the evaluation-phase and evaluation-status
metadata. Requeue on patchJobFailureLabels failure and add a retry
branch that patches only the Job labels when the Workload annotation
is already present.

* fix(evalhub): clean up Job when server already handled failure

The serverAlreadyHandledFailure early-return path skipped Job deletion,
leaving failed Jobs in the namespace indefinitely. Add the same
deleteEvalHubFailureSyncedJob call that the failureAlreadyReported path
already performs.

* docs(evalhub): clarify evalhub-events role binding target

The role is currently bound to the operator SA but is intended for the
EvalHub server SA once RHAI-277 lands. Update the comment to reflect
the current state and planned rebinding.

* fix(evalhub): prevent duplicate POST and Event on Job failure retry

When promotePatch failed, the retry path re-executed the POST to
EvalHub and re-emitted the Kubernetes Event because failurePendingReport
only skipped the pending-annotation write. Move the POST inside the
!failurePendingReport block so retries skip it, and move Eventf after
promotePatch so it only fires once the promote succeeds.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant