Step: ipi-deprovision-vsphere-lb

Deletes AWS Network Load Balancer and Target Groups by their ARN saved in ${SHARED_DIR}/nlb_arn.txt and ${SHARED_DIR}/tg_arn.txt.

Container image used for this step: tools

tools 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
#!/bin/bash

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

# Continue iff this is a launch job
if [ "${JOB_NAME_SAFE}" != "launch" ]; then
  echo "Skipping Load Balancer deprovision."
  exit 0
fi

export AWS_DEFAULT_REGION=us-west-2  # TODO: Derive this?
export AWS_SHARED_CREDENTIALS_FILE=/var/run/vault/vsphere/.awscred
export AWS_MAX_ATTEMPTS=50
export AWS_RETRY_MODE=adaptive
export HOME=/tmp

if ! command -v aws &> /dev/null
then
    echo "$(date -u --rfc-3339=seconds) - Install AWS cli..."
    export PATH="${HOME}/.local/bin:${PATH}"
    if command -v pip3 &> /dev/null
    then
        pip3 install --user awscli
    else
        if [ "$(python -c 'import sys;print(sys.version_info.major)')" -eq 2 ]
        then
          easy_install --user 'pip<21'
          pip install --user awscli
        else
          echo "$(date -u --rfc-3339=seconds) - No pip available exiting..."
          exit 1
        fi
    fi
fi


if [ -f "${SHARED_DIR}"/nlb_arn.txt ]; then
  # Initiate delete of NLB and wait for it
  nlb_arn=$(<"${SHARED_DIR}"/nlb_arn.txt)
  aws elbv2 delete-load-balancer --load-balancer-arn "${nlb_arn}"
  echo "Waiting for Network Load Balancer to delete..."
  aws elbv2 wait load-balancers-deleted --load-balancer-arns "${nlb_arn}"
  echo "Network Load Balancer deleted."
fi

# Load array of ARNs created in vsphere-lb step:
declare -a tg_arns
if [ -f "${SHARED_DIR}"/tg_arn.txt ]; then
  mapfile -t tg_arns < "${SHARED_DIR}"/tg_arn.txt
fi

for arn in "${tg_arns[@]}"; do
  aws elbv2 delete-target-group --target-group-arn $arn
done

echo "Target Groups deleted."

Properties

Property Value Description
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/ipi/deprovision/vsphere/lb/ipi-deprovision-vsphere-lb-ref.yaml

Owners:

Approvers:

Source code for this page located on GitHub