Skip to content
Merged
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 @@ -98,23 +98,31 @@ gcloud projects delete "${CP_PROJECT_ID}" --quiet || true
EXTERNAL_DNS_GSA="external-dns@${HYPERSHIFT_GCP_CI_PROJECT}.iam.gserviceaccount.com"

# Clean up DNS records from the CI zone (DNS records use the hosted cluster name)
DNS_CLEANUP_FAILED=false
if [[ -n "${HC_CLUSTER_NAME}" ]]; then
echo "Cleaning up DNS records for hosted cluster ${HC_CLUSTER_NAME}..."
DNS_SUFFIX="in.${HC_CLUSTER_NAME}.${HYPERSHIFT_GCP_CI_DNS_DOMAIN}."
DNS_RECORDS=$(gcloud dns record-sets list \
if ! DNS_RECORDS=$(gcloud dns record-sets list \
--zone="${HYPERSHIFT_GCP_CI_DNS_ZONE}" \
--project="${HYPERSHIFT_GCP_CI_PROJECT}" \
--filter="name ~ ${DNS_SUFFIX}" \
--format="csv[no-heading](name,type)" 2>/dev/null || true)
--format="csv[no-heading](name,type)"); then
echo "ERROR: Failed to list DNS records - check service account permissions"
DNS_CLEANUP_FAILED=true
DNS_RECORDS=""
fi

if [[ -n "${DNS_RECORDS}" ]]; then
while IFS=, read -r name type; do
[[ -z "${name}" ]] && continue
echo "Deleting DNS record: ${name} ${type}"
gcloud dns record-sets delete "${name}" \
if ! gcloud dns record-sets delete "${name}" \
--type="${type}" \
--zone="${HYPERSHIFT_GCP_CI_DNS_ZONE}" \
--project="${HYPERSHIFT_GCP_CI_PROJECT}" --quiet || true
--project="${HYPERSHIFT_GCP_CI_PROJECT}" --quiet; then
echo "ERROR: Failed to delete DNS record ${name} ${type}"
DNS_CLEANUP_FAILED=true
fi
Comment thread
cristianoveiga marked this conversation as resolved.
done <<< "${DNS_RECORDS}"
else
echo "No DNS records found matching ${DNS_SUFFIX}"
Expand All @@ -137,4 +145,9 @@ gcloud iam service-accounts remove-iam-policy-binding "${EXTERNAL_DNS_GSA}" \
--project="${HYPERSHIFT_GCP_CI_PROJECT}" || true
set -x

if [[ "${DNS_CLEANUP_FAILED}" == "true" ]]; then
echo "Cleanup complete but DNS cleanup failed - orphaned DNS records may remain"
exit 1
fi

echo "Cleanup complete"
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ workflow:
GKE_RELEASE_CHANNEL: "stable"
TECH_PREVIEW_NO_UPGRADE: "true"
HYPERSHIFT_GCP_CI_PROJECT: "gcp-hcp-hypershift-ci"
HYPERSHIFT_GCP_CI_DNS_ZONE: "hypershift-ci-zone"
HYPERSHIFT_GCP_CI_DNS_ZONE: "hypershift-ci-gcp-hcp-openshiftapps-com"
HYPERSHIFT_GCP_CI_DNS_DOMAIN: "hypershift-ci.gcp-hcp.openshiftapps.com"