diff options
author | Colin Walters <walters@verbum.org> | 2017-02-23 09:24:58 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2017-02-24 22:30:24 +0000 |
commit | 2c326d705eec5f379a01ba2b584986548473d6c2 (patch) | |
tree | 6f96a37e0e4fbdc4481a19b1bdcc5ef2fc61fbd5 /src/libostree/ostree-fetcher-curl.c | |
parent | cee57a0268334d51cd312c6cdcf367bedfd3e30d (diff) | |
download | ostree-2c326d705eec5f379a01ba2b584986548473d6c2.tar.gz |
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
Diffstat (limited to 'src/libostree/ostree-fetcher-curl.c')
-rw-r--r-- | src/libostree/ostree-fetcher-curl.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/libostree/ostree-fetcher-curl.c b/src/libostree/ostree-fetcher-curl.c index be3250fb..36bd917b 100644 --- a/src/libostree/ostree-fetcher-curl.c +++ b/src/libostree/ostree-fetcher-curl.c @@ -37,6 +37,7 @@ #endif #include "ostree-fetcher.h" +#include "ostree-fetcher-util.h" #include "ostree-enumtypes.h" #include "ostree-repo-private.h" #include "otutil.h" @@ -59,6 +60,7 @@ struct OstreeFetcher GObject parent_instance; OstreeFetcherConfigFlags config_flags; + char *remote_name; char *tls_ca_db_path; char *tls_client_cert_path; char *tls_client_key_path; @@ -159,6 +161,7 @@ _ostree_fetcher_finalize (GObject *object) { OstreeFetcher *self = OSTREE_FETCHER (object); + g_free (self->remote_name); g_free (self->cookie_jar_path); g_free (self->proxy); g_assert_cmpint (g_hash_table_size (self->outstanding_requests), ==, 0); @@ -222,9 +225,11 @@ _ostree_fetcher_init (OstreeFetcher *self) OstreeFetcher * _ostree_fetcher_new (int tmpdir_dfd, + const char *remote_name, OstreeFetcherConfigFlags flags) { OstreeFetcher *fetcher = g_object_new (OSTREE_TYPE_FETCHER, "config-flags", flags, NULL); + fetcher->remote_name = g_strdup (remote_name); fetcher->tmpdir_dfd = tmpdir_dfd; return fetcher; } @@ -303,9 +308,14 @@ check_multi_info (OstreeFetcher *fetcher) curl_easy_strerror (curlres)); } else - g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "[%u] %s", - curlres, - curl_easy_strerror (curlres)); + { + g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "[%u] %s", + curlres, + curl_easy_strerror (curlres)); + if (req->fetcher->remote_name) + _ostree_fetcher_journal_failure (req->fetcher->remote_name, + eff_url, curl_easy_strerror (curlres)); + } } else { @@ -328,8 +338,13 @@ check_multi_info (OstreeFetcher *fetcher) if (req->idx + 1 == req->mirrorlist->len) { + g_autofree char *msg = g_strdup_printf ("Server returned HTTP %lu", response); g_task_return_new_error (task, G_IO_ERROR, giocode, - "Server returned HTTP %lu", response); + "%s", msg); + if (req->fetcher->remote_name) + _ostree_fetcher_journal_failure (req->fetcher->remote_name, + eff_url, msg); + } else { |