diff options
author | Clayton Coleman <ccoleman@redhat.com> | 2017-10-29 16:58:26 -0400 |
---|---|---|
committer | Clayton Coleman <ccoleman@redhat.com> | 2017-10-30 23:31:02 -0400 |
commit | d2dd9cb8a80a20200102279ecbc81e41adc16867 (patch) | |
tree | 18edb28dba74acf7891dda029200005df6a1442a /roles/openshift_gcp/templates | |
parent | cf28d0a7711ceefdde4100495c8278278d27d148 (diff) | |
download | openshift-d2dd9cb8a80a20200102279ecbc81e41adc16867.tar.gz openshift-d2dd9cb8a80a20200102279ecbc81e41adc16867.tar.bz2 openshift-d2dd9cb8a80a20200102279ecbc81e41adc16867.tar.xz openshift-d2dd9cb8a80a20200102279ecbc81e41adc16867.zip |
Remove project metadata prefixed with the cluster prefix
Allows other scripts to create metadata that is cleaned up safely.
Diffstat (limited to 'roles/openshift_gcp/templates')
-rw-r--r-- | roles/openshift_gcp/templates/remove.j2.sh | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/roles/openshift_gcp/templates/remove.j2.sh b/roles/openshift_gcp/templates/remove.j2.sh index a1e0affec..fdc96d229 100644 --- a/roles/openshift_gcp/templates/remove.j2.sh +++ b/roles/openshift_gcp/templates/remove.j2.sh @@ -37,7 +37,7 @@ function teardown() { # scale down {{ node_group.name }} ( # performs a delete and scale down as one operation to ensure maximum parallelism - if ! instances=$( gcloud --project "{{ openshift_gcp_project }}" compute instance-groups managed list-instances "{{ openshift_gcp_prefix }}ig-{{ node_group.suffix }}" --zone "{{ openshift_gcp_zone }}" --format='value[terminator=","](instance)' ); then + if ! instances=$( gcloud --project "{{ openshift_gcp_project }}" compute instance-groups managed list-instances "{{ openshift_gcp_prefix }}ig-{{ node_group.suffix }}" --zone "{{ openshift_gcp_zone }}" --format='value[terminator=","](instance)' 2>/dev/null ); then exit 0 fi instances="${instances%?}" @@ -59,6 +59,15 @@ if gsutil ls -p "{{ openshift_gcp_project }}" "gs://{{ openshift_gcp_registry_bu fi ) & +# Project metadata prefixed with {{ openshift_gcp_prefix }} +( + for key in $( gcloud --project "{{ openshift_gcp_project }}" compute project-info describe --flatten=commonInstanceMetadata.items[] '--format=value(commonInstanceMetadata.items.key)' ); do + if [[ "${key}" == "{{ openshift_gcp_prefix }}"* ]]; then + gcloud --project "{{ openshift_gcp_project }}" compute project-info remove-metadata "--keys=${key}" + fi + done +) & + # DNS ( dns_zone="{{ dns_managed_zone | default(openshift_gcp_prefix + 'managed-zone') }}" |