deployment: provide status report via http://$DEPLOYMENT_SYSTEM:4242/status

VMs on Proxmox 2.1-14 (pve-qemu-kvm 1.1-8, 2.6.32-14-pve) have an
annoying problem with our installations, where the deployed
system freezes as soon as some action takes place on the network
stack. For example invoking "lsof -i -n" on the rebooted system
causes such a freeze.

The only solution to work around this issue seems to be stopping
and then restarting the VM. As we need to handle this
automatically we need some kind of API to retrieve system state.
By writing the current deployment state into some file and
providing it through http://$DEPLOYMENT_SYSTEM:4242/status this
should get us there.

From: Michael Prokop <mprokop@sipwise.com>
ksolomko/vlan
Michael Prokop 13 years ago
parent 0d9e56473c
commit f16fb9f527

@ -55,13 +55,30 @@ DEBIAN_RELEASE=squeeze
KANTAN=false KANTAN=false
HALT=false HALT=false
REBOOT=false REBOOT=false
STATUS_DIRECTORY=/srv/deployment/
if [ -L /sys/block/vda ] ; then if [ -L /sys/block/vda ] ; then
export DISK=vda # will be configured as /dev/vda export DISK=vda # will be configured as /dev/vda
else else
export DISK=sda # will be configured as /dev/sda export DISK=sda # will be configured as /dev/sda
fi fi
### helper functions {{{ ### helper functions {{{
set_deploy_status() {
[ -n "$1" ] || return 1
echo "$*" > "${STATUS_DIRECTORY}"/status
}
enable_deploy_status_server() {
mkdir -p "${STATUS_DIRECTORY}"
(
cd "${STATUS_DIRECTORY}"
python -m SimpleHTTPServer 4242 &
)
}
CMD_LINE=$(cat /proc/cmdline) CMD_LINE=$(cat /proc/cmdline)
stringInString() { stringInString() {
local to_test_="$1" # matching pattern local to_test_="$1" # matching pattern
@ -138,6 +155,10 @@ logit "host-IP: $(ip-screen)"
logit "deployment-version: $SCRIPT_VERSION" logit "deployment-version: $SCRIPT_VERSION"
# }}} # }}}
enable_deploy_status_server
set_deploy_status "checkBootParam"
# provide method to boot live system without running installer # provide method to boot live system without running installer
if checkBootParam debugmode ; then if checkBootParam debugmode ; then
set -x set -x
@ -400,6 +421,8 @@ if ! "$NGCP_INSTALLER" ; then
unset ROLE unset ROLE
fi fi
set_deploy_status "getconfig"
# load site specific profile if specified # load site specific profile if specified
if [ -n "$PROFILE" ] && [ -n "$NETSCRIPT_SERVER" ] ; then if [ -n "$PROFILE" ] && [ -n "$NETSCRIPT_SERVER" ] ; then
getconfig() { getconfig() {
@ -541,6 +564,8 @@ elif "$CE_EDITION" ; then
esac esac
fi fi
set_deploy_status "settings"
### echo settings ### echo settings
[ -n "$SP_VERSION" ] && SP_VERSION_STR=$SP_VERSION \ [ -n "$SP_VERSION" ] && SP_VERSION_STR=$SP_VERSION \
|| SP_VERSION_STR="<latest>" || SP_VERSION_STR="<latest>"
@ -592,6 +617,8 @@ fi
##### all parameters set ####################################################### ##### all parameters set #######################################################
set_deploy_status "start"
# measure time of installation procedure - everyone loves stats! # measure time of installation procedure - everyone loves stats!
start_seconds=$(cut -d . -f 1 /proc/uptime) start_seconds=$(cut -d . -f 1 /proc/uptime)
@ -626,6 +653,8 @@ if "$PRO_EDITION" ; then
fi fi
fi fi
set_deploy_status "diskverify"
# TODO - hardcoded for now, to avoid data damage # TODO - hardcoded for now, to avoid data damage
check_for_supported_disk() { check_for_supported_disk() {
if grep -q 'ServeRAID' /sys/block/${DISK}/device/model ; then if grep -q 'ServeRAID' /sys/block/${DISK}/device/model ; then
@ -688,6 +717,8 @@ fi
echo "root:sipwise" | chpasswd echo "root:sipwise" | chpasswd
## partition disk ## partition disk
set_deploy_status "disksetup"
# 2000GB = 2097152000 blocks in /proc/partitions - so make a rough estimation # 2000GB = 2097152000 blocks in /proc/partitions - so make a rough estimation
if [ $(awk "/ ${DISK}$/ {print \$3}" /proc/partitions) -gt 2000000000 ] ; then if [ $(awk "/ ${DISK}$/ {print \$3}" /proc/partitions) -gt 2000000000 ] ; then
TABLE=gpt TABLE=gpt
@ -766,6 +797,8 @@ case "$DEBIAN_RELEASE" in
;; ;;
esac esac
set_deploy_status "debootstrap"
# install Debian # install Debian
echo y | grml-debootstrap \ echo y | grml-debootstrap \
--arch "${ARCH}" \ --arch "${ARCH}" \
@ -969,6 +1002,8 @@ deb http://deb.sipdoc.net debian main
EOF EOF
fi fi
set_deploy_status "ngcp-installer"
# install and execute ngcp-installer # install and execute ngcp-installer
logit "ngcp-installer: $INSTALLER" logit "ngcp-installer: $INSTALLER"
if $PRO_EDITION && ! $LINUX_HA3 ; then # HA v2 if $PRO_EDITION && ! $LINUX_HA3 ; then # HA v2
@ -1480,6 +1515,7 @@ EOT
# upload db dump only if we're deploying a trunk version # upload db dump only if we're deploying a trunk version
if $TRUNK_VERSION && ! checkBootParam ngcpnoupload ; then if $TRUNK_VERSION && ! checkBootParam ngcpnoupload ; then
set_deploy_status "upload_data"
echo "Trunk version detected, considering DB dump upload." echo "Trunk version detected, considering DB dump upload."
upload_db_dump upload_db_dump
echo "Trunk version detected, considering yml configs upload." echo "Trunk version detected, considering yml configs upload."
@ -1518,6 +1554,8 @@ echo
logit "Successfully finished deployment process [$(date) - running ${SECONDS} seconds]" logit "Successfully finished deployment process [$(date) - running ${SECONDS} seconds]"
echo "Successfully finished deployment process [$(date) - running ${SECONDS} seconds]" echo "Successfully finished deployment process [$(date) - running ${SECONDS} seconds]"
set_deploy_status "finished"
if "$REBOOT" ; then if "$REBOOT" ; then
echo "Rebooting system as requested via ngcpreboot" echo "Rebooting system as requested via ngcpreboot"
for key in s u b ; do for key in s u b ; do

Loading…
Cancel
Save