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

implement status reports for DDM commands #17831

Merged
merged 2 commits into from Mar 26, 2024
Merged

Conversation

roperzh
Copy link
Member

@roperzh roperzh commented Mar 25, 2024

for #17408

Checklist for submitter

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

  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements)
  • Added/updated tests
  • Manual QA for all new/changed functionality

Base automatically changed from 17399-declarations-cron-2 to feat-macos-ddm March 25, 2024 20:32
@roperzh roperzh force-pushed the 17408-status branch 2 times, most recently from a0d50be to 1aa81cf Compare March 25, 2024 20:42
Copy link

codecov bot commented Mar 25, 2024

Codecov Report

Attention: Patch coverage is 74.41860% with 33 lines in your changes are missing coverage. Please review.

❗ No coverage uploaded for pull request base (feat-macos-ddm@44727ac). Click here to learn what that means.

Files Patch % Lines
server/mock/datastore_mock.go 0.00% 10 Missing ⚠️
server/datastore/mysql/apple_mdm.go 86.76% 6 Missing and 3 partials ⚠️
server/service/apple_mdm.go 78.94% 6 Missing and 2 partials ⚠️
pkg/mdm/mdmtest/apple.go 57.14% 2 Missing and 1 partial ⚠️
server/mdm/apple/util.go 50.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@                Coverage Diff                @@
##             feat-macos-ddm   #17831   +/-   ##
=================================================
  Coverage                  ?   65.75%           
=================================================
  Files                     ?     1194           
  Lines                     ?   109280           
  Branches                  ?     2568           
=================================================
  Hits                      ?    71858           
  Misses                    ?    31975           
  Partials                  ?     5447           
Flag Coverage Δ
backend 66.75% <74.41%> (?)

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.

@roperzh roperzh marked this pull request as ready for review March 25, 2024 21:14
@roperzh roperzh requested a review from a team as a code owner March 25, 2024 21:14
Copy link
Member

@mna mna left a comment

Choose a reason for hiding this comment

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

LGTM, I assume the plan is to add mysql unit tests during freeze as for the other PR?

Left some minor comments if time permits, can be safely ignored otherwise.

server/fleet/apple_mdm.go Outdated Show resolved Hide resolved
server/fleet/apple_mdm.go Show resolved Hide resolved
server/mdm/apple/util.go Outdated Show resolved Hide resolved
@@ -2615,7 +2615,13 @@ func (svc *MDMAppleCheckinAndCommandService) CommandAndReportResults(r *mdm.Requ
cmdResult.Status == fleet.MDMAppleStatusCommandFormatError {
return nil, svc.ds.UpdateHostLockWipeStatusFromAppleMDMResult(r.Context, cmdResult.UDID, cmdResult.CommandUUID, requestType, cmdResult.Status == fleet.MDMAppleStatusAcknowledged)
}
case "DeclarativeManagement":
// set "pending-install" profiles to "verifying"
Copy link
Member

Choose a reason for hiding this comment

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

More a question for my own understanding than anything else, this implies that the DeclarativeManagement is always signaling a successful apply of the declarative stuff? I.e. we don't check for any command result like for standard MDM commands, it's necessarily a success and we mark the state as Verifying?

(it might be worth a comment just for future us, if only to explain the difference with the other cases)

Copy link
Member

Choose a reason for hiding this comment

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

Actually it looks like it goes from pending to verifying and then only when a status is received in DeclarativeManagement below it knows if it succeeded/failed. (which I now realize was what the comment explained, but it didn't compute for me for some reason :D )

// considerable time trying to make it work.)
//
// My current guess is that the documentation is implicitly referring
// to asset declarations (which deliver tangible "assets" to the host)
Copy link
Member

Choose a reason for hiding this comment

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

That makes sense to me, fwiw.

@@ -13266,6 +13266,144 @@ func (s *integrationMDMTestSuite) TestAppleDDMReconciliation() {
checkDDMSync(deviceThree)
}

func (s *integrationMDMTestSuite) TestAppleDDMStatusReport() {
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion, as this is probably only gonna grow: let's start a distinct file for DDM integration tests? Could still be in the integrationMDMTestSuite, just this file is already so huge.

Copy link
Member Author

Choose a reason for hiding this comment

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

lol, you're right, that's a great idea. I know Sarah and Dante have PRs that modify this file, I will do this as soon as those land to avoid conflicts.

require.NoError(t, err)
assertHostDeclarations(mdmHost.UUID, []*fleet.MDMAppleHostDeclaration{
{Identifier: "I1", Status: &fleet.MDMDeliveryFailed, OperationType: fleet.MDMOperationTypeInstall},
})
Copy link
Member

Choose a reason for hiding this comment

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

👍 Nice test!

@roperzh roperzh merged commit f0ad942 into feat-macos-ddm Mar 26, 2024
18 checks passed
@roperzh roperzh deleted the 17408-status branch March 26, 2024 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants