Skip to content

Commit eb5062c

Browse files
committed
fix(ci): free the GKE static IP before the operator deployment
All GKE jobs share the fixed IP `rhdh-static-ip`, and GCE hands it to one Ingress at a time. An interrupted job leaves its Ingress behind, which keeps serving gke-ci.janus-idp.io, so the next job's first test suite runs against a stale instance. That is what happened when the GKE operator presubmit of #5982 tested `showcase`, not `showcase-rbac`. The Helm job already deletes the RBAC namespace before its first deployment; do the same in the operator job. A namespace delete waits for the old load balancer to release the IP, so the new Ingress can take it. Add `wait_for_gke_ingress_ip` after the four places that create an Ingress and fail the job with the addresses it found if its own Ingress never gets the IP, so this class of stale state no longer hides behind unrelated test failures. A failed `kubectl get` during the wait is retried instead of ending the job under `errexit`. Assisted-by: OpenCode
1 parent 0f84117 commit eb5062c

5 files changed

Lines changed: 63 additions & 2 deletions

File tree

‎.ci/pipelines/cluster/gke/gke-helm-deployment.sh‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ initiate_gke_helm_deployment() {
4848
log::error "Helm upgrade failed for ${RELEASE_NAME} in ${NAME_SPACE}"
4949
return 1
5050
fi
51+
52+
wait_for_gke_ingress_ip "${NAME_SPACE}"
5153
}
5254

