From 5f0f63e12a4298a2ecfac9313ebbb188cc0f77b8 Mon Sep 17 00:00:00 2001 From: Nick De Villiers Date: Wed, 9 Oct 2024 10:37:35 +0100 Subject: [PATCH] feat(machines): Add kernel crash dump checkbox to deploy form MAASENG-3759 (#5539) Resolves [MAASENG-3759](https://warthogs.atlassian.net/browse/MAASENG-3759) --- .../DeployFormFields.test.tsx | 53 +++++++++++++++++++ .../DeployFormFields/DeployFormFields.tsx | 37 +++++++++++++ 2 files changed, 90 insertions(+) diff --git a/src/app/machines/components/MachineForms/MachineActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.test.tsx b/src/app/machines/components/MachineForms/MachineActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.test.tsx index a9f223f049..f43268d319 100644 --- a/src/app/machines/components/MachineForms/MachineActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.test.tsx +++ b/src/app/machines/components/MachineForms/MachineActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.test.tsx @@ -1,6 +1,7 @@ import { Provider } from "react-redux"; import { MemoryRouter } from "react-router-dom"; import configureStore from "redux-mock-store"; +import { test } from "vitest"; import DeployForm from "../DeployForm"; @@ -15,6 +16,8 @@ import { renderWithBrowserRouter, } from "@/testing/utils"; +const kernelCrashDumpEnabled = + process.env.VITE_APP_KERNEL_CRASH_DUMP_ENABLED === "true"; const mockStore = configureStore(); describe("DeployFormFields", () => { @@ -708,4 +711,54 @@ describe("DeployFormFields", () => { screen.queryByRole("checkbox", { name: "Register as MAAS KVM host" }) ).not.toBeInTheDocument(); }); + + test.runIf(kernelCrashDumpEnabled)( + "shows a tooltip for minimum OS requirements", + async () => { + renderWithBrowserRouter( + , + { route: "/machines/add", state } + ); + + await userEvent.hover( + screen.getAllByRole("button", { name: "help-mid-dark" })[1] + ); + + await waitFor(() => { + expect(screen.getByRole("tooltip")).toHaveTextContent( + "Ubuntu 24.04 LTS or higher." + ); + }); + } + ); + + test.runIf(kernelCrashDumpEnabled)( + "shows a tooltip for minimum hardware requirements", + async () => { + renderWithBrowserRouter( + , + { route: "/machines/add", state } + ); + + await userEvent.hover( + screen.getAllByRole("button", { name: "help-mid-dark" })[0] + ); + + await waitFor(() => { + expect(screen.getByRole("tooltip")).toHaveTextContent( + ">= 4 CPU threads, >= 6GB RAM, Reserve >5x RAM size as free disk space in /var." + ); + }); + } + ); }); diff --git a/src/app/machines/components/MachineForms/MachineActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.tsx b/src/app/machines/components/MachineForms/MachineActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.tsx index 0d996f5d41..5431349332 100644 --- a/src/app/machines/components/MachineForms/MachineActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.tsx +++ b/src/app/machines/components/MachineForms/MachineActionFormWrapper/DeployForm/DeployFormFields/DeployFormFields.tsx @@ -276,6 +276,43 @@ export const DeployFormFields = (): JSX.Element => { name="enableHwSync" type="checkbox" /> + + {import.meta.env.VITE_APP_KERNEL_CRASH_DUMP_ENABLED === "true" && ( + + To enable kernel crash dump, the hardware{" "} + + {" "} + >= 4 CPU threads,
>= 6GB RAM,
+ Reserve >5x RAM size as free disk space in /var. + + } + />{" "} + and OS{" "} + {" "} + must meet the minimum requirements and secure boot must be + disabled. Check crash dump status in machine details. + + } + label={ + <> + Try to enable kernel crash dump{" "} + + Kernel crash dump docs + + + } + name="kernel_crash_dump" + type="checkbox" + /> + )} {user && user.sshkeys_count === 0 && (