Skip to content

Commit

Permalink
kdump: Fix unhandled promise rejection on service start failure
Browse files Browse the repository at this point in the history
Log the error to the console instead of crashing the page. The UI
already shows the failure in an alert.
  • Loading branch information
martinpitt committed Jan 22, 2024
1 parent d0487f9 commit 98e0c1e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/kdump/kdump.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@ const initStore = function(rootElement) {
const promise = desiredState ? dataStore.kdumpClient.ensureOn() : dataStore.kdumpClient.ensureOff();
dataStore.stateChanging = true;
dataStore.render();
promise.finally(function() {
dataStore.stateChanging = false;
dataStore.render();
});
promise
.catch(error => console.warn("Failed to change kdump state:", error))
.finally(() => {
dataStore.stateChanging = false;
dataStore.render();
});
}
const render = function() {
root.render(<WithDialogs>{React.createElement(KdumpPage, {
Expand Down
26 changes: 26 additions & 0 deletions test/verify/check-kdump
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,32 @@ class TestKdump(KdumpHelpers):
b.wait_not_present(".automation-script-modal")
m.execute("diff /etc/kdump.conf /etc/kdump.conf.orig", stdout=None)

# service errors

m.execute("systemctl disable --now kdump.service")
self.assertActive(active=False)
b.wait_not_present(".pf-v5-c-alert__title")

# service is absent (not installed)
m.execute("mv /usr/lib/systemd/system/kdump.service /usr/lib/systemd/system/kdump.service.disabled")
m.execute("systemctl daemon-reload")
b.wait_in_text(".pf-v5-c-alert__title", "Kdump service is not installed")

# put it back, but cause error on startup
m.execute("mv /usr/lib/systemd/system/kdump.service.disabled /usr/lib/systemd/system/kdump.service")
m.write("/etc/systemd/system/kdump.service.d/break.conf",
"[Service]\nExecStart=\nExecStart=/bin/false\n")
m.execute("systemctl daemon-reload")
b.wait_not_present(".pf-v5-c-alert__title")
b.click(".pf-v5-c-switch__input")
b.wait_in_text(".pf-v5-c-alert__title", "Service has an error")
self.assertActive(active=False)
# "more details" leads to services page
b.click(".pf-v5-c-alert__title button")
b.switch_to_top()
b.wait_js_cond('window.location.pathname === "/system/services"')
b.wait_js_cond('window.location.hash === "#/kdump.service"')

@testlib.nondestructive
def testConfiguration(self):
b = self.browser
Expand Down

0 comments on commit 98e0c1e

Please sign in to comment.