Skip to content

fix(e2e): isolate the P2.7 Vault CA break per environment - #1167

Open
rh-amarin wants to merge 2 commits into
mainfrom
claude/fix-p2-7-vault-ca-isolation-cde9f5
Open

rh-amarin wants to merge 2 commits into
mainfrom
claude/fix-p2-7-vault-ca-isolation-cde9f5

Conversation

@rh-amarin

@rh-amarin rh-amarin commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Incident

Since 2026-11-20, every OpenShift e2e on the shared CI cluster hysh-aws-01 fails in P1 with "Vault credential backend is unreachable". The controller logs "vault CA bundle contains no usable certificate".

What happened:

  1. PR 1148's OpenShift job was cancelled when the PR merged (22:46:20Z).
  2. The orphaned e2e.test kept running and reached P2.7 (vault-fail-closed).
  3. P2.7 overwrote the shared openshell-vault/openshell-gateway-vault-tls ca.crt with a placeholder. It restores the CA only from a Go defer.
  4. The process was SIGKILLed at 22:47:07Z, so the restore never ran.
  5. scripts/cluster/vault.sh reuses an existing TLS Secret without checking it, so the broken CA persisted for every later PR environment.

This PR does not repair the live cluster. That is handled separately.

Fix

  1. Per-environment CA copy (main fix). vault.sh copies ca.crt into the environment's own namespace (Secret hypershell-vault-ca, VAULT_CA_COPY_NAMESPACE). The OpenShift driver (oc set env) and the Kind overlay set GATEWAY_VAULT_CA_SECRET=<env-ns>/hypershell-vault-ca on the controller. The controller ClusterRole already grants Secret reads.
  2. P2.7 breaks only that copy. It reads the target from the controller's GATEWAY_VAULT_CA_SECRET. It refuses to run when the env var is unset or names openshell-vault.
  3. Safer restore. P2.7 refuses to start if the current ca.crt is not a valid PEM certificate, so a broken value is never saved as the "original". The restore is idempotent and is registered with both t.Cleanup and defer.
  4. P2.7 still runs serially and last. The break no longer leaves the environment, but it still affects every gateway this control plane provisions. Only the comments changed.
  5. Tests.
    • vault_probe_test.go runs fake-Vault (httptest.NewTLSServer) cases: non-PEM CA, CA from a different authority, sealed Vault (503), missing CA Secret, the GATEWAY_VAULT_CA_SECRET override, and denied login.
    • It also checks that ReconcileGateway marks EnvironmentReady Failed and stops before any deploy step or cluster write when the probe fails.
  6. Specs. Updated openshell-gateway-credentials.spec.md (OSG-CRED-14 text, 14.02, coverage boundaries) and the P2.7 entry in e2e-testing.spec.md.

vault.sh still reuses an existing shared TLS Secret without checking it. That is enough now, because P2.7 no longer writes to the shared Secret.

Verification

  • make check: pass
  • cd components/control-plane && go test ./...: pass
  • make ci-test: six unrelated suites fail the same way on unmodified main: deploy/oce-kind/{automation,install-oce,readme,render-oce}_test.sh, scripts/funnel-dispatch_test.sh, scripts/skillspector-scan_test.sh.
  • Not run: a live OpenShift or Kind e2e of the new P2.7 path.

🤖 Generated with Claude Code

P2.7 (vault-fail-closed) corrupted the shared openshell-vault/openshell-gateway-vault-tls
ca.crt and restored it only from a Go defer. A cancelled CI job left an orphaned e2e.test
that was SIGKILLed mid-step on 2026-11-20, and vault.sh reused the broken Secret, so every
OpenShift e2e on the shared cluster failed in P1.

- vault.sh copies the validated CA into the environment namespace (hypershell-vault-ca);
  the OpenShift and Kind drivers point GATEWAY_VAULT_CA_SECRET at that copy.
- P2.7 discovers the CA Secret from the controller env, refuses the shared namespace,
  refuses to save a non-PEM "original", and restores via t.Cleanup plus an idempotent defer.
- vault.sh validates a reused TLS Secret (openssl verify) and regenerates it, then reloads
  Vault TLS with SIGHUP (storage is emptyDir, so a restart would wipe Vault).
- Fake-Vault unit tests for the probes and the reconciler fail-closed path.
- Spec text for OSG-CRED-14 and the e2e phase list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 24, 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

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
Pre-merge checks: Passed 5 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Ai-Attribution Warning AI use is disclosed, and the attribution is wrong. Evidence: - The PR description ends with "Generated with Claude Code". This states AI tool use. - The only commit i… Amend the commit message on branch claude/fix-p2-7-vault-ca-isolation-cde9f5: 1. Remove the line Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>. 2. Add an Assisted-by or Generated-by trailer that names the AI tool and model, …
Passed Passed checks: 5 passed

Check name Status Explanation
No-Weak-Crypto Passed PR #1167 (openshift-online/hypershell, author rh-amarin) introduces no weak cryptography. Checked against the committed diff (origin/main..HEAD, 15 files, non-Markdown). Findings by criterion: - Weak …
Container-Privileges Passed The check flags privileged: true, hostPID, hostNetwork, hostIPC, SYS_ADMIN, root without justification, and allowPrivilegeEscalation: true in container or Kubernetes manifests. The PR (openshift-onlin…
No-Sensitive-Data-In-Logs Passed Scope: CWE-532 (Insertion of Sensitive Information into Log File). Diff reviewed as main..HEAD (main=b5b5f36, HEAD=e8bd19f) across 15 files. Added log, echo, and print statements checked: - scripts/cl…
No-Hardcoded-Secrets Passed No hardcoded secret found in the PR diff (main..HEAD, 15 files, commit e8bd19f on top of main b5b5f36). Checks run on added lines only: - Private key PEM blocks (BEGIN ... PRIVATE KEY): none added. …
No-Injection-Vectors Passed No injection vector from the listed classes is introduced by PR #1167 (head e8bd19f). Scope and method: - The clone is shallow. HEAD is a grafted root, so git diff main...HEAD has no merge base. - I…
Full details: No-Weak-Crypto

Explanation

PR #1167 (openshift-online/hypershell, author rh-amarin) introduces no weak cryptography. Checked against the committed diff (origin/main..HEAD, 15 files, non-Markdown). Findings by criterion: - Weak algorithms (MD5, SHA1, DES, 3DES, RC4, Blowfish, ECB): no added lines reference these primitives. A word-boundary scan of the added lines returned no matches. Related CWE: CWE-327 (broken or risky algorithm). Not triggered. - Custom crypto: none. The new code calls standard libraries only. vault_probe_test.go generates a test CA with ecdsa.GenerateKey(elliptic.P256()) and x509.CreateCertificate. scripts/cluster/vault-tls.sh validates chains with openssl x509 and openssl verify. Certificate and key generation reuses the existing scripts/gen-postgres-tls.sh, which is unchanged and uses RSA-2048 with SHA-256. Related CWE: CWE-327. Not triggered. - Non-constant-time comparison of secrets or tokens (CWE-208): no comparison touches a secret or token. - scripts/cluster/vault.sh (around line 518) compares base64 tls.crt values with =. tls.crt is a public certificate, not a secret. The tls.key is not compared. - scripts/cluster/vault-tls_test.sh compares fixture strings in a test helper. - tests/e2e/vault_phases.go compares env var names and certificate PEM block types, not credentials. - The Go probe test uses a fixed fake token (hvs.PROBE) and does not compare it. Residual note: the shell = comparison on certificate bytes is not constant-time. It is not a secret comparison, so this check does not cover it.

Full details: Container-Privileges

Explanation

The check flags privileged: true, hostPID, hostNetwork, hostIPC, SYS_ADMIN, root without justification, and allowPrivilegeEscalation: true in container or Kubernetes manifests. The PR (openshift-online/hypershell #1167, head e8bd19f against base b5b5f36) does not add any of these. Evidence: - The diff touches 15 files. Only one is a Kubernetes manifest: deploy/kind/kustomization.yaml. Its change adds one env var, GATEWAY_VAULT_CA_SECRET=hypershell-system/hypershell-vault-ca. It adds no securityContext, capability, host namespace, or privilege setting. - A search of added and removed diff lines found no matches for privileged, hostPID, hostNetwork, hostIPC, SYS_ADMIN, allowPrivilegeEscalation, runAsUser, runAsNonRoot, hostPath, or securityContext. - The openshift.sh change adds an oc set env call for the same env var. The vault.sh and vault-tls.sh changes copy a CA Secret and run openssl checks. None of these changes creates or alters a pod spec. - The only "capabilities" hits are gateway capability labels in Go e2e test code (for example, "runtime/kata"). These are not Linux capabilities. No manifest in the PR adds or changes a flagged setting.

Full details: No-Sensitive-Data-In-Logs

Explanation

Scope: CWE-532 (Insertion of Sensitive Information into Log File). Diff reviewed as main..HEAD (main=b5b5f36, HEAD=e8bd19f) across 15 files. Added log, echo, and print statements checked: - scripts/cluster/vault.sh: success/error/info messages name only the TLS Secret (${VAULT_TLS_SECRET}) and the copy target (${VAULT_CA_COPY_NAMESPACE}/${VAULT_CA_COPY_SECRET}). No CA bytes, tls.key, or tokens are printed. openssl x509 and openssl verify output is redirected to /dev/null. The SIGHUP block prints no certificate content. - scripts/cluster/drivers/openshift.sh: info prints the namespace/secret name for GATEWAY_VAULT_CA_SECRET. This is a name, not a secret value. - tests/e2e/vault_phases.go: t.Logf WARN lines print the Secret namespace/name and the Kubernetes API error. They do not print Data[ca.crt], the original CA, or the broken placeholder. - components/control-plane/internal/gateway/vault_probe_test.go: the fake client token hvs.PROBE is a test fixture and is not logged. t.Errorf messages print only namespace, role, and report struct values. - No new Go production logging calls were found in the diff. No new logging exposes passwords, tokens, API keys, PII, session IDs, internal hostnames, or customer data. Namespace and Secret names appear in logs. The check does not list them as sensitive. Limit: the shallow checkout exposes only the PR commit and base history. The review covers the added lines, not pre-existing output that vault.sh or openshift.sh already produced.

Full details: No-Hardcoded-Secrets

Explanation

No hardcoded secret found in the PR diff (main..HEAD, 15 files, commit e8bd19f on top of main b5b5f36). Checks run on added lines only: - Private key PEM blocks (BEGIN ... PRIVATE KEY): none added. - Cloud and SaaS key formats (AKIA, ghp_, xox, sk-, Vault s.): none added. - URLs with embedded credentials (scheme://user:***REDACTED_URI_PASSWORD***@host): none added. - Long base64-like literals (33+ chars): none. The matches were Go identifiers such as test function names. - Variables named token, secret, password, key, or cred assigned string literals: none with a real value. Secret-related names hold Secret object names (hypershell-vault-ca) or env var names (GATEWAY_VAULT_CA_SECRET), which are not credentials. One literal needs a note. components/control-plane/internal/gateway/vault_probe_test.go returns {"auth":{"client_token":"***REDACTED_SECRET_ASSIGNMENT***"}} from an httptest.NewTLSServer fake Vault (lines 47 and 162 of the added code). The value uses the Vault hvs. prefix, but it is a fixed placeholder. It is not a live token. It appears only in test code and does not match a credential format that CWE-798 would cover. It does not trigger the check. Maintainers may prefer a non-prefixed placeholder to avoid secret-scanner alerts. Other literals in the diff, such as fail-closed-e2e: not a certificate and the fake CA PEM generated at runtime, are test fixtures. They are not secrets.

Full details: No-Injection-Vectors

Explanation

No injection vector from the listed classes is introduced by PR #1167 (head e8bd19f). Scope and method: - The clone is shallow. HEAD is a grafted root, so git diff main...HEAD has no merge base. - I compared each PR-related file to origin/main directly. Changed files: scripts/cluster/vault.sh, scripts/cluster/drivers/openshift.sh, scripts/kind/up.sh, deploy/kind/kustomization.yaml, tests/e2e/suite.go, tests/e2e/vault_phases.go, and the two spec files. components/control-plane/internal/gateway/vault_probe_test.go is new. vault_probe.go is unchanged. Check against each listed class: - SQL concatenation (CWE-89): no SQL or database query code in the changed files. - shell=True or shell command built from user input (CWE-78): no Python. The new shell code passes variables as quoted arguments to vkube, oc_cli set env, and kubectl. The GATEWAY_VAULT_CA_SECRET value is built from OPENSHIFT_NAMESPACE, which is operator configuration. No eval, sh -c, bash -c, or xargs appears in added lines. - eval or exec on untrusted data (CWE-95): none. The only exec is vkube ... exec "${VPOD}" -- cat /vault/tls/tls.crt and kill -HUP 1, both with fixed arguments. - pickle.loads (CWE-502) and yaml.load without SafeLoader: no Python or YAML deserialization in the diff. - os.system with variables: not used. - dangerouslySetInnerHTML (CWE-79): no frontend changes in the PR. Go changes: - vault_phases.go parses the controller env value with strings.Cut. It uses PEM decoding and x509.ParseCertificate. It does not pass the value to a shell or query. - vault_probe_test.go uses httptest fake servers and JSON decoding of test requests. I checked it with pattern searches only, not a full line-by-line read. Pattern hits show no exec, Sprintf-built command, SQL, or unsafe deserialization. Residual gap: the base comparison covers the files the PR changes. It does not show a full PR patch. This does not change the result, because no sink in the listed classes appears in any added line I inspected.

Full details: Ai-Attribution

Explanation

AI use is disclosed, and the attribution is wrong. Evidence: - The PR description ends with "Generated with Claude Code". This states AI tool use. - The only commit in the PR (main..HEAD, e8bd19f, author Angel Marin <amarin@redhat.com>) ends with Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;. - The commit has no Assisted-by or Generated-by trailer. A search of the last 30 commits found no such trailer. The check requires Red Hat attribution through Assisted-by or Generated-by trailers. It also flags Co-Authored-By for AI tools. The commit uses the flagged form and lacks the required trailer. Scope: the author identity and PR number were taken from the provider record (PR #1167, author login rh-amarin). The commit text came from the local checkout. The PR description and commit text are contributor-authored, but they are used here only as evidence of AI use and trailer format.

Resolution

Amend the commit message on branch claude/fix-p2-7-vault-ca-isolation-cde9f5: 1. Remove the line Co-Authored-By: Claude Opus 5.5 &lt;noreply@anthropic.com&gt;. 2. Add an Assisted-by or Generated-by trailer that names the AI tool and model, following the Red Hat attribution convention. 3. Force-push the amended commit. 4. Optionally, replace the "Generated with Claude Code" footer in the PR description with the same attribution, so the PR body and commit agree.

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

HyperShell environment destroyed

This ephemeral OpenShift environment has been destroyed. Comment /pr-extend to redeploy it.

@mergify

mergify Bot commented Nov 24, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

@codecov-appsre

codecov-appsre Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main    #1167      +/-   ##
==========================================
+ Coverage   46.92%   47.04%   +0.12%     
==========================================
  Files         424      424              
  Lines       33633    33633              
==========================================
+ Hits        15783    15824      +41     
+ Misses      15896    15852      -44     
- Partials     1954     1957       +3     
Flag Coverage Δ
control-plane 56.84% <ø> (+0.32%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 4 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c42d001...5106244. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

The per-environment CA copy already keeps P2.7 away from the shared Secret,
so the reuse check, regeneration and SIGHUP reload are not needed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant