Swarm: simplify heat WC signalling with $WAIT_CURL
This change uses the curl_cli attribute of heat's waitconditions in the swarm driver which provides a preconstructed curl command which can be used for signalling the waitcondition. This pattern has been used elsewhere in magnum and simplifies the process of using wait conditions. Change-Id: I8e5f63e6d905266cc43d4957ce95e53659d01321
This commit is contained in:
parent
907415c984
commit
e4d691f48f
|
@ -11,6 +11,4 @@ UUID=`uuidgen`
|
|||
|
||||
data=$(echo '{"status": "'${STATUS}'", "reason": "'$REASON'", "data": "'${DATA}'", "id": "'$UUID'"}')
|
||||
|
||||
curl -k -i -X POST -H "Content-Type: application/json" -H "X-Auth-Token: $WAIT_HANDLE_TOKEN" \
|
||||
--data-binary "$data" \
|
||||
"$WAIT_HANDLE_ENDPOINT"
|
||||
sh -c "${WAIT_CURL} --data-binary '${data}'"
|
||||
|
|
|
@ -11,6 +11,5 @@ write_files:
|
|||
[Service]
|
||||
Type=simple
|
||||
TimeoutStartSec=0
|
||||
ExecStart=/usr/bin/curl -k -i -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: $WAIT_HANDLE_TOKEN' \
|
||||
--data-binary '{"status": "FAILURE", "reason": "$SERVICE service failed to start.", "data": "Failure"}' \
|
||||
"$WAIT_HANDLE_ENDPOINT"
|
||||
ExecStart=/usr/bin/$WAIT_CURL \
|
||||
--data-binary '{"status": "FAILURE", "reason": "$SERVICE service failed to start.", "data": "Failure"}'
|
||||
|
|
|
@ -5,8 +5,6 @@ write_files:
|
|||
owner: "root:root"
|
||||
permissions: "0600"
|
||||
content: |
|
||||
WAIT_HANDLE_ENDPOINT="$WAIT_HANDLE_ENDPOINT"
|
||||
WAIT_HANDLE_TOKEN="$WAIT_HANDLE_TOKEN"
|
||||
WAIT_CURL="$WAIT_CURL"
|
||||
ETCD_DISCOVERY_URL="$ETCD_DISCOVERY_URL"
|
||||
DOCKER_VOLUME="$DOCKER_VOLUME"
|
||||
|
|
|
@ -5,8 +5,6 @@ write_files:
|
|||
owner: "root:root"
|
||||
permissions: "0600"
|
||||
content: |
|
||||
WAIT_HANDLE_ENDPOINT="$WAIT_HANDLE_ENDPOINT"
|
||||
WAIT_HANDLE_TOKEN="$WAIT_HANDLE_TOKEN"
|
||||
WAIT_CURL="$WAIT_CURL"
|
||||
DOCKER_VOLUME="$DOCKER_VOLUME"
|
||||
DOCKER_VOLUME_SIZE="$DOCKER_VOLUME_SIZE"
|
||||
|
|
|
@ -80,9 +80,8 @@ do
|
|||
sleep 5
|
||||
done
|
||||
|
||||
curl -k -i -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: $WAIT_HANDLE_TOKEN' \
|
||||
--data-binary '{"status": "SUCCESS", "reason": "Swarm agent ready", "data": "OK", "id": "${UUID}"}' \
|
||||
"$WAIT_HANDLE_ENDPOINT"
|
||||
${WAIT_CURL} \
|
||||
--data-binary '{"status": "SUCCESS", "reason": "Swarm agent ready", "data": "OK", "id": "${UUID}"}'
|
||||
EOF
|
||||
|
||||
chown root:root $SCRIPT
|
||||
|
|
|
@ -50,9 +50,8 @@ cat >> /etc/systemd/system/swarm-manager.service << END_SERVICE_BOTTOM
|
|||
etcd://$ETCD_SERVER_IP:2379/v2/keys/swarm/
|
||||
ExecStop=/usr/bin/docker stop swarm-manager
|
||||
Restart=always
|
||||
ExecStartPost=/usr/bin/curl -k -i -X POST -H 'Content-Type: application/json' -H 'X-Auth-Token: $WAIT_HANDLE_TOKEN' \\
|
||||
--data-binary '{"status": "SUCCESS", "reason": "Setup complete", "data": "OK", "id": "$UUID"}' \\
|
||||
"$WAIT_HANDLE_ENDPOINT"
|
||||
ExecStartPost=/usr/bin/$WAIT_CURL \\
|
||||
--data-binary '{"status": "SUCCESS", "reason": "Setup complete", "data": "OK", "id": "$UUID"}'
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
@ -213,8 +213,6 @@ resources:
|
|||
str_replace:
|
||||
template: {get_file: ../../common/templates/swarm/fragments/write-heat-params-master.yaml}
|
||||
params:
|
||||
"$WAIT_HANDLE_ENDPOINT": {get_attr: [master_wait_handle, endpoint]}
|
||||
"$WAIT_HANDLE_TOKEN": {get_attr: [master_wait_handle, token]}
|
||||
"$WAIT_CURL": {get_attr: [master_wait_handle, curl_cli]}
|
||||
"$DOCKER_VOLUME": {get_resource: docker_volume}
|
||||
"$DOCKER_VOLUME_SIZE": {get_param: docker_volume_size}
|
||||
|
@ -303,8 +301,7 @@ resources:
|
|||
template: {get_file: ../../common/templates/swarm/fragments/write-cluster-failure-service.yaml}
|
||||
params:
|
||||
"$SERVICE": swarm-manager
|
||||
"$WAIT_HANDLE_ENDPOINT": {get_attr: [master_wait_handle, endpoint]}
|
||||
"$WAIT_HANDLE_TOKEN": {get_attr: [master_wait_handle, token]}
|
||||
"$WAIT_CURL": {get_attr: [master_wait_handle, curl_cli]}
|
||||
|
||||
write_docker_socket:
|
||||
type: "OS::Heat::SoftwareConfig"
|
||||
|
@ -322,8 +319,7 @@ resources:
|
|||
params:
|
||||
"$ETCD_SERVER_IP": {get_attr: [etcd_address_switch, private_ip]}
|
||||
"$NODE_IP": {get_attr: [swarm_master_eth0, fixed_ips, 0, ip_address]}
|
||||
"$WAIT_HANDLE_ENDPOINT": {get_attr: [master_wait_handle, endpoint]}
|
||||
"$WAIT_HANDLE_TOKEN": {get_attr: [master_wait_handle, token]}
|
||||
"$WAIT_CURL": {get_attr: [master_wait_handle, curl_cli]}
|
||||
"$HTTP_PROXY": {get_param: http_proxy}
|
||||
"$HTTPS_PROXY": {get_param: https_proxy}
|
||||
"$NO_PROXY": {get_param: no_proxy}
|
||||
|
|
|
@ -191,8 +191,6 @@ resources:
|
|||
str_replace:
|
||||
template: {get_file: ../../common/templates/swarm/fragments/write-heat-params-node.yaml}
|
||||
params:
|
||||
"$WAIT_HANDLE_ENDPOINT": {get_attr: [node_wait_handle, endpoint]}
|
||||
"$WAIT_HANDLE_TOKEN": {get_attr: [node_wait_handle, token]}
|
||||
"$WAIT_CURL": {get_attr: [node_wait_handle, curl_cli]}
|
||||
"$DOCKER_VOLUME": {get_resource: docker_volume}
|
||||
"$DOCKER_VOLUME_SIZE": {get_param: docker_volume_size}
|
||||
|
@ -279,8 +277,7 @@ resources:
|
|||
template: {get_file: ../../common/templates/swarm/fragments/write-cluster-failure-service.yaml}
|
||||
params:
|
||||
"$SERVICE": swarm-agent
|
||||
"$WAIT_HANDLE_ENDPOINT": {get_attr: [node_wait_handle, endpoint]}
|
||||
"$WAIT_HANDLE_TOKEN": {get_attr: [node_wait_handle, token]}
|
||||
"$WAIT_CURL": {get_attr: [node_wait_handle, curl_cli]}
|
||||
|
||||
write_swarm_agent_service:
|
||||
type: "OS::Heat::SoftwareConfig"
|
||||
|
|
Loading…
Reference in New Issue