Browse Source

GCP: include all etcd discovery records in one line

This would ensure deprovisioning works correctly
Vadim Rutkovsky 6 years ago
parent
commit
acc14caef2
1 changed files with 6 additions and 2 deletions
  1. 6 2
      roles/openshift_gcp/templates/remove.j2.sh

+ 6 - 2
roles/openshift_gcp/templates/remove.j2.sh

@@ -15,9 +15,13 @@ if gcloud --project "{{ openshift_gcp_project }}" dns managed-zones describe "${
         # record-sets transaction.
         gcloud dns record-sets export --project "{{ openshift_gcp_project }}" -z "${dns_zone}" --zone-file-format "${dns}"
 
-        # Remove etcd discovery record
+        # Write the header
         ETCD_DNS_NAME="_etcd-server-ssl._tcp.{{ lookup('env', 'INSTANCE_PREFIX') | mandatory }}.{{ public_hosted_zone }}."
-        grep -F -e "${ETCD_DNS_NAME}" "${dns}" | awk '{ print "--name", $1, "--ttl", $2, "--type", $4, "\x27"$5" "$6" "$7" "$8"\x27"; }'  >> "${dns}.input" || true
+        grep -F -e "${ETCD_DNS_NAME}" "${dns}" | awk '{ print "--name", $1, "--ttl", $2, "--type", $4 }' | head -n1 | xargs echo -n > "${dns}.input"
+        # Append all etcd records
+        grep -F -e "${ETCD_DNS_NAME}" "${dns}" | awk '{ print " \x27"$5" "$6" "$7" "$8"\x27"; }' | tr -d '\n\r' >> "${dns}.input" || true
+        echo >> "${dns}.input"
+
 
         if [ -s "${dns}.input" ]; then
             rm -f "${dns}"