[remote] a path is synced on an error

pull/870/head
Timothy Stack 3 years ago
parent 9a91cdffbb
commit b78c914d6f

@ -533,8 +533,20 @@ void tailer::looper::host_tailer::loop_body()
log_debug("Got an error: %s -- %s", pe.pe_path.c_str(),
pe.pe_msg.c_str());
if (conn.c_desired_paths.count(pe.pe_path)) {
auto desired_iter = conn.c_desired_paths.find(pe.pe_path);
if (desired_iter != conn.c_desired_paths.end()) {
report_error(this->get_display_path(pe.pe_path), pe.pe_msg);
if (!desired_iter->second.loo_tail) {
conn.c_desired_paths.erase(desired_iter);
}
}
else {
auto child_iter = conn.c_child_paths.find(pe.pe_path);
if (child_iter != conn.c_child_paths.end() &&
!child_iter->second.loo_tail) {
conn.c_child_paths.erase(child_iter);
}
}
auto remote_path = ghc::filesystem::absolute(
@ -544,6 +556,14 @@ void tailer::looper::host_tailer::loop_body()
log_debug("removing %s", local_path.c_str());
this->ht_active_files.erase(local_path);
ghc::filesystem::remove_all(local_path);
if (conn.c_desired_paths.empty() &&
conn.c_child_paths.empty()) {
log_info("tailer(%s): all desired paths synced",
this->ht_netloc.c_str());
return state_v{synced{}};
}
return std::move(this->ht_state);
},
[&](const tailer::packet_offer_block &pob) {

@ -337,6 +337,8 @@ dist_noinst_DATA = \
log-samples/sample-27353a72ba4025448f261dcfa6ea16e474187795.txt \
log-samples/sample-70c906b3c1a1cf03f15bde92ee78edfa6f9b7960.txt \
log-samples/sample-ad31f12d2adabd07e3ddda3ad5b0dbf6b49c4c99.txt \
remote-log-dir/logfile_access_log.0 \
remote-log-dir/logfile_access_log.1 \
tui-captures/tui_echo.0 \
tui-captures/tui_help.0
@ -426,7 +428,7 @@ DISTCLEANFILES = \
all-local: remote/ssh_host_dsa_key remote/ssh_host_rsa_key remote/id_rsa
distclean-local:
$(RM_V)rm -rf remote
$(RM_V)rm -rf remote remote-tmp
$(RM_V)rm -rf sessions
$(RM_V)rm -rf tmp
$(RM_V)rm -rf rotmp

@ -0,0 +1,3 @@
192.168.202.254 - - [20/Jul/2009:22:59:26 +0000] "GET /vmw/cgi/tramp HTTP/1.0" 200 134 "-" "gPXE/0.9.7"
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkboot.gz HTTP/1.0" 404 46210 "-" "gPXE/0.9.7"
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkernel.gz HTTP/1.0" 200 78929 "-" "gPXE/0.9.7"

@ -0,0 +1 @@
10.112.81.15 - - [15/Feb/2013:06:00:31 +0000] "-" 400 0 "-" "-"

@ -2,6 +2,10 @@
export HOME=${PWD}/remote
rm -rf remote-tmp
mkdir -p remote-tmp
export TMPDIR=remote-tmp
cat > remote/sshd_config <<EOF
Port 2222
UsePam no
@ -38,6 +42,13 @@ check_error_output "no error for nonexistent-host?" <<EOF
error: unable to open file: nonexistent-host: -- failed to ssh to host: ...
EOF
run_test ${lnav_test} -d /tmp/lnav.err -n \
localhost:nonexistent-file
check_error_output "no error for nonexistent-file?" <<EOF
error: unable to open file: localhost:nonexistent-file -- unable to lstat -- No such file or directory
EOF
run_test ${lnav_test} -d /tmp/lnav.err -n \
localhost:${test_dir}/logfile_access_log.0
@ -46,3 +57,23 @@ check_output "could not download remote file?" <<EOF
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkboot.gz HTTP/1.0" 404 46210 "-" "gPXE/0.9.7"
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkernel.gz HTTP/1.0" 200 78929 "-" "gPXE/0.9.7"
EOF
run_test ${lnav_test} -d /tmp/lnav.err -n \
"localhost:${test_dir}/logfile_access_log.*"
check_output "could not download remote file?" <<EOF
192.168.202.254 - - [20/Jul/2009:22:59:26 +0000] "GET /vmw/cgi/tramp HTTP/1.0" 200 134 "-" "gPXE/0.9.7"
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkboot.gz HTTP/1.0" 404 46210 "-" "gPXE/0.9.7"
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkernel.gz HTTP/1.0" 200 78929 "-" "gPXE/0.9.7"
10.112.81.15 - - [15/Feb/2013:06:00:31 +0000] "-" 400 0 "-" "-"
EOF
run_test ${lnav_test} -d /tmp/lnav.err -n \
"localhost:${test_dir}/remote-log-dir"
check_output "could not download remote file?" <<EOF
192.168.202.254 - - [20/Jul/2009:22:59:26 +0000] "GET /vmw/cgi/tramp HTTP/1.0" 200 134 "-" "gPXE/0.9.7"
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkboot.gz HTTP/1.0" 404 46210 "-" "gPXE/0.9.7"
192.168.202.254 - - [20/Jul/2009:22:59:29 +0000] "GET /vmw/vSphere/default/vmkernel.gz HTTP/1.0" 200 78929 "-" "gPXE/0.9.7"
10.112.81.15 - - [15/Feb/2013:06:00:31 +0000] "-" 400 0 "-" "-"
EOF

Loading…
Cancel
Save