Skip to content

Commit 4d751cf

Browse files
riya-17portante
authored andcommitted
Improves handling of ssh error in sync-satellite logs
Fixes #1609 Replace tabs with spaces
1 parent 22b427b commit 4d751cf

File tree

7 files changed

+202
-6
lines changed

7 files changed

+202
-6
lines changed

server/bin/gold/test-28.txt

Lines changed: 163 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
+++ Running pbench-sync-satellite satellite-one
2+
--- Finished pbench-sync-satellite (status=2)
3+
+++ Running unit test audit
4+
Template: pbench-unittests.v3.server-reports
5+
Index: pbench-unittests.v3.server-reports.1970-01 1
6+
len(actions) = 1
7+
[
8+
{
9+
"_id": "5ca1ab1e70015f100dedfab1ed0ff1ce",
10+
"_index": "pbench-unittests.v3.server-reports.1970-01",
11+
"_op_type": "create",
12+
"_source": {
13+
"@generated-by": {
14+
"commit_id": "unit-test",
15+
"group_id": 43,
16+
"hostname": "example.com",
17+
"pid": 42,
18+
"user_id": 44,
19+
"version": ""
20+
},
21+
"@timestamp": "1970-01-01T00:00:42",
22+
"chunk_id": 1,
23+
"doctype": "status",
24+
"name": "pbench-audit-server",
25+
"text": "pbench-audit-server.run-1970-01-01T00:00:42-UTC(unit-test)\n",
26+
"total_chunks": 1,
27+
"total_size": 59
28+
},
29+
"_type": "pbench-server-reports"
30+
}
31+
]
32+
--- Finished unit test audit (status=0)
33+
+++ var/www/html tree state (/var/tmp/pbench-test-server/test-28/var-www-html)
34+
lrwxrwxrwx 63 incoming -> /var/tmp/pbench-test-server/test-28/pbench/public_html/incoming
35+
drwxrwxr-x - pbench-results-host-info.versioned
36+
lrwxrwxrwx 38 pbench-results-host-info.versioned/pbench-results-host-info.URL002 -> pbench-results-host-info.URL002.active
37+
-rw-rw-r-- 134 pbench-results-host-info.versioned/pbench-results-host-info.URL002.active
38+
-rw-rw-r-- 95 pbench-results-host-info.versioned/pbench-results-host-info.URL002.maint
39+
lrwxrwxrwx 62 results -> /var/tmp/pbench-test-server/test-28/pbench/public_html/results
40+
lrwxrwxrwx 61 static -> /var/tmp/pbench-test-server/test-28/pbench/public_html/static
41+
lrwxrwxrwx 60 users -> /var/tmp/pbench-test-server/test-28/pbench/public_html/users
42+
--- var/www/html tree state
43+
+++ results host info (/var/tmp/pbench-test-server/test-28/var-www-html/pbench-results-host-info.versioned)
44+
/var/tmp/pbench-test-server/test-28/var-www-html/pbench-results-host-info.versioned/pbench-results-host-info.URL002.active:[email protected]:/var/tmp/pbench-test-server/test-28/pbench-local/pbench-move-results-receive/fs-version-002
45+
/var/tmp/pbench-test-server/test-28/var-www-html/pbench-results-host-info.versioned/pbench-results-host-info.URL002.maint:MESSAGE===System Under Maintenance - please retry at a later time ([email protected])
46+
--- results host info
47+
+++ var/www/html-satellite tree state (/var/tmp/pbench-test-server/test-28/var-www-html-satellite)
48+
lrwxrwxrwx 73 incoming -> /var/tmp/pbench-test-server/test-28/pbench-satellite/public_html/incoming
49+
drwxrwxr-x - pbench-results-host-info.versioned
50+
lrwxrwxrwx 38 pbench-results-host-info.versioned/pbench-results-host-info.URL002 -> pbench-results-host-info.URL002.active
51+
-rw-rw-r-- 138 pbench-results-host-info.versioned/pbench-results-host-info.URL002.active
52+
-rw-rw-r-- 95 pbench-results-host-info.versioned/pbench-results-host-info.URL002.maint
53+
lrwxrwxrwx 72 results -> /var/tmp/pbench-test-server/test-28/pbench-satellite/public_html/results
54+
lrwxrwxrwx 71 static -> /var/tmp/pbench-test-server/test-28/pbench-satellite/public_html/static
55+
lrwxrwxrwx 70 users -> /var/tmp/pbench-test-server/test-28/pbench-satellite/public_html/users
56+
--- var/www/html-satellite tree state
57+
+++ results host info (/var/tmp/pbench-test-server/test-28/var-www-html-satellite/pbench-results-host-info.versioned)
58+
/var/tmp/pbench-test-server/test-28/var-www-html-satellite/pbench-results-host-info.versioned/pbench-results-host-info.URL002.active:[email protected]:/var/tmp/pbench-test-server/test-28/pbench-satellite-local/pbench-move-results-receive/fs-version-002
59+
/var/tmp/pbench-test-server/test-28/var-www-html-satellite/pbench-results-host-info.versioned/pbench-results-host-info.URL002.maint:MESSAGE===System Under Maintenance - please retry at a later time ([email protected])
60+
--- results host info
61+
+++ pbench tree state (/var/tmp/pbench-test-server/test-28/pbench)
62+
drwxrwxr-x - archive
63+
drwxrwxr-x - archive/fs-version-001
64+
drwxrwxr-x - public_html
65+
drwxrwxr-x - public_html/incoming
66+
drwxrwxr-x - public_html/results
67+
drwxrwxr-x - public_html/static
68+
drwxrwxr-x - public_html/static/css
69+
drwxrwxr-x - public_html/static/css/v0.2
70+
drwxrwxr-x - public_html/static/css/v0.2/css
71+
-rw-rw-r-- 308 public_html/static/css/v0.2/css/pbench_utils.css
72+
drwxrwxr-x - public_html/static/css/v0.3
73+
drwxrwxr-x - public_html/static/css/v0.3/css
74+
-rw-rw-r-- 11798 public_html/static/css/v0.3/css/LICENSE.TXT
75+
-rw-rw-r-- 3663 public_html/static/css/v0.3/css/jschart.css
76+
drwxrwxr-x - public_html/static/js
77+
drwxrwxr-x - public_html/static/js/v0.2
78+
drwxrwxr-x - public_html/static/js/v0.2/js
79+
-rw-rw-r-- 9415 public_html/static/js/v0.2/js/app.js
80+
-rw-rw-r-- 5556 public_html/static/js/v0.2/js/pbench_utils.js
81+
drwxrwxr-x - public_html/static/js/v0.3
82+
drwxrwxr-x - public_html/static/js/v0.3/js
83+
-rw-rw-r-- 11798 public_html/static/js/v0.3/js/LICENSE.TXT
84+
-rw-rw-r-- 143934 public_html/static/js/v0.3/js/jschart.js
85+
drwxrwxr-x - public_html/users
86+
--- pbench tree state
87+
+++ pbench-local tree state (/var/tmp/pbench-test-server/test-28/pbench-local)
88+
drwxrwxr-x - logs
89+
drwxrwxr-x - logs/pbench-audit-server
90+
-rw-rw-r-- 0 logs/pbench-audit-server/pbench-audit-server.error
91+
-rw-rw-r-- 437 logs/pbench-audit-server/pbench-audit-server.log
92+
drwxrwxr-x - logs/pbench-sync-satellite
93+
drwxrwxr-x - logs/pbench-sync-satellite/ONE
94+
-rw-rw-r-- 0 logs/pbench-sync-satellite/ONE/change_state.log
95+
-rw-rw-r-- 105 logs/pbench-sync-satellite/pbench-sync-satellite.error
96+
-rw-rw-r-- 61 logs/pbench-sync-satellite/pbench-sync-satellite.log
97+
drwxrwxr-x - pbench-move-results-receive
98+
drwxrwxr-x - pbench-move-results-receive/fs-version-002
99+
drwxrwxr-x - quarantine
100+
drwxrwxr-x - quarantine/duplicates-002
101+
drwxrwxr-x - quarantine/errors-002
102+
drwxrwxr-x - quarantine/md5-002
103+
drwxrwxr-x - tmp
104+
--- pbench-local tree state
105+
+++ pbench-satellite tree state (/var/tmp/pbench-test-server/test-28/pbench-satellite)
106+
drwxrwxr-x - archive
107+
drwxrwxr-x - archive/fs-version-001
108+
drwxrwxr-x - public_html
109+
drwxrwxr-x - public_html/incoming
110+
drwxrwxr-x - public_html/results
111+
drwxrwxr-x - public_html/static
112+
drwxrwxr-x - public_html/static/css
113+
drwxrwxr-x - public_html/static/css/v0.2
114+
drwxrwxr-x - public_html/static/css/v0.2/css
115+
-rw-rw-r-- 308 public_html/static/css/v0.2/css/pbench_utils.css
116+
drwxrwxr-x - public_html/static/css/v0.3
117+
drwxrwxr-x - public_html/static/css/v0.3/css
118+
-rw-rw-r-- 11798 public_html/static/css/v0.3/css/LICENSE.TXT
119+
-rw-rw-r-- 3663 public_html/static/css/v0.3/css/jschart.css
120+
drwxrwxr-x - public_html/static/js
121+
drwxrwxr-x - public_html/static/js/v0.2
122+
drwxrwxr-x - public_html/static/js/v0.2/js
123+
-rw-rw-r-- 9415 public_html/static/js/v0.2/js/app.js
124+
-rw-rw-r-- 5556 public_html/static/js/v0.2/js/pbench_utils.js
125+
drwxrwxr-x - public_html/static/js/v0.3
126+
drwxrwxr-x - public_html/static/js/v0.3/js
127+
-rw-rw-r-- 11798 public_html/static/js/v0.3/js/LICENSE.TXT
128+
-rw-rw-r-- 143934 public_html/static/js/v0.3/js/jschart.js
129+
drwxrwxr-x - public_html/users
130+
--- pbench-satellite tree state
131+
+++ pbench-satellite-local tree state (/var/tmp/pbench-test-server/test-28/pbench-satellite-local)
132+
drwxrwxr-x - logs
133+
drwxrwxr-x - pbench-move-results-receive
134+
drwxrwxr-x - pbench-move-results-receive/fs-version-002
135+
drwxrwxr-x - quarantine
136+
drwxrwxr-x - quarantine/duplicates-002
137+
drwxrwxr-x - quarantine/errors-002
138+
drwxrwxr-x - quarantine/md5-002
139+
drwxrwxr-x - tmp
140+
--- pbench-satellite-local tree state
141+
+++ pbench log file contents
142+
++++ pbench-local/logs
143+
+++++ pbench-audit-server/pbench-audit-server.error
144+
----- pbench-audit-server/pbench-audit-server.error
145+
+++++ pbench-audit-server/pbench-audit-server.log
146+
1970-01-01T00:00:42.000000 DEBUG pbench-audit-server.indexer update_templates -- done templates (start ts: 1970-01-01T00:00:42-UTC, end ts: 1970-01-01T00:00:42-UTC, duration: 0.00s, successes: 1, retries: 0)
147+
1970-01-01T00:00:42.000000 DEBUG pbench-audit-server.report post_status -- posted status (start ts: 1970-01-01T00:00:42-UTC, end ts: 1970-01-01T00:00:42-UTC, duration: 0.00s, successes: 1, duplicates: 0, failures: 0, retries: 0)
148+
----- pbench-audit-server/pbench-audit-server.log
149+
+++++ pbench-sync-satellite/ONE/change_state.log
150+
----- pbench-sync-satellite/ONE/change_state.log
151+
+++++ pbench-sync-satellite/pbench-sync-satellite.error
152+
pbench-sync-satellite: FAILED: ssh: connect to host pbench-satellite-error.example.com: No route to host
153+
----- pbench-sync-satellite/pbench-sync-satellite.error
154+
+++++ pbench-sync-satellite/pbench-sync-satellite.log
155+
run-1970-01-01T00:00:42-UTC: start - 1970-01-01T00:00:42-UTC
156+
----- pbench-sync-satellite/pbench-sync-satellite.log
157+
---- pbench-local/logs
158+
++++ pbench-satellite-local/logs
159+
---- pbench-satellite-local/logs
160+
--- pbench log file contents
161+
+++ test-execution.log file contents
162+
ssh pbench-satellite-error.example.com /var/tmp/pbench-test-server/test-28/opt/pbench-server-satellite/bin/pbench-sync-package-tarballs
163+
--- test-execution.log file contents

server/bin/pbench-base.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,12 @@ function log_finish {
102102
}
103103

104104
function log_exit {
105-
echo "${PROG}: ${1}" >&4
105+
local _msg="${PROG}: ${1}"
106+
if [[ -z "${3}" ]]; then
107+
printf -- "%s\n" "${_msg}" >&4
108+
else
109+
printf -- "%s\n" "${_msg}" | tee -a "${3}" >&4
110+
fi
106111
log_finish
107112
if [[ -z "${2}" ]]; then
108113
exit 1

server/bin/pbench-remote-sync-package-tarballs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,19 @@ if [[ -z "${dir}" || -z "${PROG}" ]]; then
2222
fi
2323

2424
case $# in
25-
2)
25+
3)
2626
:
2727
;;
2828
*)
29-
echo "Usage: $PROG <satellite-config> <output-tar-ball>" >&2
29+
echo "Usage: $PROG <satellite-config> <output-tar-ball> <ssh-error>" >&2
3030
exit 1
3131
;;
3232
esac
3333

3434

3535
satellite_config=$1
3636
output_tar_ball=$2
37+
errors=$3
3738
shift 2
3839

3940
remote_host=$(getconf.py satellite-host $satellite_config)
@@ -47,4 +48,4 @@ if [ -z "${remote_opt}" ]; then
4748
exit 1
4849
fi
4950

