Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

OSAC-757: Update keycloak deployment manifests to match fulfillment-service changes - #286

Merged
openshift-merge-bot[bot] merged 4 commits into
osac-project:mainfrom
obochan-rh:OSAC-757/update-keycloak-manifests
Jul 2, 2026
Merged

openshift-merge-bot[bot] merged 4 commits into
osac-project:mainfrom
obochan-rh:OSAC-757/update-keycloak-manifests

Conversation

@obochan-rh

@obochan-rh obochan-rh commented Jun 17, 2026

Copy link
Copy Markdown

Summary

Aligns the osac-installer Keycloak realm configuration and supporting scripts with the service-account changes introduced in fulfillment-service PR #462.

  • Add osac-admin client & service-account user to realm.json — mirrors the new admin service-account client created in the fulfillment-service IT Helm chart. Also sets directAccessGrantsEnabled: false on osac-controller to match the client-credentials-only pattern.
  • Fix refresh-after-snapshot.sh — the old select(.serviceAccountsEnabled == true) now returns multiple clients; switched to explicit select(.clientId == "osac-controller") so the credential secret is always resolved unambiguously.
  • Fix sync-authconfig-rego.py & resync overlay AuthConfig policies — the base Rego now lists controller after admin in emergency_service_accounts, so the injection-point pattern was updated from admincontroller. Re-ran --fix to bring all four overlays in sync (adds controller SA, corrects comments, updates API endpoint names).

Changed files

File Change
prerequisites/keycloak/service/files/realm.json Add osac-admin client, service-account-osac-admin user, roles.client entry; set directAccessGrantsEnabled: false on osac-controller
scripts/refresh-after-snapshot.sh Hardcode osac-controller lookup instead of generic serviceAccountsEnabled query
scripts/sync-authconfig-rego.py Update Rego injection point pattern from admin to controller
overlays/{caas-ci,development,osac-integration,vmaas-ci}/kustomization.yaml Resync overlay Rego with base (emergency SA, API endpoints, comments)

Test plan

  • python scripts/sync-authconfig-rego.py exits 0 (no drift)
  • jq . prerequisites/keycloak/service/files/realm.json > /dev/null passes (valid JSON)
  • Deploy to a dev cluster and verify both osac-admin and osac-controller clients appear in the Keycloak admin console
  • Verify refresh-after-snapshot.sh correctly recreates the fulfillment-controller-credentials secret after a snapshot boot
  • Verify the fulfillment-service controller can authenticate using the osac-controller client credentials

Resolves: OSAC-757
Related: fulfillment-service PR #462

Summary by CodeRabbit

  • Chores
    • Updated the Keycloak realm configuration for osac by refining admin roles and service-account setup, and disabling direct access grants for the controller while keeping service accounts enabled.
    • Improved the fulfillment-controller credential refresh script to select and regenerate fulfillment credentials for a specific Keycloak client via a new environment variable, using the corresponding client secret.

@openshift-ci-robot

openshift-ci-robot commented Jun 17, 2026

Copy link
Copy Markdown

@obochan-rh: This pull request references OSAC-757 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the sub-task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

Aligns the osac-installer Keycloak realm configuration and supporting scripts with the service-account changes introduced in fulfillment-service PR #462.

  • Add osac-admin client & service-account user to realm.json — mirrors the new admin service-account client created in the fulfillment-service IT Helm chart. Also sets directAccessGrantsEnabled: false on osac-controller to match the client-credentials-only pattern.
  • Fix refresh-after-snapshot.sh — the old select(.serviceAccountsEnabled == true) now returns multiple clients; switched to explicit select(.clientId == "osac-controller") so the credential secret is always resolved unambiguously.
  • Fix sync-authconfig-rego.py & resync overlay AuthConfig policies — the base Rego now lists controller after admin in emergency_service_accounts, so the injection-point pattern was updated from admincontroller. Re-ran --fix to bring all four overlays in sync (adds controller SA, corrects comments, updates API endpoint names).

Changed files

