(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
This commit is contained in:
Scott Hussey 2018-11-19 12:45:35 -06:00
parent 2d71c24e0f
commit b4d6562bba
5 changed files with 5 additions and 37 deletions

View File

@ -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")

View File

@ -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 }}

View File

@ -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

View File

@ -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

View File

@ -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;