Don't send duplicate signals via 99-refresh-completed

Currently we send signals for every deployment, even those already
completed, so instead keep a record of already-signalled deployments
similar to how heat-config does, which will remove the annoying
SIGNAL_COMPLETE: Unknown events (and possibly be slightly faster too).

Partial-Bug: #1564627
Change-Id: I0ec7ed4cc4e58a43a91e8323cb9a1bcaaafc9752
This commit is contained in:
Steven Hardy 2016-05-09 19:32:34 +01:00
parent fdf717f2aa
commit de7012df7c
1 changed files with 15 additions and 2 deletions

View File

@ -63,10 +63,23 @@ DEPLOYMENTS=$(os-apply-config --key deployments --type raw --key-default "" |
select(.inputs[].name == \"deploy_signal_id\") |
.id + (.inputs | map(select(.name == \"deploy_signal_id\")) | .[].value)) |
.[]")
# We store a file per deployment similar to how heat-config stores them under
# /var/lib/heat-config/deployed, here we use /var/lib/os-apply-config-deployments/deployed
DEPLOYED_DIR="/var/lib/os-apply-config-deployments/deployed"
if [ ! -d $DEPLOYED_DIR ]; then
mkdir -p $DEPLOYED_DIR
fi
for dep in ${DEPLOYMENTS}
do
DEPLOY_ID=$(echo $dep | sed "s/http.*$//")
DEPLOY_URL=$(echo $dep | sed "s/^.*http/http/")
echo "Signalling os-apply-config deployment $DEPLOY_ID $DEPLOY_URL"
call_curl_deployment POST $DEPLOY_URL "os-apply-config deployment $DEPLOY_ID completed"
if [ ! -f $DEPLOYED_DIR/$DEPLOY_ID ]; then
echo "Signalling os-apply-config deployment $DEPLOY_ID $DEPLOY_URL"
call_curl_deployment POST $DEPLOY_URL "os-apply-config deployment $DEPLOY_ID completed"
touch $DEPLOYED_DIR/$DEPLOY_ID
else
echo "Skipping $DEPLOY_ID, already deployed"
fi
done