Skip to content

Commit

Permalink
fix: don't fail if host profile not found
Browse files Browse the repository at this point in the history
  • Loading branch information
jahzielv committed Sep 24, 2024
1 parent 2d4121b commit 66b8e18
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions server/datastore/mysql/apple_mdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -3935,6 +3935,10 @@ WHERE

var hostProf fleet.HostMDMAppleProfile
if err := sqlx.GetContext(ctx, ds.writer(ctx), &hostProf, stmt, uuid); err != nil {
if errors.Is(err, sql.ErrNoRows) {
return nil, notFound("HostMDMAppleProfile")
}

return nil, ctxerr.Wrap(ctx, err, "getting host mdm apple profile by uuid")
}

Expand Down
6 changes: 4 additions & 2 deletions server/service/apple_mdm.go
Original file line number Diff line number Diff line change
Expand Up @@ -772,14 +772,16 @@ func (svc *Service) DeleteMDMAppleConfigProfile(ctx context.Context, profileUUID

hp, err := svc.ds.GetHostMDMAppleProfileByUUID(ctx, cp.ProfileUUID)
if err != nil {
return ctxerr.Wrap(ctx, err, "getting host mdm apple profile")
if !fleet.IsNotFound(err) {
return ctxerr.Wrap(ctx, err, "getting host mdm apple profile")
}
}

if err := svc.ds.DeleteMDMAppleConfigProfile(ctx, profileUUID); err != nil {
return ctxerr.Wrap(ctx, err)
}

if hp.Status == nil && hp.OperationType == fleet.MDMOperationTypeInstall && hp.CommandUUID == "" {
if hp != nil && hp.Status == nil && hp.OperationType == fleet.MDMOperationTypeInstall && hp.CommandUUID == "" {
if err := svc.ds.DeleteHostMDMAppleProfileByUUID(ctx, cp.ProfileUUID); err != nil {
return ctxerr.Wrap(ctx, err, "deleting host mdm apple profile")
}
Expand Down

0 comments on commit 66b8e18

Please sign in to comment.