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

OSAC-1315: fix Helm deploy deadlock in setup.sh - #240

Merged
openshift-merge-bot[bot] merged 1 commit into
osac-project:mainfrom
omer-vishlitzky:fix/helm-deploy-deadlock-osac-1315
Jun 11, 2026
Merged

openshift-merge-bot[bot] merged 1 commit into
osac-project:mainfrom
omer-vishlitzky:fix/helm-deploy-deadlock-osac-1315

Conversation

@omer-vishlitzky

@omer-vishlitzky omer-vishlitzky commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes OSAC-1315 — the e2e-vmaas-full-setup-helm periodic job fails 100% because setup.sh deadlocks during Helm install.

Root cause: helm upgrade --install --wait blocks waiting for pods, but the pods need resources (ca-bundle ConfigMap, fulfillment-controller-credentials secret, fulfillment-db secret) that are either created after Helm returns or never created in Helm mode.

Changes

  1. Move ensure-ca-bundle.sh and fulfillment-controller-credentials creation before the Helm install — these ran after the if/else block, but helm --wait blocks indefinitely because pods mount them as required volumes. Now runs before for both modes (idempotent, no kustomize impact).

  2. Deploy the fulfillment database before OSAC Helm install (Helm mode only) — uses the existing it/charts/postgres chart. The fulfillment-service chart expects an external PostgreSQL but nothing in the Helm path provisioned one. Also creates the client certificate and fulfillment-db connection secret.

  3. Create namespace early — needed so trust-manager can target it with the ca-bundle Bundle CR before Helm runs. Removes --create-namespace from the OSAC Helm install since it already exists.

Evidence from the failing job

4 pods stuck in ContainerCreating for 40 minutes until Helm times out:

FailedMount  (x27 over 40m)  pod/authorino-...              configmap "ca-bundle" not found
FailedMount  (x23 over 40m)  pod/fulfillment-controller-... configmap "ca-bundle" not found
FailedMount  (x18 over 40m)  pod/fulfillment-controller-... secret "fulfillment-controller-credentials" not found
FailedMount  (x26 over 40m)  pod/fulfillment-grpc-server-.. secret "fulfillment-db" not found

Equivalent kustomize job (build 2063773341717630976) passes.

Test plan

  • e2e-vmaas-full-setup-helm periodic job passes
  • Kustomize path is unaffected (all moved code is idempotent)

Summary by CodeRabbit

  • Bug Fixes
    • Improved setup reliability by preparing namespaces, trust bundles, and controller credentials before deployment
    • Made namespace creation idempotent and added readiness checks for the certificate bundle
    • Ensured controller credentials are resolved up front and fail-fast if missing
    • Prepared external database and TLS assets prior to Helm deployment and adjusted Helm install behavior
    • Applied same preparatory steps for Kustomize installs to avoid timing issues

@coderabbitai

coderabbitai Bot commented Jun 8, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The setup script reorders initialization so namespace creation, CA bundle validation, and Keycloak-derived controller credentials are prepared before deployment. Helm mode additionally provisions external PostgreSQL, cert-manager Certificate, and TLS-enabled DB secrets prior to installing the osac chart.

Changes

Deployment Initialization Refactor

Layer / File(s) Summary
Early prerequisite initialization
scripts/setup.sh
Namespace created idempotently, ca-bundle ConfigMap ensured and validated to contain a PEM bundle, fulfillment-controller-credentials Secret extracted from Keycloak realm.json with hard failure if osac-controller client secret is missing.
Helm provisioning with PostgreSQL and TLS
scripts/setup.sh
External fulfillment PostgreSQL deployed with issuer/ca-bundle and service DB settings, cert-manager Certificate created for postgres-client-cert-service and waited for Ready, fulfillment-db Secret constructed with sslmode=verify-full and filesystem cert/key/rootcert paths, Helm dependencies built, and osac chart upgraded using the pre-created namespace; removed duplicate later-stage CA/credentials logic.
Kustomize branch adjustment
scripts/setup.sh
Moved ensure-ca-bundle.sh and Keycloak-derived controller credential creation into the Kustomize branch so CA and credentials readiness occur before oc apply -k ....

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Risk Assessment: Medium-high severity. Reordering initialization affects bootstrap sequencing and secret lifecycles; failures in Keycloak secret extraction or cert-manager readiness can block deployments and may expose misconfiguration of TLS/DB connectivity. Verify secret existence, cert issuance, and namespace targeting before running in production.

Suggested labels: lgtm

Suggested reviewers:

  • eranco74
  • akshaynadkarni
  • adriengentil

🔧 Namespace and secrets dance in early light,
CA bundles validated, TLS fastened tight,
PostgreSQL stands ready with cert-manager's care,
Helm charts depend on what's prepared with flair. 🎯


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-Injection-Vectors ❌ Error Line 270: INSTALLER_NAMESPACE variable interpolated into eval'd condition without sanitization, enabling command injection via shell metacharacters. Refactor retry_until to avoid eval or validate namespace against Kubernetes DNS naming rules a-z0-9?
Ai-Attribution ⚠️ Warning Commit uses Co-Authored-By for AI tool (Claude Opus), violating Red Hat policy. Must use Assisted-by or Generated-by trailers instead. Replace Co-Authored-By trailer with proper Red Hat AI attribution: either Assisted-by or Generated-by trailer for Claude Opus involvement.
✅ 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 'OSAC-1315: fix Helm deploy deadlock in setup.sh' directly summarizes the main objective of the PR, which is fixing a Helm deployment deadlock issue in the setup script.
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.
No-Hardcoded-Secrets ✅ Passed No new hardcoded secrets introduced. FC_CLIENT_SECRET read from config file, not hardcoded. DB_URL is template with file path placeholders. realm.json not modified.
No-Weak-Crypto ✅ Passed No weak cryptographic algorithms, custom crypto implementations, or unsafe secret comparisons found. Code uses modern cert-manager with TLS verify-full mode for database connections.
Container-Privileges ✅ Passed No privilege escalation detected. All security contexts use restrictive settings (allowPrivilegeEscalation: false, runAsNonRoot: true). setup.sh uses standard Kubernetes operations only.
No-Sensitive-Data-In-Logs ✅ Passed Secrets never logged. FC_CLIENT_SECRET and DB_URL are only used in oc create secret commands, never echoed. No set -x debugging. Error messages don't reveal values.
✨ 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 and usage tips.

