Skip to content

Commit a466b83

Browse files
committed
ci-operator/step-registry/ipi/deprovision/vsphere: Decompose into sub-steps
So we can recycle the vanilla IPI deprovision step without needing to make changes to it (other than using the UPI image to get the vSphere CA certs). This also makes the link between the resource-creating and resource-destroying steps more transparent. Also store the hosted zone ID in a secret so we don't have to look it up again, which lets us simplify the secret loading a bit in the DNS deprovisioning. Remove the ipi-deprovision-vsphere chain, since there's no reason folks would use it instead of the ipi-vsphere-post chain.
1 parent 1953a35 commit a466b83

13 files changed

+73
-42
lines changed

ci-operator/step-registry/ipi/conf/vsphere/dns/ipi-conf-vsphere-dns-commands.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ hosted_zone_id="$(aws route53 list-hosted-zones-by-name \
2424
--dns-name "${base_domain}" \
2525
--query "HostedZones[? Config.PrivateZone != \`true\` && Name == \`${base_domain}.\`].Id" \
2626
--output text)"
27-
27+
echo "${hosted_zone_id}" > "${SHARED_DIR}/hosted-zone.txt"
2828

2929
echo "Creating DNS records..."
3030
cat > "${SHARED_DIR}"/dns-create.json <<EOF

ci-operator/step-registry/ipi/conf/vsphere/dns/ipi-conf-vsphere-dns-ref.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ ref:
1010
Uses VIPs in ${SHARED_DIR}/vips.txt to create route53 dns records. Outputs
1111
${SHARED_DIR}/basedomain.txt to ensure consistent basedomain in conf and
1212
deprovision steps. Saves batch job to delete DNS records to
13-
${SHARED_DIR}/dns-delete.json for use in deprovisioning.
13+
${SHARED_DIR}/dns-delete.json for use in deprovisioning, with the hosted
14+
zone ID in ${SHARED_DIR}/hosted-zone.txt.

ci-operator/step-registry/ipi/conf/vsphere/vips/ipi-conf-vsphere-vips-ref.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ ref:
1010
Using secrets from the vSphere cluster profile, the vSphere VIP setup step
1111
reserves IP addresses through IPAM and saves them to $SHARED_DIR/vips.txt
1212
for later use in creating DNS records and the install config. They are also
13-
needed in deprovisioning to release the reserved VIPs.
13+
needed in deprovisioning to release the reserved VIPs (via the
14+
ipi-deprovision-vsphere-vips step).
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
approvers:
2+
- abhinavdahiya
3+
- jcpowermac
4+
- patrickdillon
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -o nounset
4+
set -o errexit
5+
set -o pipefail
6+
7+
cluster_profile=/var/run/secrets/ci.openshift.io/cluster-profile
8+
export AWS_SHARED_CREDENTIALS_FILE=${cluster_profile}/.awscred
9+
10+
HOSTED_ZONE_ID="$(cat "${SHARED_DIR}/hosted-zone.txt")"
11+
12+
echo "Deleting Route53 DNS records..."
13+
aws route53 change-resource-record-sets --hosted-zone-id "${HOSTED_ZONE_ID}" --change-batch "file:///${SHARED_DIR}/dns-delete.json"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ref:
2+
as: ipi-deprovision-vsphere-dns
3+
from: upi-installer
4+
commands: ipi-deprovision-vsphere-dns-commands.sh
5+
resources:
6+
requests:
7+
cpu: 1000m
8+
memory: 100Mi
9+
documentation: >-
10+
Releases DNS records via `${SHARED_DIR}/hosted-zone.txt` and `${SHARED_DIR}/dns-delete.json`. The IP addresses were allocated with the ipi-conf-vsphere-dns step.

ci-operator/step-registry/ipi/deprovision/vsphere/ipi-deprovision-vsphere-chain.yaml

Lines changed: 0 additions & 7 deletions
This file was deleted.

ci-operator/step-registry/ipi/deprovision/vsphere/ipi-deprovision-vsphere-commands.sh

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../deprovision/ipi-deprovision-deprovision-commands.sh

ci-operator/step-registry/ipi/deprovision/vsphere/ipi-deprovision-vsphere-ref.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ ref:
77
cpu: 1000m
88
memory: 100Mi
99
documentation: >-
10-
Reads the VIP and DNS records created in the setup phases from $SHARED_DIR
11-
and delete them. Also uses $SHARED_DIR/basedomain.txt to ensure consistent
12-
basedomain as setup steps.
10+
The IPI deprovision step tears down the cluster. Unlike the other
11+
IPI deprovisioning, the installer image must include vCenter CA
12+
certs.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
approvers:
2+
- abhinavdahiya
3+
- jcpowermac
4+
- patrickdillon
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
set -o nounset
4+
set -o errexit
5+
set -o pipefail
6+
7+
cluster_profile=/var/run/secrets/ci.openshift.io/cluster-profile
8+
tfvars_path="${cluster_profile}/secret.auto.tfvars"
9+
cluster_name="${NAMESPACE}-${JOB_NAME_HASH}"
10+
ipam_token=$(grep -oP 'ipam_token="\K[^"]+' "${tfvars_path}")
11+
12+
export AWS_SHARED_CREDENTIALS_FILE="${cluster_profile}/.awscred"
13+
14+
# FIXME: should this be using ${SHARED_DIR}/vips.txt ?
15+
echo "Releasing IP addresses from IPAM server..."
16+
for i in {0..2}
17+
do
18+
curl "http://139.178.89.254/api/removeHost.php?apiapp=address&apitoken=${ipam_token}&host=${cluster_name}-$i"
19+
done
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
ref:
2+
as: ipi-deprovision-vsphere-vips
3+
from: upi-installer
4+
commands: ipi-deprovision-vsphere-vips-commands.sh
5+
resources:
6+
requests:
7+
cpu: 1000m
8+
memory: 100Mi
9+
documentation: >-
10+
Releases IP addresses from the IPAM server. The IP addresses were allocated with the ipi-conf-vsphere-vips step.
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
chain:
22
as: ipi-vsphere-post
33
steps:
4-
- chain: ipi-deprovision
4+
- chain: gather
5+
- ref: ipi-deprovision-vsphere
6+
- ref: ipi-deprovision-vsphere-vips
7+
- ref: ipi-deprovision-vsphere-dns
58
documentation: |-
69
The IPI cleanup step contains all steps that deprovision an OpenShift
710
cluster on vSphere, provisioned by the `ipi-vsphere-pre` chain.

0 commit comments

Comments
 (0)