File kdump-nfs-fixes.patch of Package cockpit
From d1ffed4a006bc9f8aeb0e8f63e8d2a160720b4f6 Mon Sep 17 00:00:00 2001
From: Alice Brooks <alice.brooks@suse.com>
Date: Thu, 12 Jun 2025 08:48:16 +0100
Subject: [PATCH] kdump: Remove nfs directory when using sysconfig
configuration style
This is because the sysconfig style only has the KDUMP_SAVEDIR field
so we can't work with two path fields as it's impossible to extract
them again
---
pkg/kdump/kdump-client.js | 4 ++++
pkg/kdump/kdump-view.jsx | 24 +++++++++++++++---------
pkg/kdump/kdump.js | 6 ++++++
4 files changed, 26 insertions(+), 20 deletions(-)
diff --git a/pkg/kdump/kdump-client.js b/pkg/kdump/kdump-client.js
index d4c3d989a42d..35add2554a39 100644
--- a/pkg/kdump/kdump-client.js
+++ b/pkg/kdump/kdump-client.js
@@ -48,6 +48,7 @@ export class KdumpClient {
state: undefined,
config: undefined,
target: undefined,
+ sysconfig: undefined,
};
cockpit.event_target(this);
@@ -62,6 +63,7 @@ export class KdumpClient {
// watch the config file
this.configClient = new ConfigFile("/etc/kdump.conf", true);
+ this.state.sysconfig = false;
this._watchConfigChanges();
this.configClient.wait().then(() => {
@@ -69,6 +71,8 @@ export class KdumpClient {
if (this.configClient.settings === null) {
this.configClient.close();
this.configClient = new ConfigFileSUSE("/etc/sysconfig/kdump", true);
+ this.state.sysconfig = true;
+ this.dispatchEvent("kdumpSysconfigChanged", true);
this._watchConfigChanges();
}
});
diff --git a/pkg/kdump/kdump-view.jsx b/pkg/kdump/kdump-view.jsx
index c6cc1e0d6bc6..8b5d74707e39 100644
--- a/pkg/kdump/kdump-view.jsx
+++ b/pkg/kdump/kdump-view.jsx
@@ -115,12 +115,15 @@ const exportAnsibleTask = (settings, os_release) => {
return ansible;
};
-function getLocation(target) {
+function getLocation(target, sysconfig) {
let path = target.path || DEFAULT_KDUMP_PATH;
if (target.type === "ssh") {
path = `${target.server}:${path}`;
} else if (target.type == "nfs") {
+ if (sysconfig) {
+ path = '';
+ }
path = path[0] !== '/' ? '/' + path : path;
path = `${target.server}:${target.export + path}`;
}
@@ -128,7 +131,7 @@ function getLocation(target) {
return path;
}
-const KdumpSettingsModal = ({ settings, initialTarget, handleSave }) => {
+const KdumpSettingsModal = ({ settings, initialTarget, handleSave, sysconfig }) => {
const Dialogs = useDialogs();
const compressionAllowed = settings.compression?.allowed;
const [isSaving, setIsSaving] = useState(false);
@@ -276,13 +279,15 @@ const KdumpSettingsModal = ({ settings, initialTarget, handleSave }) => {
placeholder="/export/cores" value={exportPath}
onChange={(_event, value) => setExportPath(value)} isRequired />
</FormGroup>
+ {sysconfig === false &&
<FormGroup fieldId="kdump-settings-nfs-directory" label={_("Directory")} isRequired>
<TextInput id="kdump-settings-nfs-directory" key="directory"
- placeholder={DEFAULT_KDUMP_PATH} value={directory}
- data-stored={directory}
- onChange={(_event, value) => setDirectory(value)}
- isRequired />
+ placeholder={DEFAULT_KDUMP_PATH} value={directory}
+ data-stored={directory}
+ onChange={(_event, value) => setDirectory(value)}
+ isRequired />
</FormGroup>
+ }
</>
}
@@ -353,7 +358,7 @@ export class KdumpPage extends React.Component {
const target = this.props.kdumpStatus.target;
let verifyMessage;
if (!target.multipleTargets) {
- const path = getLocation(target);
+ const path = getLocation(target, this.props.sysconfig);
if (target.type === "local") {
verifyMessage = fmt_to_fragments(
' ' + _("Results of the crash will be stored in $0 as $1, if kdump is properly configured."),
@@ -403,7 +408,8 @@ export class KdumpPage extends React.Component {
const Dialogs = this.context;
Dialogs.show(<KdumpSettingsModal settings={this.props.kdumpStatus.config}
initialTarget={this.props.kdumpStatus.target}
- handleSave={this.props.onSaveSettings} />);
+ handleSave={this.props.onSaveSettings}
+ sysconfig={this.props.sysconfig} />);
}
handleAutomationClick() {
@@ -459,7 +465,7 @@ ${enableCrashKernel}
if (target.multipleTargets) {
kdumpLocation = _("invalid: multiple targets defined");
} else {
- const locationPath = getLocation(target);
+ const locationPath = getLocation(target, this.props.sysconfig);
if (target.type == "local") {
kdumpLocation = cockpit.format(_("Local, $0"), locationPath);
targetCanChange = true;
diff --git a/pkg/kdump/kdump.js b/pkg/kdump/kdump.js
index 1a143defef15..b0f75e88c220 100644
--- a/pkg/kdump/kdump.js
+++ b/pkg/kdump/kdump.js
@@ -41,6 +41,7 @@ const initStore = function(rootElement) {
dataStore.domRootElement = rootElement;
dataStore.kdumpClient = new kdumpClient.KdumpClient();
+ dataStore.sysconfig = dataStore.kdumpClient.state.sysconfig;
dataStore.saveSettings = settings =>
dataStore.kdumpClient.validateSettings(settings)
@@ -74,6 +75,7 @@ const initStore = function(rootElement) {
reservedMemory: dataStore.kdumpMemory,
kdumpStatus: dataStore.kdumpStatus,
kdumpCmdlineEnabled: dataStore.crashkernel || false,
+ sysconfig: dataStore.sysconfig,
onSaveSettings: dataStore.saveSettings,
onCrashKernel: dataStore.kdumpClient.crashKernel,
exportConfig: dataStore.exportConfig,
@@ -117,6 +119,10 @@ const initStore = function(rootElement) {
dataStore.kdumpStatus = status;
render();
});
+ dataStore.kdumpClient.addEventListener('kdumpSysconfigChanged', function(event, sysconfig) {
+ dataStore.sysconfig = sysconfig;
+ render();
+ });
// render once
render();