5355
initiate_rbac_gke_helm_deployment() {
@@ -78,4 +80,6 @@ initiate_rbac_gke_helm_deployment() {
7880
log::error "Helm upgrade failed for ${RELEASE_NAME_RBAC} in ${NAME_SPACE_RBAC}"
7981
return 1
8082
fi
83+
84+
wait_for_gke_ingress_ip "${NAME_SPACE_RBAC}"
8185
}

‎.ci/pipelines/cluster/gke/gke-operator-deployment.sh‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ initiate_gke_operator_deployment() {
4444
deploy_rhdh_operator "${namespace}" "${DIR}/resources/rhdh-operator/rhdh-start_K8s.yaml"
4545

4646
apply_gke_operator_ingress "$namespace" "backstage-$RELEASE_NAME"
47+
wait_for_gke_ingress_ip "${namespace}"
4748
}
4849

4950
initiate_rbac_gke_operator_deployment() {
@@ -70,4 +71,5 @@ initiate_rbac_gke_operator_deployment() {
7071
deploy_rhdh_operator "${namespace}" "${DIR}/resources/rhdh-operator/rhdh-start-rbac_K8s.yaml"
7172

7273
apply_gke_operator_ingress "$namespace" "backstage-$RELEASE_NAME_RBAC"
74+
wait_for_gke_ingress_ip "${namespace}"
7375
}

‎.ci/pipelines/cluster/gke/manifest.sh‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,52 @@ apply_gke_operator_ingress() {
2121
export SERVICE_NAME=$service_name
2222
envsubst < "${DIR}/cluster/gke/manifest/gke-operator-ingress.yaml" | kubectl apply --namespace="${namespace}" -f -
2323
}
24+
25+
# Function: wait_for_gke_ingress_ip
26+
# Description: Waits until an Ingress in the namespace is assigned the shared
27+
# static IP. GCE gives that IP to one Ingress at a time, so an Ingress left
28+
# behind in another namespace keeps serving the RHDH host and the tests would
29+
# run against a stale instance.
30+
# Arguments:
31+
# $1 - namespace
32+
# $2 - timeout seconds (default: 900, a new GCE load balancer takes minutes)
33+
# $3 - check interval seconds (default: 15)
34+
# Returns:
35+
# 0 - Success
36+
# 1 - No Ingress in the namespace got the static IP before the timeout
37+
wait_for_gke_ingress_ip() {
38+
local namespace=$1
39+
local timeout=${2:-900}
40+
local check_interval=${3:-15}
41+
42+
if [[ -z "${namespace}" ]]; then
43+
log::error "wait_for_gke_ingress_ip: missing namespace"
44+
return 1
45+
fi
46+
47+
log::info "Waiting for the GKE Ingress in namespace '${namespace}' to get the static IP (timeout: ${timeout}s)..."
48+
local elapsed=0
49+
local address
50+
while [[ ${elapsed} -lt ${timeout} ]]; do
51+
# A failed poll must not end the job under errexit; treat it as no address yet.
52+
address=$(kubectl get ingress --namespace="${namespace}" \
53+
-o jsonpath='{.items[*].status.loadBalancer.ingress[*].ip}' 2> /dev/null) || address=""
54+
if [[ -n "${address}" ]]; then
55+
log::success "GKE Ingress in namespace '${namespace}' has the static IP: ${address}"
56+
return 0
57+
fi
58+
sleep "${check_interval}"
59+
elapsed=$((elapsed + check_interval))
60+
done
61+
62+
log::error "GKE Ingress in namespace '${namespace}' did not get the static IP within ${timeout}s."
63+
local holders
64+
holders=$(kubectl get ingress --all-namespaces \
65+
-o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,ADDRESS:.status.loadBalancer.ingress[0].ip' \
66+
2> /dev/null | grep -v '<none>' || true)
67+
if [[ -n "${holders}" ]]; then
68+
log::error "An Ingress in another namespace probably holds the static IP. Ingresses with an address:"
69+
log::error "${holders}"
70+
fi
71+
return 1
72+
}

‎.ci/pipelines/jobs/gke-operator.sh‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ handle_gke_operator() {
4040

4141
prepare_operator
4242

43+
# An Ingress left in the RBAC namespace by an interrupted job keeps the shared
44+
# static IP and would serve the first test suite, so remove it first.
45+
namespace::delete "${NAME_SPACE_RBAC}"
46+
4347
initiate_gke_operator_deployment "${NAME_SPACE}" "https://${K8S_CLUSTER_ROUTER_BASE}"
4448
testing::check_and_test "${RELEASE_NAME}" "${NAME_SPACE}" "${PW_PROJECT_SHOWCASE_K8S}" "https://${K8S_CLUSTER_ROUTER_BASE}" 50 30
4549
namespace::delete "${NAME_SPACE}"

‎docs/e2e-tests/CI-medic-guide.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ Tests on AWS Elastic Kubernetes Service. See [`eks-helm.sh`](../../.ci/pipelines
475475

476476
Tests on Google Kubernetes Engine. See [`gke-helm.sh`](../../.ci/pipelines/jobs/gke-helm.sh) / [`gke-operator.sh`](../../.ci/pipelines/jobs/gke-operator.sh). GCP utilities in [`gcloud.sh`](../../.ci/pipelines/cluster/gke/gcloud.sh).
477477

478-
**Namespaces**: `showcase-k8s-ci-nightly`, `showcase-rbac-k8s-ci-nightly`
478+
**Namespaces**: `showcase`, `showcase-rbac`
479479

480480
**Test suites**: `showcase-k8s`, `showcase-rbac-k8s`
481481

@@ -486,7 +486,9 @@ Tests on Google Kubernetes Engine. See [`gke-helm.sh`](../../.ci/pipelines/jobs/
486486

487487
**Access**: The cluster runs in the `rhdh-qe` Google Cloud project. See [Google Cloud access](../../.ci/pipelines/README.md#google-cloud-rhdh-qe-project) for how to get access.
488488

489-
**Common failures**: Since GKE uses a long-running shared cluster, most issues stem from stale state -- a previous job exited without proper cleanup, or two jobs were triggered at the same time and collided on shared resources (namespaces, certificates, static IP). If jobs overlap, adjust the cron schedule in the [ci-operator config](https://github.com/openshift/release/tree/master/ci-operator/config/redhat-developer/rhdh) to space them out.
489+
**Common failures**: Since GKE uses a long-running shared cluster, most issues stem from stale state -- a previous job exited without proper cleanup, or two jobs were triggered at the same time and collided on shared resources (namespaces, certificates, static IP). All GKE jobs run in the `rhdh-gke` Prow queue, so they cannot overlap: a queued job stays `triggered` with no pod until the running one finishes. If two jobs still collide, check the queue in the [Prow config](https://github.com/openshift/release/blob/main/core-services/prow/02_config/redhat-developer/rhdh/_prowconfig.yaml).
490+
491+
Ingresses on this cluster share the fixed IP `rhdh-static-ip`, and GCE gives it to one Ingress at a time. An Ingress left behind by an aborted or timed-out job (for example in `showcase-rbac`) therefore keeps serving `gke-ci.janus-idp.io`, and the next job's tests run against the old instance. Symptoms: the `/healthcheck` passes seconds after the Ingress is created while the RHDH pod is still starting, and guest sign-in shows no sidebar. Every GKE job deletes the other test namespace before its first deployment, and `wait_for_gke_ingress_ip` fails the job with the addresses it found if its own Ingress never gets the IP.
490492

491493
---
492494

0 commit comments

Comments
 (0)