Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ NODEPOOL_SA=$(awk -F'"' '/"nodepool-mgmt"/{print $4}' "${IAM_OUTPUT}")
CLOUDCONTROLLER_SA=$(awk -F'"' '/"cloud-controller"/{print $4}' "${IAM_OUTPUT}")
STORAGE_SA=$(awk -F'"' '/"gcp-pd-csi"/{print $4}' "${IAM_OUTPUT}")
IMAGEREGISTRY_SA=$(awk -F'"' '/"image-registry"/{print $4}' "${IAM_OUTPUT}")
NETWORK_SA=$(awk -F'"' '/"cloud-network"/{print $4}' "${IAM_OUTPUT}")

if [[ -z "${PROJECT_NUMBER}" || -z "${POOL_ID}" || -z "${PROVIDER_ID}" || -z "${CONTROLPLANE_SA}" || -z "${NODEPOOL_SA}" || -z "${CLOUDCONTROLLER_SA}" || -z "${STORAGE_SA}" || -z "${IMAGEREGISTRY_SA}" ]]; then
if [[ -z "${PROJECT_NUMBER}" || -z "${POOL_ID}" || -z "${PROVIDER_ID}" || -z "${CONTROLPLANE_SA}" || -z "${NODEPOOL_SA}" || -z "${CLOUDCONTROLLER_SA}" || -z "${STORAGE_SA}" || -z "${IMAGEREGISTRY_SA}" || -z "${NETWORK_SA}" ]]; then
echo "ERROR: Failed to parse WIF configuration from IAM output"
cat "${IAM_OUTPUT}"
exit 1
Expand All @@ -131,6 +132,7 @@ echo "${NODEPOOL_SA}" > "${SHARED_DIR}/nodepool-sa"
echo "${CLOUDCONTROLLER_SA}" > "${SHARED_DIR}/cloudcontroller-sa"
echo "${STORAGE_SA}" > "${SHARED_DIR}/storage-sa"
echo "${IMAGEREGISTRY_SA}" > "${SHARED_DIR}/imageregistry-sa"
echo "${NETWORK_SA}" > "${SHARED_DIR}/network-sa"

echo "WIF configuration saved to SHARED_DIR"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ CONTROLPLANE_SA=""
CLOUDCONTROLLER_SA=""
STORAGE_SA=""
IMAGEREGISTRY_SA=""
NETWORK_SA=""
SA_SIGNING_KEY_PATH=""

if [[ -f "${SHARED_DIR}/wif-project-number" ]]; then
Expand All @@ -71,6 +72,9 @@ fi
if [[ -f "${SHARED_DIR}/imageregistry-sa" ]]; then
IMAGEREGISTRY_SA="$(<"${SHARED_DIR}/imageregistry-sa")"
fi
if [[ -f "${SHARED_DIR}/network-sa" ]]; then
NETWORK_SA="$(<"${SHARED_DIR}/network-sa")"
fi
Comment on lines +75 to +77
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.

⚠️ Potential issue | 🟡 Minor

Add an explicit non-empty guard for NETWORK_SA before test execution.

Right now, an empty value still gets forwarded on Line 160. Failing early here would make workflow breakages much easier to diagnose.

Suggested hardening
 if [[ -f "${SHARED_DIR}/network-sa" ]]; then
     NETWORK_SA="$(<"${SHARED_DIR}/network-sa")"
 fi
+
+if [[ -z "${NETWORK_SA}" ]]; then
+    echo "ERROR: network service account not found or empty at ${SHARED_DIR}/network-sa"
+    echo "Ensure hypershift-gcp-hosted-cluster-setup step produced network-sa"
+    exit 1
+fi

Also applies to: 160-160

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@ci-operator/step-registry/hypershift/gcp/run-e2e/hypershift-gcp-run-e2e-commands.sh`
around lines 75 - 77, Add a strict non-empty guard for the NETWORK_SA variable
after it is read from SHARED_DIR so an empty string cannot be propagated into
test execution; check that NETWORK_SA is set and not empty (e.g., test -n or [[
-n "${NETWORK_SA}" ]]) and exit with an error message if it is empty, so
wherever NETWORK_SA is later used in the script (the test execution invocation
that currently forwards NETWORK_SA) you can assume a valid value; update the
block that reads NETWORK_SA and add the guard/early-exit handling with a clear
error log.

if [[ -f "${SHARED_DIR}/sa-signing-key-path" ]]; then
SA_SIGNING_KEY_PATH="$(<"${SHARED_DIR}/sa-signing-key-path")"
fi
Expand Down Expand Up @@ -153,6 +157,7 @@ hack/ci-test-e2e.sh -test.v \
--e2e.gcp-cloudcontroller-sa="${CLOUDCONTROLLER_SA}" \
--e2e.gcp-storage-sa="${STORAGE_SA}" \
--e2e.gcp-imageregistry-sa="${IMAGEREGISTRY_SA}" \
--e2e.gcp-network-sa="${NETWORK_SA}" \
--e2e.gcp-sa-signing-key-path="${SA_SIGNING_KEY_PATH}" \
--e2e.gcp-oidc-issuer-url="${OIDC_ISSUER_URL}" \
--e2e.gcp-boot-image="${GCP_BOOT_IMAGE}" \
Expand Down