Skip to content

various profile fixes#11084

Merged
roperzh merged 11 commits intomainfrom
various-profile-fixes
Apr 9, 2023
Merged

various profile fixes#11084
roperzh merged 11 commits intomainfrom
various-profile-fixes

Conversation

@roperzh
Copy link
Copy Markdown
Contributor

@roperzh roperzh commented Apr 8, 2023

Related tickets

#10775
#10678
#11024
#11026

What's happening

  • Implemented the hashing mechanism defined by @mna in Edited MDM configuration profiles may fail to properly deploy to the hosts #10678, however this mechanism is mainly relevant for batch profile updates via the CLI, we can't leverage it when a host switches teams.
  • Modified BulkSetPendingMDMAppleHostProfiles so when two profiles with the same identifier are sheduled both for removal and update, the function will now mark only the install as pending so it's picked by the cron, and will DELETE the remove entry from the database so it's not picked by the cron and never sent to the user.
  • GetHostMDMProfiles and consequently the profiles returned in GET /api/_version_/fleet/hosts return host_mdm_apple_profiles.state = NULL as "Enforcing (pending", the distinction between status = 'pending' and status IS NULL is only useful for the cron, for users both mean the same thing, and all our profile aggregations already behave this way.
  • Using the solution implemented by @gillespi314 in Reconcile MDM profiles by updating installed profiles in place #10998 we're now deleting the host row from host_disk_encryption_keys if a host is moved from a team that enforces disk encryption to a team that doesn't.

Checklist for submitter

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

  • Added/updated tests
  • Manual QA for all new/changed functionality

@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 18:02 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 18:42 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 18:42 — with GitHub Actions Inactive
Comment thread server/datastore/mysql/apple_mdm.go Outdated
@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 20:25 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 20:25 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 22:24 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 22:24 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 22:45 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 22:45 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 23:01 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 23:01 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 23:40 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 8, 2023 23:51 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 9, 2023 00:03 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 9, 2023 00:03 — with GitHub Actions Inactive
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 9, 2023

Codecov Report

Patch coverage: 74.16% and project coverage change: -0.05 ⚠️

Comparison is base (da15fc8) 60.14% compared to head (6b1ddef) 60.10%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11084      +/-   ##
==========================================
- Coverage   60.14%   60.10%   -0.05%     
==========================================
  Files         527      528       +1     
  Lines       55103    55263     +160     
==========================================
+ Hits        33143    33217      +74     
- Misses      18943    19021      +78     
- Partials     3017     3025       +8     
Impacted Files Coverage Δ
ee/server/service/teams.go 0.00% <0.00%> (ø)
server/datastore/mysql/hosts.go 83.30% <0.00%> (+0.07%) ⬆️
server/fleet/apple_mdm.go 40.38% <ø> (ø)
server/fleet/datastore.go 0.00% <ø> (ø)
server/datastore/mysql/apple_mdm.go 72.15% <78.94%> (-0.59%) ⬇️
...ons/tables/20230408084104_AddChecksumToProfiles.go 81.81% <81.81%> (ø)
server/service/apple_mdm.go 58.11% <100.00%> (+0.17%) ⬆️

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@roperzh roperzh marked this pull request as ready for review April 9, 2023 00:51
@roperzh roperzh requested a review from a team as a code owner April 9, 2023 00:51
@roperzh roperzh requested a review from gillespi314 April 9, 2023 01:31
gillespi314
gillespi314 previously approved these changes Apr 9, 2023
Copy link
Copy Markdown
Contributor

@gillespi314 gillespi314 left a comment

Choose a reason for hiding this comment

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

Looks good! I had one question on the team delete scenario.

Comment thread ee/server/service/teams.go
@roperzh roperzh temporarily deployed to Docker Hub April 9, 2023 02:03 — with GitHub Actions Inactive
@roperzh roperzh temporarily deployed to Docker Hub April 9, 2023 02:03 — with GitHub Actions Inactive
@roperzh roperzh requested a review from gillespi314 April 9, 2023 02:06
@roperzh roperzh merged commit a59b8a5 into main Apr 9, 2023
@roperzh roperzh deleted the various-profile-fixes branch April 9, 2023 02:23
jacobshandling pushed a commit to jacobshandling/fleet that referenced this pull request Apr 15, 2023
### Related tickets

fleetdm#10775
fleetdm#10678
fleetdm#11024
fleetdm#11026

### What's happening

- Implemented the hashing mechanism defined by @mna in fleetdm#10678, however
this mechanism is mainly relevant for batch profile updates via the CLI,
we can't leverage it when a host switches teams.
- Modified `BulkSetPendingMDMAppleHostProfiles` so when two profiles
with the same identifier are sheduled both for removal and update, the
function will now mark only the `install` as `pending` so it's picked by
the cron, and will `DELETE` the `remove` entry from the database so it's
not picked by the cron and never sent to the user.
- `GetHostMDMProfiles` and consequently the profiles returned in `GET
/api/_version_/fleet/hosts` return `host_mdm_apple_profiles.state =
NULL` as "Enforcing (pending", the distinction between `status =
'pending'` and `status IS NULL` is only useful for the cron, for users
both mean the same thing, and all our profile aggregations already
behave this way.
- Using the solution implemented by @gillespi314 in
fleetdm#10998 we're now deleting the host
row from `host_disk_encryption_keys` if a host is moved from a team that
enforces disk encryption to a team that doesn't.


# Checklist for submitter

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

- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
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.

2 participants