fetcher: Log failures into journal
Particularly when HTTP requests fail, I really want a lot more information. We could theoretically stuff it into the `GError` message field, but that gets ugly *fast*. Using the systemd journal allows us to log things in a structured fashion. Right now e.g. rpm-ostree won't be aware of this additional information, but I think we could teach it to be down the line. In the short term, users can learn to find it from `systemctl status rpm-ostreed` or `journalctl -b -r -u rpm-ostreed`, etc. One thing I'd like to do next is log successful fetches of e.g. commit objects as well with more information about the originating server (things like the final URL if we were redirected, did we use TLS pinning, what was the negotiated TLS version+cipher, etc). Closes: #708 Approved by: jlebon
This commit is contained in:
1 parent
cee57a0268
commit
2c326d705e
6 files changed
+64
-6
No files matched your search
@@ -23,6 +23,10 @@
|
||||
#include <gio/gfiledescriptorbased.h>
|
||||
#include <gio/gunixoutputstream.h>
|
||||
|
||||
#ifdef HAVE_LIBSYSTEMD
|
||||
#include <systemd/sd-journal.h>
|
||||
#endif
|
||||
|
||||
#include "ostree-fetcher-util.h"
|
||||
#include "otutil.h"
|
||||
|
||||
@@ -122,3 +126,23 @@ _ostree_fetcher_request_uri_to_membuf (OstreeFetcher *fetcher,
|
||||
out_contents, max_size,
|
||||
cancellable, error);
|
||||
}
|
||||
|
||||
#define OSTREE_HTTP_FAILURE_ID SD_ID128_MAKE(f0,2b,ce,89,a5,4e,4e,fa,b3,a9,4a,79,7d,26,20,4a)
|
||||
|
||||
void
|
||||
_ostree_fetcher_journal_failure (const char *remote_name,
|
||||
const char *url,
|
||||
const char *msg)
|
||||
{
|
||||
#ifdef HAVE_LIBSYSTEMD
|
||||
/* Sanity - we don't want to log this when doing local/file pulls */
|
||||
if (!remote_name)
|
||||
return;
|
||||
sd_journal_send ("MESSAGE=libostree HTTP error from remote %s for <%s>: %s",
|
||||
remote_name, url, msg,
|
||||
"MESSAGE_ID=" SD_ID128_FORMAT_STR, SD_ID128_FORMAT_VAL(OSTREE_HTTP_FAILURE_ID),
|
||||
"OSTREE_REMOTE=%s", remote_name,
|
||||
"OSTREE_URL=%s", url,
|
||||
NULL);
|
||||
#endif
|
||||
}
|
||||
Reference in new issue
Block a user