Skip to content

Commit

Permalink
Merge pull request #4850 from psafont/rrd_logs
Browse files Browse the repository at this point in the history
  • Loading branch information
psafont authored Nov 18, 2022
2 parents 8f4c4e5 + 1623639 commit 0ac2c9e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
20 changes: 8 additions & 12 deletions ocaml/libs/http-svr/xmlrpc_client.ml
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,11 @@ let with_transport ?(stunnel_wait_disconnect = true) transport f =
st_proc' @@ fun st_proc ->
let s = st_proc.Stunnel.fd in
let s_pid = Stunnel.getpid st_proc.Stunnel.pid in
debug "stunnel pid: %d (cached = %b) connected to %s:%d" s_pid
use_stunnel_cache host port ;
debug "stunnel pid: %d (%scached) connected to %s:%d" s_pid
(if use_stunnel_cache then "" else "not ")
host port ;
(* Call the {,un}set_stunnelpid_callback hooks around the remote call *)
let with_recorded_stunnelpid task_opt s_pid f =
debug "with_recorded_stunnelpid task_opt=%s s_pid=%d"
(Option.value ~default:"None" task_opt)
s_pid ;
let with_recorded_stunnelpid f =
( match !Internal.set_stunnelpid_callback with
| Some f ->
f task_id s_pid
Expand All @@ -355,7 +353,7 @@ let with_transport ?(stunnel_wait_disconnect = true) transport f =
()
)
in
with_recorded_stunnelpid task_id s_pid (fun () ->
with_recorded_stunnelpid (fun () ->
finally
(fun () ->
try f Unixfd.(!s)
Expand All @@ -367,11 +365,9 @@ let with_transport ?(stunnel_wait_disconnect = true) transport f =
raise e
)
(fun () ->
if use_stunnel_cache then (
Stunnel_cache.add st_proc ;
debug "stunnel pid: %d (cached = %b) returned stunnel to cache"
s_pid use_stunnel_cache
) else (
if use_stunnel_cache then
Stunnel_cache.add st_proc
else (
Unix.unlink st_proc.Stunnel.logfile ;
Stunnel.disconnect ~wait:stunnel_wait_disconnect st_proc
)
Expand Down
2 changes: 0 additions & 2 deletions ocaml/xcp-rrdd/bin/rrdd/rrdd_monitor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,6 @@ let update_rrds timestamp dss uuid_domids paused_vms =
| None ->
Some (add_ds_to StringMap.empty)
| Some dss ->
warn {|%s: found duplicate datasource with key "%s" in owner "%a"|}
__FUNCTION__ ds.ds_name owner_to_string owner ;
Some (add_ds_to dss)
in
OwnerMap.update owner merge all
Expand Down
14 changes: 7 additions & 7 deletions ocaml/xcp-rrdd/bin/rrdd/rrdd_server.ml
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ let backup_rrds (remote_address : string option) () : unit =
let destination =
match remote_address with
| None ->
"to local disk"
"local disk"
| Some address ->
Printf.sprintf "to host %s" address
Printf.sprintf "host %s" address
in
debug "backing up rrds %s" destination ;
info "%s: trying to back up RRDs to %s" __FUNCTION__ destination ;
let total_cycles = 5 in
let cycles_tried = ref 0 in
while !cycles_tried < total_cycles do
Expand All @@ -129,7 +129,7 @@ let backup_rrds (remote_address : string option) () : unit =
Mutex.unlock mutex ;
List.iter
(fun (uuid, rrd) ->
debug "Backup: saving RRD for VM uuid=%s %s" uuid destination ;
debug "%s: saving RRD for VM uuid=%s" __FUNCTION__ uuid ;
let rrd = with_lock mutex (fun () -> Rrd.copy_rrd rrd) in
archive_rrd_internal ~transport ~uuid ~rrd ()
)
Expand All @@ -142,14 +142,14 @@ let backup_rrds (remote_address : string option) () : unit =
Mutex.unlock mutex ;
List.iter
(fun (uuid, rrd) ->
debug "Backup: saving RRD for SR uuid=%s %s" uuid destination ;
debug "%s: saving RRD for SR uuid=%s" __FUNCTION__ uuid ;
let rrd = with_lock mutex (fun () -> Rrd.copy_rrd rrd) in
archive_rrd_internal ~transport ~uuid ~rrd ()
)
srrds ;
match !host_rrd with
| Some rrdi ->
debug "Backup: saving RRD for host %s" destination ;
debug "%s: saving RRD for host" __FUNCTION__ ;
let rrd = with_lock mutex (fun () -> Rrd.copy_rrd rrdi.rrd) in
archive_rrd_internal ~transport
~uuid:(Inventory.lookup Inventory._installation_uuid)
Expand All @@ -159,7 +159,7 @@ let backup_rrds (remote_address : string option) () : unit =
) else (
cycles_tried := 1 + !cycles_tried ;
if !cycles_tried >= total_cycles then
debug "Could not acquire RRD lock, skipping RRD backup"
warn "%s: Could not acquire RRD lock, skipping RRD backup" __FUNCTION__
else
Thread.delay 1.
)
Expand Down

0 comments on commit 0ac2c9e

Please sign in to comment.