From 50c18db21e0577d31425bb000792c42f372b7246 Mon Sep 17 00:00:00 2001 From: James Slagle Date: Mon, 30 Nov 2015 16:49:41 -0500 Subject: [PATCH] Add script so that deployments won't get rerun This script creates the necessary files under /var/run/heat-config so that the next time configure.d/55-heat-config is executed via os-refresh-config, no deployments that were already known are rerun. This is a workaround for https://bugs.launchpad.net/heat-templates/+bug/1513220 in scenarios where /var/run/heat-config has already been lost due to a scenario such as a system reboot. This script is a manual workaround, and should only be executed on instances where it's known that the deployments do not need to be reapplied. Change-Id: I3ac4e280a39acb893a8ecc94712eb6265a1236d2 Partial-Bug: #1513220 --- .../bin/heat-config-rebuild-deployed | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 hot/software-config/elements/heat-config/bin/heat-config-rebuild-deployed diff --git a/hot/software-config/elements/heat-config/bin/heat-config-rebuild-deployed b/hot/software-config/elements/heat-config/bin/heat-config-rebuild-deployed new file mode 100755 index 00000000..6140a3fe --- /dev/null +++ b/hot/software-config/elements/heat-config/bin/heat-config-rebuild-deployed @@ -0,0 +1,41 @@ +#!/bin/bash + +# This script will create the needed files under /var/run/heat-config so that +# any deployments that have already been queried from the Heat api via +# os-collect-config are not executed. +# +# This is a workaround for: +# https://bugs.launchpad.net/heat-templates/+bug/1513220 +# where /var/run/heat-config has already been lost due to system reboot. + +set -eu + +deployments=$(mktemp) + +echo "Reading deployments via os-apply-config to $deployments" +os-apply-config --key deployments --type raw | jq . > $deployments + +num_deployments=$(jq length $deployments) +echo "Found $num_deployments deployments." +let "num_deployments -= 1" + +if [ -e /var/lib/heat-config/deployed ]; then + deployed_dir=/var/lib/heat-config/deployed +else + deployed_dir=/var/run/heat-config/deployed +fi +mkdir -p $deployed_dir + +for idx in $(seq 0 $num_deployments); do + deployment=$(jq .[$idx] $deployments) + deployment_id=$(jq -r .id <<<$deployment) + deployment_group=$(jq -r .group <<<$deployment) + if [ "$deployment_group" = "os-apply-config" -o \ + "$deployment_group" = "Heat::Ungrouped" ]; then + echo "Skipping creating deployed file for deployment $deployment_id as it is group:$deployment_group" + continue + else + echo "Creating $deployed_dir/${deployment_id}.json so that deployment will not be re-run" + touch $deployed_dir/${deployment_id}.json + fi +done