Skip to content

Resolve sandbox and tenant namespaces from env, not hardcoded names - #3

Merged
blues-man merged 1 commit into
mainfrom
scope-sandbox-namespaces-per-tenant
Oct 7, 2026
Merged

blues-man merged 1 commit into
mainfrom
scope-sandbox-namespaces-per-tenant

Conversation

@blues-man

Copy link
Copy Markdown
Collaborator

Problem

The verify skill hardcodes sdlc-sandboxes and pr-test-mr-<iid>. Both are cluster-wide names, so on a shared cluster every tenant uses the same ones. ArgoCD surfaced it first as contested ownership:

Namespace/sdlc-sandboxes is part of applications
openshift-gitops/lightwell-tenant-b8bxn and lightwell-tenant-z9bbp

Only one tenant reports Healthy; the rest fight over it. But the ownership conflict is the mildest symptom:

  • Cross-tenant credential exposure. Step 2 does oc create secret generic gitlab-pat -n sdlc-sandboxes — every tenant writes its GitLab PAT into the shared namespace, where every other tenant's verify Jobs run.
  • Job collisions. Idempotency keys on -l mr-iid=<iid>, and MR iids restart at !1 per project. Two tenants with an open !1 find each other's Jobs — and the skill deletes a failed one before re-applying.
  • Wrong-tenant Nexus. The discovery block took oc get cm tenant-integration -A -o jsonpath='{.items[0].metadata.namespace}'. There are two such ConfigMaps per tenant, so items[0] can resolve a different tenant entirely and point the Maven build at their Nexus.

Change

Stop discovering, start reading injected env. rhpds/lightwell-workshop@3e1f780 adds to the OpenCode pod:

Variable Example
LIGHTWELL_GUID 49t9b
TENANT_NAMESPACE lightwell-tenant-49t9b
SDLC_SANDBOX_NAMESPACE sdlc-sandboxes-49t9b
EPHEMERAL_NS_PREFIX pr-test-mr-49t9b
NEXUS_NAMESPACE lightwell-nexus-49t9b
NEXUS_REPOSITORIES redhat-packages-validated-49t9b,redhat-packages-remediated-49t9b

.opencode/agents/mr-verifier.md and .opencode/skills/mr-verify-ephemeral/SKILL.md now use $SDLC_SANDBOX_NAMESPACE and ${EPHEMERAL_NS_PREFIX}-<iid>. README.md and spec.md updated to the -<guid> forms.

Ordering

These prompts are baked in at build time (container/Dockerfile: COPY .opencode /app/.opencode), so this takes effect on the next image build, not on merge. Build the image before the chart rename reaches a tenant — renaming the namespace while the running image still says sdlc-sandboxes breaks MR verification. The reverse order is safe: a new image with $SDLC_SANDBOX_NAMESPACE unset fails loudly rather than silently using a shared namespace.

🤖 Generated with Claude Code

The verify skill hardcoded `sdlc-sandboxes` and `pr-test-mr-<iid>`. Both
are cluster-wide names, so on a shared cluster every tenant used the same
ones. The skill writes the tenant's GitLab PAT into the sandbox as Secret
gitlab-pat, so sharing it exposes one tenant's PAT to another tenant's
verify Jobs; and Job idempotency keys on mr-iid, which restarts at 1 per
project, so two tenants with an open !1 find and delete each other's Jobs.

Worse, the Nexus lookup did:

  TENANT_NS=$(oc get cm tenant-integration -A -o jsonpath='{.items[0].metadata.namespace}')

There are two tenant-integration ConfigMaps per tenant, so items[0] can
resolve a different tenant and point the verify build at their Nexus.

The bootstrap-tenant chart now injects LIGHTWELL_GUID, TENANT_NAMESPACE,
SDLC_SANDBOX_NAMESPACE, EPHEMERAL_NS_PREFIX, NEXUS_NAMESPACE and
NEXUS_REPOSITORIES into the OpenCode pod, so read those instead of
discovering anything. Chart side: rhpds/lightwell-workshop@3e1f780.

These prompts are baked into the image at build time (container/Dockerfile
COPY .opencode), so this takes effect on the next image build, not on
merge.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@blues-man
blues-man merged commit 5e19550 into main Oct 7, 2026
blues-man added a commit to rhpds/lightwell-workshop that referenced this pull request Oct 7, 2026
rhpds/lw-sdlc-opencode#3 is merged, but every Actions run on that repo
since 2026-10-07 ends in startup_failure with zero jobs allocated, so CI
never published a sha-* tag for it. The workflow file is byte-identical
to the one behind the last green run and parses fine, so the cause is on
the org/policy side, not in the repo.

Built main @ 5e19550 by hand for linux/amd64 and pushed it to
quay.io/bluesman. It is bit-identical to the sandbox-ns-test image this
pinned before -- same tag now just names a commit instead of a branch
experiment.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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