From d1b71540268f3ea23c362dbabb68351e7407d89c Mon Sep 17 00:00:00 2001 From: Ernestas Kulik Date: Mon, 11 Feb 2019 09:39:05 +0100 Subject: [PATCH] systemd: logs: Use reportd for reporting problems Currently, crash reporting is done by running the command-line tool, which asks for user input on the standard streams. This completely breaks most workflows, as, for example, one needs to log in to their RH Bugzilla account to file a bug, but the prompt is shown on the server-side only. reportd was written for the express purpose of dealing with such cases. With version 0.5, it supports signaling clients about incoming prompts and provides an API to deal with them. Closes: #11150 --- pkg/systemd/host.css | 37 ++ pkg/systemd/logs.html | 14 +- pkg/systemd/logs.js | 100 ++--- pkg/systemd/reporting.jsx | 511 ++++++++++++++++++++++ test/verify/check-docker | 2 +- test/verify/check-journal | 184 ++++++-- test/verify/files/mock-bugzilla-server.py | 44 ++ test/verify/files/mock-faf-server.py | 46 +- tools/cockpit.spec | 5 + 9 files changed, 814 insertions(+), 129 deletions(-) create mode 100644 pkg/systemd/reporting.jsx create mode 100755 test/verify/files/mock-bugzilla-server.py diff --git a/pkg/systemd/host.css b/pkg/systemd/host.css index c16b3d750..38bf274f7 100644 --- a/pkg/systemd/host.css +++ b/pkg/systemd/host.css @@ -434,3 +434,40 @@ body { .fa-exclamation-circle { color: var(--pf-global--danger-color--100); } + +.full-width { + width: 100%; +} + +table.reporting-table tr:first-child td { + border-top: none; +} + +table.reporting-table td:first-child { + white-space: nowrap; + width: 40%; +} + +table.reporting-table td:nth-child(2) { + text-align: start; + width: 60%; +} + +table.reporting-table td:nth-child(2) > .spinner { + display: inline-block; + margin-right: 0.5em; + vertical-align: middle; +} + +td.report-column { + flex-direction: row-reverse; +} + +#journal-entry-heading { + padding-bottom: 0.5rem; +} + +#journal-entry-message { + padding-left: 1.5rem; + +} diff --git a/pkg/systemd/logs.html b/pkg/systemd/logs.html index 4a5754b57..41b7b2679 100644 --- a/pkg/systemd/logs.html +++ b/pkg/systemd/logs.html @@ -81,17 +81,11 @@ along with Cockpit; If not, see . diff --git a/pkg/systemd/logs.js b/pkg/systemd/logs.js index b10e2a480..2367e9f74 100644 --- a/pkg/systemd/logs.js +++ b/pkg/systemd/logs.js @@ -20,6 +20,8 @@ import $ from "jquery"; import cockpit from "cockpit"; import { journal } from "journal"; +import moment from "moment"; +import { init_reporting } from "./reporting.jsx"; import ReactDOM from 'react-dom'; import React from 'react'; @@ -426,12 +428,14 @@ $(function() { var cursor = cockpit.location.path[0]; var out = $('#journal-entry-fields'); + const reportingTable = document.getElementById("journal-entry-reporting-table"); + if (reportingTable != null) { + reportingTable.remove(); + } + out.empty(); function show_entry(entry) { - var d = new Date(entry.__REALTIME_TIMESTAMP / 1000); - $('#journal-entry-date').text(d.toString()); - var id; if (entry.SYSLOG_IDENTIFIER) id = entry.SYSLOG_IDENTIFIER; @@ -446,13 +450,20 @@ $(function() { id = entry.PROBLEM_BINARY; } - $('#journal-entry-id').text(id); + $('#journal-entry-heading').text(id); + + const crumb = $("#journal-entry-crumb"); + const date = moment(new Date(entry.__REALTIME_TIMESTAMP / 1000)); if (is_problem) { + crumb.text(cockpit.format(_("$0: crash at $1"), id, date.format("YYYY-MM-DD HH:mm:ss"))); + find_problems().done(function() { create_problem(out, entry); }); } else { + crumb.text(cockpit.format(_("Entry at $0"), date.format("YYYY-MM-DD HH:mm:ss"))); + create_entry(out, entry); } } @@ -476,8 +487,21 @@ $(function() { }); } + function create_message_row(entry) { + const reasonColumn = document.createElement("th"); + reasonColumn.setAttribute("colspan", 2); + reasonColumn.setAttribute("id", "journal-entry-message"); + reasonColumn.appendChild(document.createTextNode(journal.printable(entry.MESSAGE))); + + const reason = document.createElement("tr"); + reason.appendChild(reasonColumn); + + return reason; + } + function create_entry(out, entry) { - $('#journal-entry-message').text(journal.printable(entry.MESSAGE)); + out.append(create_message_row(entry)); + var keys = Object.keys(entry).sort(); $.each(keys, function (i, key) { if (key !== 'MESSAGE') { @@ -515,7 +539,11 @@ $(function() { .replaceWith(new_content); } - $('#journal-entry-message').text(''); + const heading = document.createElement("h3"); + heading.appendChild(document.createTextNode(_("Extended Information"))); + + const caption = document.createElement("caption"); + caption.appendChild(heading); var ge_t = $('
  • ').append($('').append($('').text(_("General")))); var pi_t = $('
  • ').append($('').append($('').text(_("Problem info")))); @@ -527,56 +555,18 @@ $(function() { .append( $('').append($('
    '))); - var tab = $('