Update run script modal#31604
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
| jest.mock("../RunScriptBatchPaginatedList", () => { | ||
| return { | ||
| __esModule: true, | ||
| default: ({ onRunScript }: { onRunScript: (script: IScript) => void }) => { | ||
| return ( | ||
| <div> | ||
| <div onClick={() => onRunScript(windowsScript)}>windows script</div> | ||
| <div onClick={() => onRunScript(linuxScript)}>linux script</div> | ||
| </div> | ||
| ); | ||
| }, | ||
| }; | ||
| }); |
There was a problem hiding this comment.
We're not testing the paginated list component here, so mock it to just provide a list of two scripts that we can click.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 28390-frontend-feature #31604 +/- ##
==========================================================
+ Coverage 63.69% 63.72% +0.02%
==========================================================
Files 1960 1962 +2
Lines 191074 191214 +140
Branches 6249 6203 -46
==========================================================
+ Hits 121714 121846 +132
- Misses 59818 59826 +8
Partials 9542 9542
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| isValid: ( | ||
| formData: IRunScriptBatchModalScheduleFormData, | ||
| validations?: IRunScriptBatchModalFormValidation | ||
| ) => { |
There was a problem hiding this comment.
@ghernandez345 I extended your validation framework slightly here to allow isValid to receive the current validation state as a param, so that we can tell if the provided time is in the past (if the date is today).
| } | ||
| : { script_id: script.id, host_ids: selectedHostIds }; | ||
|
|
||
| // Create the base request. |
|
@jacobshandling addressed your comments, thanks for the thorough review! |
for #31555 # Details This PR adds a new cron schedule "batch_activity_completion_checker" that runs every 5 minutes and checks whether any batch activities marked as "started" have completed their runs. In general this is done by determining whether the sum of the "ran", "incompatible", "errored" and "canceled" hosts equals the number of "targeted" hosts for the activity. How that is computed will vary by batch activity type (currently we just have batch scripts). When an activity is marked as finished, we cache the final tally of host statuses (ran, incompatible, errored, canceled) on the record. This is important so that future queries on activity records don't have to do the expensive query to compute the host counts on activities where those counts will never change. # Checklist for submitter If some of the following don't apply, delete the relevant line. - [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 - [X] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [X] QA'd all new/changed functionality manually Started a new batch script run using the update run modal (see #31604) and then triggered the new job using `fleetctl trigger --name batch_activity_completion_checker`, and verified that the `batch_activities` record status was `finished` and the expected fields were populated. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Introduced an automated process that regularly marks completed batch activities, ensuring more accurate and up-to-date activity statuses. * **Bug Fixes** * Improved reliability in updating the status of batch activities when all targeted hosts have finished their tasks. * **Tests** * Added comprehensive tests to verify correct marking of completed batch activities. * **Chores** * Enhanced internal scheduling and datastore interfaces to support the new completion-checking process. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
# Details This PR merges the feature branch for the scheduled scripts UI into main. This includes the following previously-approved PRs: * #31750 * #31604 * #31797 # 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. ## Testing - [X] Added/updated automated tests - [X] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [X] QA'd all new/changed functionality manually --------- Co-authored-by: jacobshandling <61553566+jacobshandling@users.noreply.github.com> Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
# Details This PR merges the feature branch for the scheduled scripts UI into main. This includes the following previously-approved PRs: * #31750 * #31604 * #31797 # 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. ## Testing - [X] Added/updated automated tests - [X] Where appropriate, [automated tests simulate multiple hosts and test for host isolation](https://github.com/fleetdm/fleet/blob/main/docs/Contributing/reference/patterns-backend.md#unit-testing) (updates to one hosts's records do not affect another) - [X] QA'd all new/changed functionality manually --------- Co-authored-by: jacobshandling <61553566+jacobshandling@users.noreply.github.com> Co-authored-by: Jacob Shandling <jacob@fleetdm.com>
for #30526
Details
This PR updates the "Run batch script" modal to allow for scheduling scripts in the future. When a script is selected from the list, rather than running immediately, it now presents a choice of "Run now" and "Schedule for later". If the user opts to schedule for later, they are presented with a form for choosing the date and time to run the script.
Run now example:
run.single.now.mov
Schedule for later example:
run.mult.schedule.mov
Checklist for submitter
Testing