Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add batching logic when we pull windows profiles to install or remove #26964

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jahzielv
Copy link
Contributor

@jahzielv jahzielv commented Mar 7, 2025

For #26918

Checklist for submitter

If some of the following don't apply, delete the relevant line.

  • Changes file added for user-visible changes in changes/, orbit/changes/ or ee/fleetd-chrome/changes.
    See Changes files for more information.
  • Added/updated automated tests
  • A detailed QA plan exists on the associated ticket (if it isn't there, work with the product group's QA engineer to add it)
  • Manual QA for all new/changed functionality

@jahzielv jahzielv marked this pull request as ready for review March 7, 2025 20:53
@jahzielv jahzielv requested a review from a team as a code owner March 7, 2025 20:53
Copy link

codecov bot commented Mar 7, 2025

Codecov Report

Attention: Patch coverage is 73.91304% with 24 lines in your changes missing coverage. Please review.

Project coverage is 61.77%. Comparing base (a0f8d09) to head (ee76f32).
Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
server/datastore/mysql/microsoft_mdm.go 73.91% 16 Missing and 8 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26964      +/-   ##
==========================================
- Coverage   64.02%   61.77%   -2.25%     
==========================================
  Files        1701     1701              
  Lines      162252   162278      +26     
  Branches     4272     4272              
==========================================
- Hits       103874   100250    -3624     
- Misses      50319    54062    +3743     
+ Partials     8059     7966      -93     
Flag Coverage Δ
backend 62.33% <73.91%> (-2.46%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@iansltx iansltx self-assigned this Mar 7, 2025
Copy link
Member

@iansltx iansltx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this'll fix the problem, at the expense of complexity that makes it easier to miss the "zero host IDs in the list" nuance. Refactoring that case out into its own function solves that problem, so I think it's worth doing now. I may go ahead and do this since I'm asking for some nontrivial changes, and since we can have another person put eyes on this afterward.

return err
})

return result, err
}

func listMDMWindowsProfilesToRemoveDB(
func (ds *Datastore) listMDMWindowsProfilesToRemoveDB(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same feedback as for the install case. Feels even more like we should do this refactor given that doing so doesn't require us to modify the datastore interface.

…les to install/remove

The vast majority of the overlap between "all hosts" and "a subset of hosts" for these functions are in the SQL, so if we extract the SQL out we can split the function into one that only operates on a subset of hosts (and optionally a subset of profiles), and one that only operates on all hosts. This reduces the complexity of both functions, which is important given that we just added complexity via batching.

This change winds up with equivalent behavior for both places that call the functions.
@iansltx iansltx assigned mna and unassigned iansltx Mar 9, 2025
@iansltx
Copy link
Member

iansltx commented Mar 9, 2025

@mna Assigning you on this for review as I went from reviewing this to doing a more substantial refactor, and it would be helpful to get MDM eyes on this to make sure I'm not off-base with these changes, as I changed more on this than @jahzielv did.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants