Swarm: Set to CREATE_FAILED status if swarm services not started
This patch checks $NODE_SERVICES status before send SUCCESS single to heat cfn, this will make sure the bay is usable. Change-Id: Ie232c578c5c27b1842965bdda481096fb0b5c820 Closes-Bug: #1500291
This commit is contained in:
parent
7945fbf5ec
commit
832aa60436
|
@ -3,8 +3,29 @@
|
|||
. /etc/sysconfig/heat-params
|
||||
|
||||
echo "notifying heat"
|
||||
|
||||
STATUS="SUCCESS"
|
||||
REASON="Setup complete"
|
||||
DATA="OK"
|
||||
FAILED_SERVICE=""
|
||||
|
||||
for service in $NODE_SERVICES; do
|
||||
echo "checking service status for $service"
|
||||
systemctl status $service
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "$service is not active, the cluster is not valid"
|
||||
FAILED_SERVICE="$FAILED_SERVICE $service"
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -n $FAILED_SERVICE ]]; then
|
||||
STATUS="FAILURE"
|
||||
REASON="Setup failed, $FAILED_SERVICE not start up correctly."
|
||||
DATA="Failed"
|
||||
fi
|
||||
|
||||
data=$(echo '{"Status": "'${STATUS}'", "Reason": "'$REASON'", "Data": "'${DATA}'", "UniqueId": "00000"}')
|
||||
|
||||
curl -sf -X PUT -H 'Content-Type: application/json' \
|
||||
--data-binary '{"Status": "SUCCESS",
|
||||
"Reason": "Setup complete",
|
||||
"Data": "OK", "UniqueId": "00000"}' \
|
||||
"$WAIT_HANDLE"
|
||||
--data-binary "$data" \
|
||||
"$WAIT_HANDLE"
|
||||
|
|
|
@ -257,14 +257,17 @@ resources:
|
|||
config:
|
||||
str_replace:
|
||||
template: {get_file: fragments/enable-services.sh}
|
||||
params:
|
||||
params: &node_services
|
||||
"$NODE_SERVICES": "docker.socket swarm-agent swarm-manager"
|
||||
|
||||
cfn_signal:
|
||||
type: "OS::Heat::SoftwareConfig"
|
||||
properties:
|
||||
group: ungrouped
|
||||
config: {get_file: fragments/cfn-signal.sh}
|
||||
config:
|
||||
str_replace:
|
||||
template: {get_file: fragments/cfn-signal.sh}
|
||||
params: *node_services
|
||||
|
||||
disable_selinux:
|
||||
type: "OS::Heat::SoftwareConfig"
|
||||
|
|
|
@ -189,14 +189,17 @@ resources:
|
|||
config:
|
||||
str_replace:
|
||||
template: {get_file: fragments/enable-services.sh}
|
||||
params:
|
||||
params: &node_services
|
||||
"$NODE_SERVICES": "docker.socket swarm-agent"
|
||||
|
||||
cfn_signal:
|
||||
type: "OS::Heat::SoftwareConfig"
|
||||
properties:
|
||||
group: ungrouped
|
||||
config: {get_file: fragments/cfn-signal.sh}
|
||||
config:
|
||||
str_replace:
|
||||
template: {get_file: fragments/cfn-signal.sh}
|
||||
params: *node_services
|
||||
|
||||
disable_selinux:
|
||||
type: "OS::Heat::SoftwareConfig"
|
||||
|
|
Loading…
Reference in New Issue