Skip to content

Commit c7cfaf8

Browse files
markturanskyclaude
andcommitted
fix(pr-test): validate required secrets before install, remove cluster domain derivation
- Add upfront secret verification step — fail fast with clear message if postgresql-credentials, frontend-oauth-config, ambient-vertex, or ambient-api-server missing from SOURCE_NAMESPACE - Remove cluster domain derivation (no longer needed — Routes get hosts assigned by OpenShift; filter no longer sets explicit spec.host) - Remove CLUSTER_DOMAIN env var from filter pipeline - Add minio-credentials and postgresql-credentials to copy list 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7f08e85 commit c7cfaf8

2 files changed

Lines changed: 39 additions & 35 deletions

File tree

components/pr-test/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@ bash components/pr-test/provision.sh destroy <instance-id>
1414

1515
> **Operational how-to:** `.claude/skills/ambient-pr-test/SKILL.md` — step-by-step PR test workflow that references this spec.
1616
17+
## Reference
18+
19+
| Resource | URL |
20+
|----------|-----|
21+
| Tenant Operator | https://gitlab.cee.redhat.com/paas/tenant-operator |
22+
| Tenant Operator Access | https://gitlab.cee.redhat.com/ddis/ai/devops/ddis-ai-gitops |
23+
1724
## Purpose
1825

1926
This specification defines how Ambient Code creates and destroys ephemeral OpenShift namespaces for S0.x merge queue test instances. Each S0.x instance is a fully independent, shared-nothing installation of Ambient, used for integration testing of a single candidate branch before it merges to `main`.

components/pr-test/install.sh

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ SOURCE_NAMESPACE="${SOURCE_NAMESPACE:-ambient-code--runtime-int}"
88
CONFIG_NAMESPACE="${CONFIG_NAMESPACE:-ambient-code--config}"
99
ARGOCD_TOKEN_SECRET="${ARGOCD_TOKEN_SECRET:-tenantaccess-argocd-account-token}"
1010