50-
ssh ${remote_host} "${remote_opt}/bin/pbench-sync-package-tarballs" > ${output_tar_ball}
51+
ssh ${remote_host} "${remote_opt}/bin/pbench-sync-package-tarballs" > ${output_tar_ball} 2> ${errors}

server/bin/pbench-sync-satellite.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,13 @@ typeset -i nprocessed=0
118118
typeset -i nfailed_md5=0
119119
typeset -i nerrs=0
120120

121+
syncerr=${tmp}/syncerrors
122+
121123
# Fetch all the tarballs from remote host's archive
122-
pbench-remote-sync-package-tarballs ${satellite_config} ${tmp}/satellite.${remote_prefix}.tar
124+
pbench-remote-sync-package-tarballs ${satellite_config} ${tmp}/satellite.${remote_prefix}.tar ${syncerr}
123125
rc=$?
124126
if [[ $rc != 0 ]] ;then
125-
log_exit "$PROG: pbench-remote-sync-package-tarballs: failed." 2
127+
log_exit "FAILED: $(cat ${syncerr})" 2 "${mail_content}"
126128
fi
127129

128130
if [ -s $tmp/satellite.$remote_prefix.tar ]; then
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
install-dir = %(unittest-dir)s/opt/pbench-server
2+
default-host = pbench-satellite-error.example.com
3+
4+
[logging]
5+
logger_type = file
6+
logging_level = WARNING
7+
8+
[satellite-one]
9+
# NOTE WELL: this satellite host name, pbench-satellite.example.com, is the
10+
# host name expected by the mock ssh command which triggers the behavior of
11+
# running the actual commands instead of just echoing them.
12+
satellite-host = pbench-satellite-error.example.com
13+
14+
15+
###########################################################################
16+
# The rest will come from the global state config file and the default config file.
17+
[config]
18+
path = %(unittest-dir)s/tmp, %(install-dir)s/lib/config
19+
files = state-pbench-server.cfg

server/bin/test-bin/ssh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ if [ "${remote_host}" = "pbench-satellite.example.com" ] ;then
99
# environment from leaking into the "remote" server environment.
1010
unset _PBENCH_SERVER_CONFIG
1111
$*
12+
elif [ "${remote_host}" == "pbench-satellite-error.example.com" ] ;then
13+
echo "ssh: connect to host ${remote_host}: No route to host" >&2
14+
exit 1
1215
fi
1316
exit 0

server/bin/unittests

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,9 @@ declare -A cmds=(
755755

756756
# Test culling unpacked tar balls
757757
[test-27]="_run pbench-cull-unpacked-tarballs"
758+
759+
# Test ssh-error
760+
[test-28]="_run pbench-sync-satellite satellite-one"
758761
)
759762
all_tests_sorted=$(for x in ${!cmds[@]} ;do echo $x ;done | sed 's/\./-/' | sort -n -t '-' -k 3 | sort -n -t '-' -k 2 --stable | sed 's/\(.*-[0-9]\+\)-\([0-9]\+\)/\1.\2/')
760763

0 commit comments

Comments
 (0)