File Change
prerequisites/keycloak/service/files/realm.json Add osac-admin client, service-account-osac-admin user, roles.client entry; set directAccessGrantsEnabled: false on osac-controller
scripts/refresh-after-snapshot.sh Hardcode osac-controller lookup instead of generic serviceAccountsEnabled query
scripts/sync-authconfig-rego.py Update Rego injection point pattern from admin to controller
overlays/{caas-ci,development,osac-integration,vmaas-ci}/kustomization.yaml Resync overlay Rego with base (emergency SA, API endpoints, comments)

Test plan

  • python scripts/sync-authconfig-rego.py exits 0 (no drift)
  • jq . prerequisites/keycloak/service/files/realm.json > /dev/null passes (valid JSON)
  • Deploy to a dev cluster and verify both osac-admin and osac-controller clients appear in the Keycloak admin console
  • Verify refresh-after-snapshot.sh correctly recreates the fulfillment-controller-credentials secret after a snapshot boot
  • Verify the fulfillment-service controller can authenticate using the osac-controller client credentials

Resolves: OSAC-757
Related: fulfillment-service PR #462

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
openshift-ci Bot requested review from trewest and tzumainn June 17, 2026 08:11
@obochan-rh
obochan-rh force-pushed the OSAC-757/update-keycloak-manifests branch from 26a82d3 to 7ccbebc Compare June 17, 2026 11:11
@coderabbitai

coderabbitai Bot commented Jun 17, 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

Adds an osac-admin Keycloak client and service account entries, disables direct access grants on osac-controller, and updates the refresh script to select the credential target via FC_CLIENT and resolve its secret from realm.json.

Changes

osac-admin client and credential script update

Layer / File(s) Summary
realm.json client and service account updates
prerequisites/keycloak/service/files/realm.json
Adds an osac-admin client-role entry, creates service-account-osac-admin, disables directAccessGrantsEnabled on osac-controller, and defines the osac-admin client with its secret and client settings.
refresh-after-snapshot.sh client selection
scripts/refresh-after-snapshot.sh
Adds FC_CLIENT with default osac-controller and updates create_fulfillment_credentials to derive FC_CLIENT_ID from it, then resolve the matching client secret from realm.json.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Suggested reviewers: jhernand, adriengentil


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 warning)

