From b4d6562bbabdc87a7a29af9841fcf77c8ce6ab90 Mon Sep 17 00:00:00 2001 From: Scott Hussey Date: Mon, 19 Nov 2018 12:45:35 -0600 Subject: [PATCH] (fix) Fix import job race condition - If the import job triggers before the rack controller pod(s) have registered w/ the region controller, then it must fully timeout and then reschedule to pass. Update it so that each time it checks for rack controller image sync, it updates the list of all registered rack controllers. - Update register service to be part of Dockerfile so it can be enabled. Change-Id: I72e190d472ad259da65b2e583b2a16d8adf660f5 --- .../bin/_import-boot-resources.sh.tpl | 2 +- charts/maas/templates/configmap-etc.yaml | 2 -- .../etc/_register-rack-controller.service.tpl | 12 ---------- images/maas-rack-controller/Dockerfile | 4 ++++ .../scripts/register-rack-controller.sh | 22 ------------------- 5 files changed, 5 insertions(+), 37 deletions(-) delete mode 100644 charts/maas/templates/etc/_register-rack-controller.service.tpl delete mode 100644 images/maas-rack-controller/scripts/register-rack-controller.sh diff --git a/charts/maas/templates/bin/_import-boot-resources.sh.tpl b/charts/maas/templates/bin/_import-boot-resources.sh.tpl index cb0d704..15db50e 100644 --- a/charts/maas/templates/bin/_import-boot-resources.sh.tpl +++ b/charts/maas/templates/bin/_import-boot-resources.sh.tpl @@ -90,11 +90,11 @@ function check_then_set { } function check_for_rack_sync { - rack_list=$(maas ${ADMIN_USERNAME} rack-controllers read | tail -n +1 | jq -r '.[] | .system_id') sync_list="" while [[ ${JOB_TIMEOUT} -gt 0 ]] do + rack_list=$(maas ${ADMIN_USERNAME} rack-controllers read | tail -n +1 | jq -r '.[] | .system_id') for rack_id in ${rack_list} do selected_imgs=$(maas ${ADMIN_USERNAME} rack-controller list-boot-images ${rack_id} | tail -n +1 | jq ".images[] | select( .name | contains(\"${MAAS_DEFAULT_DISTRO}\")) | .name") diff --git a/charts/maas/templates/configmap-etc.yaml b/charts/maas/templates/configmap-etc.yaml index 0c98c22..4a07137 100644 --- a/charts/maas/templates/configmap-etc.yaml +++ b/charts/maas/templates/configmap-etc.yaml @@ -40,8 +40,6 @@ data: {{ tuple "etc/_regiond.conf.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} nsswitch.conf: | {{ tuple "etc/_nsswitch.conf.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} - register-rack-controller.service: | -{{ tuple "etc/_register-rack-controller.service.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} {{- if .Values.conf.drivers }} drivers.yaml: | {{ tuple "etc/_drivers.yaml.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} diff --git a/charts/maas/templates/etc/_register-rack-controller.service.tpl b/charts/maas/templates/etc/_register-rack-controller.service.tpl deleted file mode 100644 index 0bf64b4..0000000 --- a/charts/maas/templates/etc/_register-rack-controller.service.tpl +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Register with MaaS Region Controller -Wants=network-online.target -After=network-online.target - -[Service] -Type=oneshot -PassEnvironment=MAAS_ENDPOINT MAAS_REGION_SECRET -ExecStart=/usr/local/bin/register-rack-controller.sh - -[Install] -WantedBy=multi-user.target diff --git a/images/maas-rack-controller/Dockerfile b/images/maas-rack-controller/Dockerfile index 316c4bc..23e73da 100644 --- a/images/maas-rack-controller/Dockerfile +++ b/images/maas-rack-controller/Dockerfile @@ -43,6 +43,10 @@ RUN rsyslogd; apt-get install -y maas-cli=$MAAS_VERSION maas-rack-controller=$MA RUN mv /usr/sbin/tcpdump /usr/bin/tcpdump RUN ln -s /usr/bin/tcpdump /usr/sbin/tcpdump +# register ourselves with the region controller +COPY scripts/register-rack-controller.service /lib/systemd/system/register-rack-controller.service +RUN systemctl enable register-rack-controller.service + # Patch so that Calico interfaces are ignored # dc6350: this appears to be fixed in maas master as of 10/4/2018, but that change is not in 2.3.5 COPY 2.3_nic_filter.patch /tmp/2.3_nic_filter.patch diff --git a/images/maas-rack-controller/scripts/register-rack-controller.sh b/images/maas-rack-controller/scripts/register-rack-controller.sh deleted file mode 100644 index add7edf..0000000 --- a/images/maas-rack-controller/scripts/register-rack-controller.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# show env -env > /tmp/env - -echo "register-rack-controller URL: ${MAAS_ENDPOINT}" - -# note the secret must be a valid hex value - -# register forever -while [ 1 ]; -do - if maas-rack register --url=http://${MAAS_ENDPOINT}/MAAS --secret="${MAAS_REGION_SECRET}"; - then - echo "Successfully registered with MaaS Region Controller" - break - else - echo "Unable to register with http://${MAAS_ENDPOINT}/MAAS... will try again" - sleep 10 - fi; - -done;