mirror of
https://github.com/fleetdm/fleet
synced 2026-04-21 21:47:20 +00:00
<!-- Add the related story/sub-task/bug number, like Resolves #123, or remove if NA --> **Related issue:** Resolves #33173 **Related issue:** Resolves #33111 # Details This is the remaining work to implement the "Stop the setup experience when required software fails to install" feature. This didn't turn out to be quite as straightforward as expected so I ended up doing a bit of design-by-code and expect some feedback on the approach. I tried to make it as low-touch as possible. The general design is: 1. In the `maybeUpdateSetupExperienceStatus` function which is called in various places when a setup experience step is marked as completed, call a new `maybeCancelPendingSetupExperienceSteps` function if the setup step was marked as failed. Similarly call `maybeCancelPendingSetupExperienceSteps` if a VPP app install fails to enqueue. 2. In `maybeCancelPendingSetupExperienceSteps`, check whether the specified host is MacOS and whether the "RequireAllSoftwareMacOS" flag is set in the team (or global) config. If so, mark the remaining setup experience items as canceled and cancel any upcoming activities related to those steps. 3. On the front-end, if the `require_all_software_macos` is set and a software step is marked as failed, show a new failure page indicating that setup has failed and showing details of the failed software. 4. On the agent side, when checking setup experience status, send a `reset_after_failure` flag _only the first time_. If this flag is set, then the code in the `/orbit/setup_experience/status` handler will clear and re-queue any failed setup experience steps (but leave successful steps to avoid re-installing already-installed software). This facilitates re-starting the setup experience when the host is rebooted. I also updated the way that software (packages and VPP) is queued up for the setup experience to be ordered alphabetically, to make it easier to test _and_ because this is a desired outcome for a future story. Since the order is not deterministic now, this update shouldn't cause any problems (aside from a couple of test updates), but I'm ok taking it out if desired. # Checklist for submitter If some of the following don't apply, delete the relevant line. - [X] Changes file added for user-visible changes in `changes/`, `orbit/changes/` or `ee/fleetd-chrome/changes`. See [Changes files](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/guides/committing-changes.md#changes-files) for more information. - [X] Input data is properly validated, `SELECT *` is avoided, SQL injection is prevented (using placeholders for values in statements) ## Testing - [X] Added/updated automated tests * Added a new integration test for software packages, testing that a failed software package causes the rest of the setup experience to be marked as failed when `require_all_software_macos` is set, and testing that the "reset after failure" code works. * Added a new integration test for VPP packages, testing that a failed VPP enqueue causes the same halting of the setup experience. I _don't_ have test for a failure _during_ a VPP install. It should go through the same code path as the software package failure, so it's not a huge gap. - [ ] QA'd all new/changed functionality manually Working on it ## fleetd/orbit/Fleet Desktop - [X] Verified compatibility with the latest released version of Fleet (see [Must rule](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/workflows/fleetd-development-and-release-strategy.md)) - [X] If the change applies to only one platform, confirmed that `runtime.GOOS` is used as needed to isolate changes - [X] Verified that fleetd runs on macOS, Linux and Windows <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - New Features - Configurable option to halt macOS device setup if any software install fails. - Device setup page now shows a clear “Device setup failed” state with expandable error details when all software is required on macOS. - Improvements - Setup status now includes per-step error messages for better troubleshooting. - Pending setup steps are automatically canceled after a failure when applicable, with support to reset and retry the setup flow as configured. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Ian Littman <iansltx@gmail.com>
93 lines
2.5 KiB
TypeScript
93 lines
2.5 KiB
TypeScript
import { IDeviceUser } from "interfaces/host";
|
|
import { IDeviceSoftware } from "interfaces/software";
|
|
import { ISetupStep } from "interfaces/setup";
|
|
import {
|
|
IGetDeviceSoftwareResponse,
|
|
IGetSetupExperienceStatusesResponse,
|
|
} from "services/entities/device_user";
|
|
import { createMockHostSoftwarePackage } from "./hostMock";
|
|
|
|
const DEFAULT_DEVICE_USER_MOCK: IDeviceUser = {
|
|
email: "test@test.com",
|
|
source: "test_source",
|
|
};
|
|
|
|
const createMockDeviceUser = (
|
|
overrides?: Partial<IDeviceUser>
|
|
): IDeviceUser => {
|
|
return { ...DEFAULT_DEVICE_USER_MOCK, ...overrides };
|
|
};
|
|
|
|
const DEFAULT_DEVICE_SOFTWARE_MOCK: IDeviceSoftware = {
|
|
id: 1,
|
|
name: "mock software 1.app",
|
|
icon_url: null,
|
|
source: "apps",
|
|
bundle_identifier: "com.app.mock",
|
|
status: null,
|
|
installed_versions: null,
|
|
software_package: createMockHostSoftwarePackage(),
|
|
app_store_app: null,
|
|
};
|
|
|
|
export const createMockDeviceSoftware = (
|
|
overrides?: Partial<IDeviceSoftware>
|
|
) => {
|
|
return { ...DEFAULT_DEVICE_SOFTWARE_MOCK, ...overrides };
|
|
};
|
|
|
|
const DEFAULT_DEVICE_SOFTWARE_RESPONSE_MOCK = {
|
|
software: [createMockDeviceSoftware()],
|
|
count: 0,
|
|
meta: {
|
|
has_next_results: false,
|
|
has_previous_results: false,
|
|
},
|
|
};
|
|
|
|
export const createMockDeviceSoftwareResponse = (
|
|
overrides?: Partial<IGetDeviceSoftwareResponse>
|
|
) => {
|
|
return {
|
|
...DEFAULT_DEVICE_SOFTWARE_RESPONSE_MOCK,
|
|
...overrides,
|
|
};
|
|
};
|
|
|
|
const DEFAULT_SETUP_STEP_STATUS_MOCK: ISetupStep = {
|
|
name: "Slack",
|
|
status: "pending",
|
|
type: "software_install",
|
|
};
|
|
|
|
export const createMockSetupStepStatus = (
|
|
overrides?: Partial<ISetupStep>
|
|
): ISetupStep => {
|
|
return { ...DEFAULT_SETUP_STEP_STATUS_MOCK, ...overrides };
|
|
};
|
|
|
|
const DEFAULT_SETUP_SOFTWARE_STATUSES_RESPONSE_MOCK: IGetSetupExperienceStatusesResponse = {
|
|
setup_experience_results: {
|
|
software: [
|
|
createMockSetupStepStatus({ name: "1Password", status: "pending" }),
|
|
createMockSetupStepStatus({ name: "Chrome", status: "failure" }),
|
|
createMockSetupStepStatus({ name: "Firefox", status: "cancelled" }),
|
|
createMockSetupStepStatus({ name: "Slack", status: "success" }),
|
|
createMockSetupStepStatus({ name: "Zoom", status: "running" }),
|
|
],
|
|
scripts: [
|
|
createMockSetupStepStatus({ name: "test.sh", status: "running" }),
|
|
],
|
|
},
|
|
};
|
|
|
|
export const createMockSetupSoftwareStatusesResponse = (
|
|
overrides?: Partial<IGetSetupExperienceStatusesResponse>
|
|
): IGetSetupExperienceStatusesResponse => {
|
|
return {
|
|
...DEFAULT_SETUP_SOFTWARE_STATUSES_RESPONSE_MOCK,
|
|
...overrides,
|
|
};
|
|
};
|
|
|
|
export default createMockDeviceUser;
|