Check name Status Explanation Resolution
No-Hardcoded-Secrets ❌ Error realm.json includes hardcoded Keycloak client-secret literals for osac-controller and the new osac-admin client. Move client secrets out of realm.json and inject them from environment/secret management; regenerate them at deploy time.
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 (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: updating Keycloak deployment manifests to align with fulfillment-service service-account changes.
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.
No-Weak-Crypto ✅ Passed Only md5sum is used for file-change detection and HmacSHA1 is OTP config; no weak ciphers, custom crypto, or secret/token comparisons appear in changed files.
No-Injection-Vectors ✅ Passed Touched files are static config/shell lookups; no eval/exec, shell=True, os.system, yaml.load, pickle.loads, SQL concat, or DOM injection found.
Container-Privileges ✅ Passed Touched manifests and submodule diffs contain no privileged=true/hostPID/hostNetwork/hostIPC/SYS_ADMIN/allowPrivilegeEscalation=true; operator keeps allowPrivilegeEscalation:false and runAsNonRoot:...
No-Sensitive-Data-In-Logs ✅ Passed No added logging of secrets/tokens/PII found; the script logs client IDs and cluster metadata, but not credential values.
Ai-Attribution ✅ Passed No AI-tool mentions or attribution trailers appear in the PR text, changed files, or commit; no Co-Authored-By misuse found.
✨ 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.

@obochan-rh

Copy link
Copy Markdown
Author

/retest

Comment thread scripts/refresh-after-snapshot.sh

@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: 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 `@scripts/refresh-after-snapshot.sh`:
- Line 18: The FC_CLIENT variable is unconditionally assigned on line 18, which
overwrites any externally provided value and prevents the fallback logic on line
148 from ever being used. Replace the unconditional assignment of FC_CLIENT with
bash parameter-default assignment syntax to set the default value to
"osac-controller" only when FC_CLIENT is not already set externally. This allows
external configuration to take precedence while providing a fallback default
when needed.
🪄 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: osac-project/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: dc0b1bda-c9c5-425e-87ca-f2384b9458c6

📥 Commits

Reviewing files that changed from the base of the PR and between 7ccbebc and e7201c0.

📒 Files selected for processing (1)
  • scripts/refresh-after-snapshot.sh

Comment thread scripts/refresh-after-snapshot.sh Outdated
@obochan-rh

Copy link
Copy Markdown
Author

/retest

2 similar comments
@obochan-rh

Copy link
Copy Markdown
Author

/retest

@obochan-rh

Copy link
Copy Markdown
Author

/retest

@CrystalChun

Copy link
Copy Markdown
Contributor

/approve
/lgtm

@CrystalChun

Copy link
Copy Markdown
Contributor

/cc @adriengentil

@openshift-ci
openshift-ci Bot requested a review from adriengentil June 23, 2026 14:08
@omer-vishlitzky

Copy link
Copy Markdown
Contributor

🏗️ CI Triage: infra | Category: INFRA

Root cause: The CI job failed to acquire a bare metal machine from the OFCIR pool because no resources of type 'osac' were available.

Explanation: During the pre-flight phase, the e2e-vmaas-ofcir-acquire step attempted to lease a bare metal machine from the OFCIR pool to run the E2E tests. The OFCIR API returned a 404 error with the message 'No available resource found of type [osac]', indicating that all machines in the pool are currently in use. Because no machine could be acquired, the test execution was aborted and subsequent steps failed.

Evidence:

build-log.txt:

No available resource found of type [osac]

build-log.txt:

+ exit_with_failure 'Could not acquire CI resource: No available resource found of type [osac]'

Suggestion: Retrigger the job later when bare metal machines become available in the pool.


Prow job | Build 2068687561886273536 | 🤖 triagent

For deeper investigation, use the /osac-debug-e2e skill with this build ID.

@eliorerz

Copy link
Copy Markdown
Contributor

/hold

@eliorerz

Copy link
Copy Markdown
Contributor

@obochan-rh I've set that pr on hold so we can test it properly.
Soon (I believe in a few hours) we will have a e2e full installation test on the installer and I want it to pass before merging - see #357.

@obochan-rh

Copy link
Copy Markdown
Author

@eliorerz can we unhold it and run the test if needed ?

@eliorerz

Copy link
Copy Markdown
Contributor

/test ?

@github-actions

Copy link
Copy Markdown

Slash commands

Commands match workflow file names by prefix.

Command Workflow
/test all Re-run all PR workflows
/test ? or /test help Show this help
/retest Re-run all failed checks
/cancel [name] Cancel in-progress runs

@eliorerz
eliorerz force-pushed the OSAC-757/update-keycloak-manifests branch from 8bd36e9 to c131b9d Compare June 30, 2026 14:31
@openshift-ci openshift-ci Bot removed the lgtm label Jun 30, 2026
@obochan-rh
obochan-rh force-pushed the OSAC-757/update-keycloak-manifests branch from c131b9d to 60a3bb2 Compare June 30, 2026 17:26
@obochan-rh

Copy link
Copy Markdown
Author

/unhold

@obochan-rh

Copy link
Copy Markdown
Author

/retest

@github-actions

Copy link
Copy Markdown

Re-triggered failed runs:

  • E2E VMaaS Full Install (#28463354865)

@CrystalChun

Copy link
Copy Markdown
Contributor

/retest

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Re-triggered failed runs:

  • E2E VMaaS Full Install (#28463354865)

@CrystalChun
CrystalChun force-pushed the OSAC-757/update-keycloak-manifests branch from 60a3bb2 to 53af04b Compare July 1, 2026 16:57

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

♻️ Duplicate comments (1)
scripts/refresh-after-snapshot.sh (1)

148-148: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Dead fallback: jq branch can never execute.

FC_CLIENT is always set by Line 18's ${FC_CLIENT:-"osac-controller"}, so the ${FC_CLIENT:-$(jq ...)} fallback here is unreachable — FC_CLIENT is never empty at this point. Simplify to a direct assignment.

♻️ Suggested simplification
-    FC_CLIENT_ID=${FC_CLIENT:-$(jq -er 'first(.clients[] | select(.serviceAccountsEnabled==true)) | .clientId' "${REALM_JSON}")}
+    FC_CLIENT_ID="${FC_CLIENT}"
🤖 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 `@scripts/refresh-after-snapshot.sh` at line 148, The FC_CLIENT_ID assignment
in refresh-after-snapshot.sh uses an unreachable jq fallback because FC_CLIENT
is already guaranteed to be set earlier via FC_CLIENT:-"osac-controller".
Simplify the logic by removing the fallback branch and assign FC_CLIENT_ID
directly from FC_CLIENT, keeping the surrounding setup unchanged.
🤖 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.

Duplicate comments:
In `@scripts/refresh-after-snapshot.sh`:
- Line 148: The FC_CLIENT_ID assignment in refresh-after-snapshot.sh uses an
unreachable jq fallback because FC_CLIENT is already guaranteed to be set
earlier via FC_CLIENT:-"osac-controller". Simplify the logic by removing the
fallback branch and assign FC_CLIENT_ID directly from FC_CLIENT, keeping the
surrounding setup unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: osac-project/coderabbit/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 5853b476-467b-44e7-9336-0a2de8cc4686

📥 Commits

Reviewing files that changed from the base of the PR and between 60a3bb2 and 53af04b.

⛔ Files ignored due to path filters (1)
  • prerequisites/keycloak/service/files/realm.json is excluded by !**/realm.json
📒 Files selected for processing (1)
  • scripts/refresh-after-snapshot.sh

@eliorerz

eliorerz commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

/retest

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Re-triggered failed runs:

  • E2E VMaaS Full Install (#28534012972)

@eliorerz

eliorerz commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

/retest

@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

Re-triggered failed runs:

  • E2E VMaaS Full Install (#28534012972)

Ofer Bochan added 4 commits July 1, 2026 21:17
Add the osac-admin Keycloak client and service account user to the
installer's realm.json, matching the pattern established in
fulfillment-service PR osac-project#462.

- Add osac-admin confidential client with serviceAccountsEnabled
- Add service-account-osac-admin user linked to the new client
- Add roles.client["osac-admin"] entry required by Keycloak
- Set osac-controller directAccessGrantsEnabled to false (service
  accounts should only use client credentials grant)

Related: https://redhat.atlassian.net/browse/OSAC-757
Signed-off-by: Ofer Bochan <obochan@obochan-thinkpadp1gen7.rmtil.csb>
Hardcode osac-controller in the credential lookup instead of using a
generic serviceAccountsEnabled select. The previous approach returns
multiple results now that osac-admin is also a service account client,
breaking the jq query. This matches setup.sh which already hardcodes
osac-controller.

Related: https://redhat.atlassian.net/browse/OSAC-757
Signed-off-by: Ofer Bochan <obochan@obochan-thinkpadp1gen7.rmtil.csb>
Address review feedback: instead of hardcoding osac-controller
in the function body, use an FC_CLIENT variable (set at the top,
with a jq fallback to first serviceAccountsEnabled client).
Use parameter-default assignment so an externally supplied
FC_CLIENT is not unconditionally overwritten.
@obochan-rh
obochan-rh force-pushed the OSAC-757/update-keycloak-manifests branch from 53af04b to bd4eccf Compare July 1, 2026 18:18

@eliorerz eliorerz 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.

LGTM

@openshift-ci

openshift-ci Bot commented Jul 1, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CrystalChun, eliorerz, obochan-rh, oourfali

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 label Jul 1, 2026
@openshift-merge-bot
openshift-merge-bot Bot merged commit bd847d1 into osac-project:main Jul 2, 2026
9 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants