Skip to content

Commit

Permalink
Watchdog: Use 'reset' as default when no device is attached
Browse files Browse the repository at this point in the history
  • Loading branch information
skobyda committed Oct 13, 2023
1 parent e2b3f52 commit a2db514
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/components/vm/overview/watchdog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import { WATCHDOG_INFO_MESSAGE } from './helpers.jsx';

const _ = cockpit.gettext;

const SUPPORTEDACTIONS = ["reset", "poweroff", "inject-nmi", "pause"];

const WatchdogModalAlert = ({ dialogError }) => {
const [isExpanded, setIsExpanded] = useState(false);

Expand Down Expand Up @@ -68,7 +70,7 @@ const WatchdogModalAlert = ({ dialogError }) => {

export const WatchdogModal = ({ vm, isWatchdogAttached, idPrefix }) => {
const [dialogError, setDialogError] = useState();
const [watchdogAction, setWatchdogAction] = useState(vm.watchdog.action || "no-device");
const [watchdogAction, setWatchdogAction] = useState(vm.watchdog.action || SUPPORTEDACTIONS[0]); // use first option as default
const [inProgress, setInProgress] = useState(false);
const [offerColdplug, setOfferColdplug] = useState(false);

Expand Down Expand Up @@ -134,8 +136,6 @@ export const WatchdogModal = ({ vm, isWatchdogAttached, idPrefix }) => {
.finally(() => setInProgress(false));
};

const supportedActions = ["reset", "poweroff", "inject-nmi", "pause"];

const needsShutdown = () => {
if (vm.state === 'running' && isWatchdogAttached && vm.watchdog.action !== watchdogAction)
return <NeedsShutdownAlert idPrefix={idPrefix} />;
Expand Down Expand Up @@ -203,7 +203,7 @@ export const WatchdogModal = ({ vm, isWatchdogAttached, idPrefix }) => {
fieldId="watchdog-action"
hasNoPaddingTop
isStack>
{supportedActions.map(action => (
{SUPPORTEDACTIONS.map(action => (
<Radio label={rephraseUI("watchdogAction", action)}
key={action}
id={action}
Expand Down
5 changes: 1 addition & 4 deletions test/check-machines-settings
Original file line number Diff line number Diff line change
Expand Up @@ -629,13 +629,10 @@ class TestMachinesSettings(VirtualMachinesCase):

openWatchDogDialog()
# Check no default watchdog device is selected
self.assertFalse(b.get_checked("#reset"))
self.assertTrue(b.get_checked("#reset")) # Reset is pre-selected as default when no watchdog is attached
self.assertFalse(b.get_checked("#poweroff"))
self.assertFalse(b.get_checked("#inject-nmi"))
self.assertFalse(b.get_checked("#pause"))
# Click "Add" without selecting action
b.click("#watchdog-dialog-apply")
b.wait_in_text("#vm-subVmTest1-watchdog-modal .pf-m-danger", "unsupported configuration")
closeWatchDogDialog("#vm-subVmTest1-watchdog-modal button[aria-label=Close]")

# Test configuring watchdog for shutoff VM
Expand Down

0 comments on commit a2db514

Please sign in to comment.