From 3e8598373ad9420b238b90d0fc2b4fef6e70f956 Mon Sep 17 00:00:00 2001 From: Zach Loafman Date: Mon, 12 Dec 2016 12:43:01 -0800 Subject: [PATCH] cluster/aws: Clean up dhcp-options After adding the aws janitor, the thing we're consistently sweeping is the DhcpOptionSets created by cluster/aws/util.sh (and there were thousands on the first run). Fix it! --- cluster/aws/util.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cluster/aws/util.sh b/cluster/aws/util.sh index b5497500ea9..ca07bbbb0eb 100755 --- a/cluster/aws/util.sh +++ b/cluster/aws/util.sh @@ -1489,6 +1489,21 @@ function kube-down { echo "has a name other than '${CLUSTER_ID}'." >&2 fi + if [[ -z "${DHCP_OPTION_SET_ID:-}" ]]; then + dhcp_option_ids=$($AWS_CMD describe-dhcp-options \ + --output text \ + --filters Name=tag:Name,Values=kubernetes-dhcp-option-set \ + Name=tag:KubernetesCluster,Values=${CLUSTER_ID} \ + --query DhcpOptions[].DhcpOptionsId \ + | tr "\t" "\n") + for dhcp_option_id in ${dhcp_option_ids}; do + echo "Deleting DHCP option set: ${dhcp_option_id}" + $AWS_CMD delete-dhcp-options --dhcp-options-id $dhcp_option_id > $LOG + done + else + echo "Skipping deletion of pre-existing DHCP option set: ${DHCP_OPTION_SET_ID}" + fi + echo "Deleting IAM Instance profiles" delete-iam-profiles }