@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/setup.sh`:
- Around line 297-311: The Certificate resource named
postgres-client-cert-service is missing spec.usages so cert-manager may issue a
cert without the client auth EKU; add spec.usages: ["client auth"] to the
postgres-client-cert-service Certificate manifest (the resource with
metadata.name: postgres-client-cert-service and spec.privateKey.rotationPolicy)
so the issued certificate includes the client auth Extended Key Usage required
by PostgreSQL mTLS authentication.
🪄 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: 8a0a28f7-eefa-4fc1-96d8-6f9c94ac9c1b

📥 Commits

Reviewing files that changed from the base of the PR and between 4b4c4dd and 1a77a60.

📒 Files selected for processing (1)
  • scripts/setup.sh

Comment thread scripts/setup.sh
@omer-vishlitzky
omer-vishlitzky force-pushed the fix/helm-deploy-deadlock-osac-1315 branch from 1a77a60 to 284b6e0 Compare June 8, 2026 11:28
@omer-vishlitzky omer-vishlitzky changed the title fix: resolve Helm deploy deadlock in setup.sh OSAC-1315: fix Helm deploy deadlock in setup.sh Jun 8, 2026
@openshift-ci-robot

openshift-ci-robot commented Jun 8, 2026

Copy link
Copy Markdown

@omer-vishlitzky: This pull request references OSAC-1315 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 bug to target the "5.0.0" version, but no target version was set.

Details

In response to this:

Summary

Fixes OSAC-1315 — the e2e-vmaas-full-setup-helm periodic job fails 100% because setup.sh deadlocks during Helm install.

Root cause: helm upgrade --install --wait blocks waiting for pods, but the pods need resources (ca-bundle ConfigMap, fulfillment-controller-credentials secret, fulfillment-db secret) that are either created after Helm returns or never created in Helm mode.

Changes

  1. Move ensure-ca-bundle.sh and fulfillment-controller-credentials creation before the Helm install — these ran after the if/else block, but helm --wait blocks indefinitely because pods mount them as required volumes. Now runs before for both modes (idempotent, no kustomize impact).

  2. Deploy the fulfillment database before OSAC Helm install (Helm mode only) — uses the existing it/charts/postgres chart. The fulfillment-service chart expects an external PostgreSQL but nothing in the Helm path provisioned one. Also creates the client certificate and fulfillment-db connection secret.

  3. Create namespace early — needed so trust-manager can target it with the ca-bundle Bundle CR before Helm runs. Removes --create-namespace from the OSAC Helm install since it already exists.

Evidence from the failing job

4 pods stuck in ContainerCreating for 40 minutes until Helm times out:

FailedMount  (x27 over 40m)  pod/authorino-...              configmap "ca-bundle" not found
FailedMount  (x23 over 40m)  pod/fulfillment-controller-... configmap "ca-bundle" not found
FailedMount  (x18 over 40m)  pod/fulfillment-controller-... secret "fulfillment-controller-credentials" not found
FailedMount  (x26 over 40m)  pod/fulfillment-grpc-server-.. secret "fulfillment-db" not found

Equivalent kustomize job (build 2063773341717630976) passes.

Test plan

  • e2e-vmaas-full-setup-helm periodic job passes
  • Kustomize path is unaffected (all moved code is idempotent)

Summary by CodeRabbit

  • Bug Fixes
  • Improved setup script reliability by initializing namespaces and resources in correct dependency order
  • Enhanced credential extraction from Keycloak during deployment
  • Ensured PostgreSQL and TLS certificate configuration is properly prepared before Helm deployment

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.

Comment thread scripts/setup.sh Outdated
Comment thread scripts/setup.sh Outdated
Comment thread scripts/setup.sh
Comment thread scripts/setup.sh
Comment on lines +340 to +347
FC_CLIENT_SECRET=$(jq -er '.clients[] | select(.clientId == "osac-controller") | .secret // empty' prerequisites/keycloak/service/files/realm.json)
[[ -n "${FC_CLIENT_SECRET}" ]] || { echo "ERROR: Could not resolve secret for osac-controller in realm.json" >&2; exit 1; }
oc create secret generic fulfillment-controller-credentials \
--from-literal=client-id=osac-controller \
--from-literal=client-secret="${FC_CLIENT_SECRET}" \
-n ${INSTALLER_NAMESPACE} \
--dry-run=client -o yaml | oc apply -f -
fi

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.

Ppassing secrets via --from-literal means they can show up in ps aux. Probably low risk in CI, but we could pipe them via stdin if we want to be totally secure. Not a blocker though.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@omer-vishlitzky
omer-vishlitzky force-pushed the fix/helm-deploy-deadlock-osac-1315 branch from 284b6e0 to a86a7e7 Compare June 10, 2026 11:28

@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 added the lgtm label Jun 10, 2026
@openshift-ci

openshift-ci Bot commented Jun 10, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: eliorerz, omer-vishlitzky

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

@omer-vishlitzky

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@omer-vishlitzky

Copy link
Copy Markdown
Contributor Author

/retest

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.

3 participants