Commit a50a2bff authored by Nikos Skalkotos's avatar Nikos Skalkotos
Browse files

cleanup! cleanup! cleanup! cleanup!

 * Change the monitor message type names once again (hope this is
   the final version)
 * Pass -u (unbuffered) to sed to retain the actual output order in
   the log file
 * Fix a bug in helper code where the starting `{' was missing from
   the monitoring messages
parent 44038aae
......@@ -40,6 +40,10 @@ CLEANUP=( )
ERRORS=( )
WARNINGS=( )
MSG_TYPE_ERROR="error"
MSG_TYPE_TASK_START="task-start"
MSG_TYPE_TASK_END="task-end"
add_cleanup() {
local cmd=""
for arg; do cmd+=$(printf "%q " "$arg"); done
......@@ -57,13 +61,13 @@ warn() {
echo "Warning: $@" >&2
}
report_start_task() {
report_task_start() {
local type="start-task"
local type="$MSG_TYPE_TASK_START"
local timestamp=$(date +%s.%N)
local name="${PROGNAME}"
report+="\"type\":\"$type\","
report+="{\"type\":\"$type\","
report+="\"timestamp\":$(date +%s.%N),"
report+="\"name\":\"$name\"}"
......@@ -85,15 +89,14 @@ json_list() {
echo "$report"
}
report_end_task() {
local type="end-task"
report_task_end() {
local type="$MSG_TYPE_TASK_END"
local timestam=$(date +%s.%N)
local name=${PROGNAME}
local warnings=$(json_list WARNINGS[@])
report="\"type\":\"$type\","
report+="\"timestamp\":$(date +%s),"
report="{\"type\":\"$type\","
report+="\"timestamp\":$(date +%s.%N),"
report+="\"name\":\"$name\","
report+="\"warnings\":\"$warnings\"}"
......@@ -101,14 +104,14 @@ report_end_task() {
}
report_error() {
local type="ganeti-error"
local type="$MSG_TYPE_ERROR"
local timestamp=$(date +%s.%N)
local location="${PROGNAME}"
local errors=$(json_list ERRORS[@])
local warnings=$(json_list WARNINGS[@])
local stderr="$(cat "$STDERR_FILE" | sed 's/"/\\"/g')"
report="\"type\":\"$type\","
report="{\"type\":\"$type\","
report+="\"timestamp\":$(date +%s),"
report+="\"location\":\"$location\","
report+="\"errors\":$errors,"
......@@ -400,7 +403,7 @@ task_cleanup() {
rc=$?
if [ $rc -eq 0 ]; then
report_end_task
report_task_end
else
report_error
fi
......
......@@ -27,7 +27,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
# Check if the task should be prevented from running.
check_if_excluded
......
......@@ -28,7 +28,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
# Check if the task should be prevented from running.
check_if_excluded
......
......@@ -27,7 +27,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
if [ ! -d "$SNF_IMAGE_TARGET" ]; then
log_error "Target dir:\`$SNF_IMAGE_TARGET' is missing"
......
......@@ -28,7 +28,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
# Check if the task should be prevented from running.
check_if_excluded
......
......@@ -28,7 +28,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
# Check if the task should be prevented from running.
check_if_excluded
......
......@@ -35,7 +35,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
# Check if the task should be prevented from running.
check_if_excluded
......
......@@ -28,7 +28,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
if [ -z "$SNF_IMAGE_TARGET" ]; then
log_error "Target dir: \`$SNF_IMAGE_TARGET' is missing"
......
......@@ -28,7 +28,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
# Check if the task should be prevented from running.
check_if_excluded
......
......@@ -28,7 +28,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
# Check if the task should be prevented from running.
check_if_excluded
......
......@@ -28,7 +28,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
# Check if the task should be prevented from running.
check_if_excluded
......
......@@ -29,7 +29,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
# Check if the task should be prevented from running.
check_if_excluded
......
......@@ -28,7 +28,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
# Check if the task should be prevented from running.
check_if_excluded
......
......@@ -28,7 +28,7 @@ set -e
. "@commondir@/common.sh"
trap task_cleanup EXIT
report_start_task
report_task_start
if [ ! -d "$SNF_IMAGE_TARGET" ]; then
log_error "Target dir:\`$SNF_IMAGE_TARGET' is missing"
......
......@@ -27,7 +27,7 @@ CURL="curl"
network_backend_support="@network_backend_support@"
ERROR_TYPE="ganeti-error"
MSG_TYPE_ERROR="error"
CLEANUP=( )
ERROR_MSGS=( )
......@@ -52,7 +52,7 @@ report_error() {
local error_file=$1
local monitor_fd=$2
local type="$ERROR_TYPE"
local type="$MSG_TYPE_ERROR"
local location="host"
local msg="["
......
......@@ -32,6 +32,7 @@ import prctl
import signal
import socket
MSG_TYPE="copy-progress"
def parse_arguments(args):
from optparse import OptionParser
......@@ -122,7 +123,7 @@ def main():
(sys.argv[0], pid, iofname))
message = {}
message['type'] = 'copy-progress'
message['type'] = MSG_TYPE
message['total'] = opts.read_bytes
while True:
......
......@@ -35,7 +35,7 @@ if [ -n "$PROGRESS_MONITOR" ]; then
{ sleep 1; $PROGRESS_MONITOR "$instance" < "$monitor_pipe" ; } &
monitor_pid="$!"
else
cat "$monitor_pipe" &
sed -u 's|^|MONITOR MSG: |g' < "$monitor_pipe" &
monitor_pid="$!"
fi
......@@ -161,7 +161,7 @@ $TIMEOUT -k "$HELPER_HARD_TIMEOUT" "$HELPER_SOFT_TIMEOUT" \
-fda "$floppy" -vga none -nographic -parallel none -monitor null \
-kernel "$HELPER_KERNEL" -initrd "$HELPER_INITRD" \
-append "quiet ro root=/dev/sda1 console=ttyS0,9600n8 snf_image_activate_helper" \
2>&1 | sed 's|^|HELPER: |g'
2>&1 | sed -u 's|^|HELPER: |g'
rc=$?
set -e
if [ $rc -ne 0 ]; then
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment