Skip to content

Commit

Permalink
kdump: Show message in 'Test configuration' to verify the crash
Browse files Browse the repository at this point in the history
This adds message showing a location where user can verify whetever
crash was successful:
Local filesystem: "To verify whether the crash was successful check
/var/crash location for kernel crash dump(vmcore)."
SSH: "To verify whether the crash was successful check /var/crash
location at [email protected] for kernel crash dump(vmcore)"
NFS: "To verify whether the crash was successful check /var/crash
location at myserver.com:/export/cores for kernel crash dump(vmcore)."

Closes https://issues.redhat.com/browse/RHELPLAN-125375
Closes https://bugzilla.redhat.com/show_bug.cgi?id=2097440
  • Loading branch information
skobyda committed Aug 15, 2023
1 parent f8eee3f commit 55c6ab4
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 7 deletions.
40 changes: 37 additions & 3 deletions pkg/kdump/kdump-view.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ import { DescriptionList, DescriptionListDescription, DescriptionListGroup, Desc
import { Modal } from "@patternfly/react-core/dist/esm/components/Modal/index.js";
import { Spinner } from "@patternfly/react-core/dist/esm/components/Spinner/index.js";
import { Switch } from "@patternfly/react-core/dist/esm/components/Switch/index.js";
import { Text, TextContent, TextVariants } from "@patternfly/react-core/dist/esm/components/Text/index.js";
import { TextInput } from "@patternfly/react-core/dist/esm/components/TextInput/index.js";
import { Title } from "@patternfly/react-core/dist/esm/components/Title/index.js";
import { Tooltip, TooltipPosition } from "@patternfly/react-core/dist/esm/components/Tooltip/index.js";
import { OutlinedQuestionCircleIcon } from "@patternfly/react-icons";

import { useDialogs, DialogsContext } from "dialogs.jsx";
import { fmt_to_fragments } from 'utils.jsx';
import { show_modal_dialog } from "cockpit-components-dialog.jsx";
import { FormHelper } from "cockpit-components-form-helper";
import { ModalError } from 'cockpit-components-inline-notification.jsx';
Expand Down Expand Up @@ -263,12 +265,44 @@ export class KdumpPage extends React.Component {
}

handleTestSettingsClick() {
// if we have multiple targets defined, the config is invalid
const target = this.props.kdumpStatus.target;
let verifyMessage;
if (!target.multipleTargets) {
const path = target.path || "/var/crash";
if (target.type === "local") {
verifyMessage = fmt_to_fragments(
' ' + _("Results of the crash will be stored in $0 as $1, if kdump is properly configured."),
<span className="ct-monospace">{path}</span>,
<span className="ct-monospace">vmcore</span>);
} else if (target.type === "ssh") {
verifyMessage = fmt_to_fragments(
' ' + _("Results of the crash will be stored in $0 as $1, and also copied through SSH to $2, if kdump is properly configured."),
<span className="ct-monospace">{path}</span>,
<span className="ct-monospace">vmcore</span>,
<span className="ct-monospace">{`${target.server}:${path}`}</span>);
} else if (target.type === "nfs") {
verifyMessage = fmt_to_fragments(
' ' + _("Results of the crash will be stored via SSH at $0 as $1, and also copied through NFS at $2, if kdump is properly configured."),
<span className="ct-monospace">{path}</span>,
<span className="ct-monospace">vmcore</span>,
<span className="ct-monospace">{`${target.server}:${target.export}`}</span>);
}
}

// open a dialog to confirm crashing the kernel to test the settings - then do it
const dialogProps = {
title: _("Test kdump settings"),
body: (
<span>{_("Test kdump settings by crashing the kernel. This may take a while and the system might not automatically reboot. Do not purposefully crash the system while any important task is running.")}</span>
)
body: (<TextContent>
<Text component={TextVariants.p}>
{_("Test kdump settings by crashing the kernel. This may take a while and the system might not automatically reboot. Do not purposefully crash the system while any important task is running.")}
</Text>
{verifyMessage && <Text component={TextVariants.p}>
{verifyMessage}
</Text>}
</TextContent>),
showClose: true,
titleIconVariant: "warning",
};
// also test modifying properties in subsequent render calls
const footerProps = {
Expand Down
4 changes: 4 additions & 0 deletions pkg/kdump/kdump.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@
max-block-size: 200px;
overflow-y: auto;
}

.ct-monospace {
font-family: var(--pf-v5-global--FontFamily--monospace);
}
9 changes: 5 additions & 4 deletions test/verify/check-kdump
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ class KdumpHelpers(testlib.MachineCase):
self.browser.switch_to_top()
self.browser.relogin("/kdump")

def crashKernel(self):
def crashKernel(self, message):
b = self.browser
b.click(f"button{self.default_btn_class}")
self.browser.wait_in_text(".pf-v5-c-modal-box__body", message)
# we should get a warning dialog, confirm
b.click(f"button{self.danger_btn_class}")
# wait until we've actually triggered a crash
Expand Down Expand Up @@ -174,7 +175,7 @@ class TestKdump(KdumpHelpers):
assertActive(active=True)

# crash the kernel and make sure it wrote a report into the right directory
self.crashKernel()
self.crashKernel("stored in /var/crash2 as vmcore")
m.execute(f"until test -e {customPath}/127.0.0.1*/vmcore; do sleep 1; done", timeout=180)
self.assertIn("Kdump compressed dump", m.execute(f"file {customPath}/127.0.0.1*/vmcore"))

Expand Down Expand Up @@ -425,7 +426,7 @@ class TestKdumpNFS(KdumpHelpers):
self.assertIn("\nnfs 10.111.113.2:/srv/kdump\n", conf)
self.assertNotIn("\npath", conf)

self.crashKernel()
self.crashKernel("at /var/crash as vmcore, and also copied through NFS at 10.111.113.2:/srv/kdump")

# dump is done during boot, so should exist now
self.assertIn("Kdump compressed dump",
Expand Down Expand Up @@ -454,7 +455,7 @@ class TestKdumpNFS(KdumpHelpers):

b.wait_visible(".pf-v5-c-switch__input:checked")

self.crashKernel()
self.crashKernel("at dumps as vmcore, and also copied through NFS at 10.111.113.2:/srv/kdump")
self.assertIn("Kdump compressed dump",
self.machines["nfs"].execute("file /srv/kdump/dumps/10.111.113.1*/vmcore"))

Expand Down

0 comments on commit 55c6ab4

Please sign in to comment.