11+
REQUIRED_SOURCE_SECRETS=(
12+
ambient-vertex
13+
ambient-api-server
14+
postgresql-credentials
15+
frontend-oauth-config
16+
)
17+
1118
usage() {
1219
echo "Usage: $0 <namespace> <image-tag>"
1320
echo " namespace: e.g. ambient-code--pr-42"
@@ -23,9 +30,6 @@ usage() {
2330
[[ -z "$NAMESPACE" || -z "$IMAGE_TAG" ]] && usage
2431

2532
PR_ID=$(echo "$NAMESPACE" | grep -oE 'pr-[0-9]+')
26-
CLUSTER_DOMAIN=$(oc get route frontend-route -n "$SOURCE_NAMESPACE" \
27-
-o jsonpath='{.spec.host}' 2>/dev/null | sed 's/^[^.]*\.//' \
28-
|| echo "apps.dev-osd-east-1.mxty.p1.openshiftapps.com")
2933

3034
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
3135
REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
@@ -40,7 +44,6 @@ copy_secret() {
4044
}
4145

4246
echo "==> Installing Ambient into $NAMESPACE with images tagged $IMAGE_TAG"
43-
echo " Cluster domain: $CLUSTER_DOMAIN"
4447

4548
echo "==> Step 1: Verifying cluster-scoped resources exist (CRDs, ClusterRoles)"
4649
FAILED=0
@@ -62,15 +65,29 @@ for cr in agentic-operator ambient-frontend-auth ambient-project-admin ambient-p
6265
done
6366
[[ $FAILED -eq 1 ]] && exit 1
6467

65-
echo "==> Step 2: Copying secrets from $SOURCE_NAMESPACE"
66-
copy_secret ambient-vertex
67-
copy_secret ambient-api-server
68+
echo "==> Step 2: Verifying required secrets exist in $SOURCE_NAMESPACE"
69+
FAILED=0
70+
for secret in "${REQUIRED_SOURCE_SECRETS[@]}"; do
71+
if oc get secret "$secret" -n "$SOURCE_NAMESPACE" &>/dev/null 2>&1; then
72+
echo " Secret OK: $secret"
73+
else
74+
echo "ERROR: Required secret missing from $SOURCE_NAMESPACE: $secret"
75+
echo " Copy it manually: oc get secret $secret -n <source> -o yaml | oc apply -n $SOURCE_NAMESPACE -f -"
76+
FAILED=1
77+
fi
78+
done
79+
[[ $FAILED -eq 1 ]] && exit 1
80+
81+
echo "==> Step 3: Copying secrets from $SOURCE_NAMESPACE"
82+
for secret in "${REQUIRED_SOURCE_SECRETS[@]}"; do
83+
copy_secret "$secret"
84+
done
6885

69-
echo "==> Step 3: Fetching ArgoCD SA token from $CONFIG_NAMESPACE"
86+
echo "==> Step 4: Fetching ArgoCD SA token from $CONFIG_NAMESPACE"
7087
ARGOCD_TOKEN=$(oc get secret "$ARGOCD_TOKEN_SECRET" -n "$CONFIG_NAMESPACE" \
7188
-o jsonpath='{.data.token}' | base64 -d)
7289

73-
echo "==> Step 4: Deploying production overlay with image tag $IMAGE_TAG"
90+
echo "==> Step 5: Deploying production overlay with image tag $IMAGE_TAG"
7491
TMPDIR=$(mktemp -d)
7592
cp -r "$MANIFESTS_DIR/." "$TMPDIR/"
7693
trap "rm -rf $TMPDIR" EXIT
@@ -94,19 +111,9 @@ import sys, re, os
94111
95112
namespace = os.environ['NAMESPACE']
96113
pr_id = os.environ['PR_ID']
97-
cluster_domain = os.environ['CLUSTER_DOMAIN']
98114
99115
SKIP_KINDS = {'Namespace'}
100116
101-
ROUTE_HOSTS = {
102-
'ambient-api-server-grpc': f'api-grpc-{pr_id}.{cluster_domain}',
103-
'ambient-api-server': f'api-{pr_id}.{cluster_domain}',
104-
'frontend-route': f'frontend-{pr_id}.{cluster_domain}',
105-
'backend-route': f'backend-{pr_id}.{cluster_domain}',
106-
'public-api-route': f'pubapi-{pr_id}.{cluster_domain}',
107-
'unleash-route': f'unleash-{pr_id}.{cluster_domain}',
108-
}
109-
110117
CRB_NS_RE = re.compile(r'( namespace:\s*)ambient-code(\s*$)', re.MULTILINE)
111118
112119
for doc in sys.stdin.read().split('\n---\n'):
@@ -119,8 +126,6 @@ for doc in sys.stdin.read().split('\n---\n'):
119126
kind = kind_m.group(1)
120127
if kind in SKIP_KINDS:
121128
continue
122-
name_m = re.search(r'^ name:\s*(\S+)', doc, re.MULTILINE)
123-
name = name_m.group(1) if name_m else ''
124129
if kind == 'ClusterRoleBinding':
125130
doc = CRB_NS_RE.sub(r'\g<1>' + namespace + r'\g<2>', doc)
126131
if kind == 'PersistentVolumeClaim':
@@ -139,13 +144,13 @@ for doc in sys.stdin.read().split('\n---\n'):
139144
PYEOF
140145

141146
kustomize build . \
142-
| NAMESPACE="$NAMESPACE" PR_ID="$PR_ID" CLUSTER_DOMAIN="$CLUSTER_DOMAIN" \
147+
| NAMESPACE="$NAMESPACE" PR_ID="$PR_ID" \
143148
python3 "$FILTER_SCRIPT" \
144149
| oc apply --token="$ARGOCD_TOKEN" -n "$NAMESPACE" -f -
145150

146151
popd > /dev/null
147152

148-
echo "==> Step 5: Patching operator ConfigMap with PR image tags"
153+
echo "==> Step 6: Patching operator ConfigMap with PR image tags"
149154
SOURCE_OPERATOR_CONFIG=$(oc get configmap operator-config -n "$SOURCE_NAMESPACE" -o json \
150155
| jq -r '.data | to_entries | map(select(.key | test("VERTEX|CLOUD_ML|ANTHROPIC|GOOGLE"))) | from_entries' \
151156
2>/dev/null || echo '{}')
@@ -158,7 +163,7 @@ VERTEX_PATCH=$(echo "$SOURCE_OPERATOR_CONFIG" | jq -c \
158163
oc patch configmap operator-config -n "$NAMESPACE" --type=merge \
159164
-p "{\"data\": $VERTEX_PATCH}"
160165

161-
echo "==> Step 6: Patching agent registry ConfigMap with PR image tags"
166+
echo "==> Step 7: Patching agent registry ConfigMap with PR image tags"
162167
REGISTRY=$(oc get configmap ambient-agent-registry -n "$NAMESPACE" \
163168
-o jsonpath='{.data.agent-registry\.json}' 2>/dev/null || echo "{}")
164169

@@ -170,7 +175,7 @@ REGISTRY=$(echo "$REGISTRY" | sed \
170175
oc patch configmap ambient-agent-registry -n "$NAMESPACE" --type=merge \
171176
-p "{\"data\":{\"agent-registry.json\":$(echo "$REGISTRY" | jq -Rs .)}}"
172177

173-
echo "==> Step 7: Waiting for rollouts"
178+
echo "==> Step 8: Waiting for rollouts"
174179
for deploy in backend-api frontend agentic-operator postgresql minio unleash public-api; do
175180
echo " Waiting for $deploy..."
176181
oc rollout status deployment/$deploy -n "$NAMESPACE" --timeout=300s
@@ -182,21 +187,13 @@ oc rollout status deployment/ambient-api-server-db -n "$NAMESPACE" --timeout=300
182187
echo " Waiting for ambient-api-server..."
183188
oc rollout status deployment/ambient-api-server -n "$NAMESPACE" --timeout=300s
184189

185-
echo "==> Step 8: Verifying health"
186-
BACKEND_HOST=$(oc get route backend-route -n "$NAMESPACE" \
187-
-o jsonpath='{.spec.host}' 2>/dev/null || true)
188-
189-
if [[ -n "$BACKEND_HOST" ]]; then
190-
HEALTH=$(curl -s "https://${BACKEND_HOST}/health" || true)
191-
echo " Backend health: $HEALTH"
192-
fi
193-
190+
echo "==> Step 9: Verifying health"
194191
FRONTEND_URL=$(oc get route frontend-route -n "$NAMESPACE" \
195192
-o jsonpath='https://{.spec.host}' 2>/dev/null || true)
196193

197194
echo ""
198195
echo "==> Ambient installed successfully in $NAMESPACE"
199-
echo " Frontend: $FRONTEND_URL"
196+
echo " Frontend: ${FRONTEND_URL:-<no route yet>}"
200197
echo " Image tag: $IMAGE_TAG"
201198

202199
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then

0 commit comments

Comments
 (0)