Step: upi-deprovision-vsphere

This step deprovisions the vsphere deployments created by upi-install-vsphere. It requires the ipi-deprovision step already be executed against the cluster.

Container image used for this step: upi-installer

upi-installer resolves to an image built or imported by the ci-operator configuration (documentation).

Environment

Step exposes no environmental variables except the defaults.

Source Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash

set -o nounset
set -o errexit
set -o pipefail

trap 'CHILDREN=$(jobs -p); if test -n "${CHILDREN}"; then kill ${CHILDREN} && wait; fi' TERM

# TODO:
# Worse case scenario tear down
# Use govc to remove virtual machines if terraform fails

export HOME=/tmp
export AWS_SHARED_CREDENTIALS_FILE=/var/run/vault/vsphere-aws/.awscred
export AWS_DEFAULT_REGION=us-east-1

installer_dir=/tmp/installer
cluster_name=$(<"${SHARED_DIR}"/clustername.txt)

echo "$(date -u --rfc-3339=seconds) - sourcing context from vsphere_context.sh..."
# shellcheck source=/dev/null
declare cloud_where_run
declare target_hw_version
source "${SHARED_DIR}/vsphere_context.sh"

echo Deprovisioning $cluster_name

echo "$(date -u --rfc-3339=seconds) - Collecting vCenter performance data and alerts"

echo "{\"hw_version\":  \"vmx-${target_hw_version}\", \"cloud\": \"${cloud_where_run}\"}" > "${ARTIFACT_DIR}/runtime-config.json"

set +e
source "${SHARED_DIR}/govc.sh"
vm_path="/${GOVC_DATACENTER}/vm/${cluster_name}"
vcenter_state=${ARTIFACT_DIR}/vcenter_state
mkdir ${vcenter_state}

govc object.collect "/${GOVC_DATACENTER}/host" triggeredAlarmState &> ${vcenter_state}/host_alarms.log
govc metric.ls $vm_path/* | xargs govc metric.sample -json -n 60 $vm_path/* &> ${vcenter_state}/vm_metrics.json

clustervms=$(govc ls "${vm_path}")
for vm in $clustervms; do
echo Collecting alarms from $vm
echo " >>>> Alarms for: $vm" >> ${vcenter_state}/vm_alarms.log
govc object.collect $vm triggeredAlarmState &>> ${vcenter_state}/vm_alarms.log
done
set -e

echo "$(date -u --rfc-3339=seconds) - Copying config from shared dir..."

mkdir -p "${installer_dir}/auth"
pushd ${installer_dir}

cp -t "${installer_dir}" \
    "${SHARED_DIR}/install-config.yaml" \
    "${SHARED_DIR}/metadata.json" \
    "${SHARED_DIR}/terraform.tfvars" \
    "${SHARED_DIR}/secrets.auto.tfvars" \
    "${SHARED_DIR}/bootstrap.ign" \
    "${SHARED_DIR}/worker.ign" \
    "${SHARED_DIR}/master.ign"

cp -t "${installer_dir}/auth" \
    "${SHARED_DIR}/kubeadmin-password" \
    "${SHARED_DIR}/kubeconfig"

# Copy sample UPI files
cp -rt "${installer_dir}" \
    /var/lib/openshift-install/upi/"${CLUSTER_TYPE}"/*

tar -xf "${SHARED_DIR}/terraform_state.tar.xz"

rm -rf .terraform || true
terraform init -input=false -no-color
# In some instances either the IPAM records or AWS DNS records
# are removed before teardown is executed causing terraform destroy
# to fail - this is causing resource leaks. Do not refresh the state.
terraform destroy -refresh=false -auto-approve -no-color &
wait "$!"

Properties

Property Value Description
Termination grace period[?] 10m0s Period of time until SIGKILL signal is sent to the test pod (after SIGTERM signal is sent).
Resource requests (cpu) 10m Used in .resources.requests of the pod running this step.
Resource requests (memory) 100Mi Used in .resources.requests of the pod running this step.

GitHub Link:

https://github.com/openshift/release/blob/master/ci-operator/step-registry/upi/deprovision/vsphere/upi-deprovision-vsphere-ref.yaml

Owners:

Approvers:

Source code for this page located on GitHub