Console Output

Started by upstream project "virtuozzo-update" build number 146
originally caused by:
 Started by user Pavel Tikhomirov (ptikhomirov)
[EnvInject] - Loading node environment variables.
Building on master in workspace /var/lib/jenkins/jobs/virtuozzo-reboot/workspace
No emails were triggered.
Setting virtuozzo temporarily offline
executing script:

# Rework of https://gist.github.com/scarytom/5910362
set -e
set -u

CI_MASTER_URL="https://ci.openvz.org"
NODE="virtuozzo"

node_online() {
	curl --insecure --silent "$CI_MASTER_URL/computer/$1/api/json" | grep --silent '"temporarilyOffline":false'
}

node_busy() {
	curl --insecure --silent "$CI_MASTER_URL/computer/$1/api/json" | grep --silent '"idle":false'
}

wait_for_node() {
	while node_busy $1; do
		sleep 20
		echo -n "."
	done
	echo ""
}

# Check node is offline
if node_online $NODE; then
	echo "Node $NODE is online - can not reboot"
	exit 1
else
	echo "Node $NODE is offline - can reboot"
fi

# Wait for node to finish current workload
if node_busy $NODE; then
	echo "Waiting for node $NODE to finish its current work"
	wait_for_node $NODE
	echo "Node $NODE has finished its work"
else
	echo "Node $NODE is not busy"
fi

# Reboot node
LAST_KERNEL=$(rpm -q --last vzkernel | head -1 | sed 's/vzkernel-\(.*\)\.x86_64 .*/\1/')
CURRENT_KERNEL=$(uname -r)
if [ "$LAST_KERNEL" = "$CURRENT_KERNEL" ]; then
	echo "Node $NODE has no new kernel to reboot"
else
	echo "Rebooting $NODE into new kernel"
	reboot &
fi
Node virtuozzo is offline - can reboot
Node virtuozzo is not busy
Node virtuozzo has no new kernel to reboot
[SSH] exit-status: 0
Setting virtuozzo online
No emails were triggered.
Finished: SUCCESS