Skip to content

Verify VPP: core implementation#30295

Merged
jahzielv merged 31 commits intomainfrom
29830-verify-vpp-db-migration
Jun 26, 2025
Merged

Verify VPP: core implementation#30295
jahzielv merged 31 commits intomainfrom
29830-verify-vpp-db-migration

Conversation

@jahzielv
Copy link
Copy Markdown
Contributor

@jahzielv jahzielv commented Jun 24, 2025

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.
  • Input data is properly validated, SELECT * is avoided, SQL injection is prevented (using placeholders for values in statements)
  • For database migrations:
    • Ensured the correct collation is explicitly set for character columns (COLLATE utf8mb4_unicode_ci).
  • Added/updated automated tests
  • Manual QA for all new/changed functionality

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 24, 2025

Codecov Report

Attention: Patch coverage is 49.85163% with 169 lines in your changes missing coverage. Please review.

Project coverage is 64.20%. Comparing base (e86e096) to head (1fa4ff1).
Report is 25 commits behind head on main.

Files with missing lines Patch % Lines
server/service/apple_mdm.go 46.82% 48 Missing and 19 partials ⚠️
server/datastore/mysql/vpp.go 45.20% 36 Missing and 4 partials ⚠️
server/worker/vpp_verification.go 4.76% 40 Missing ⚠️
...tions/tables/20250624140757_VPPAppVerifyInstall.go 69.23% 6 Missing and 2 partials ⚠️
cmd/fleet/cron.go 0.00% 6 Missing ⚠️
server/datastore/mysql/activities.go 88.88% 2 Missing and 1 partial ⚠️
server/datastore/mysql/mdm.go 82.35% 2 Missing and 1 partial ⚠️
cmd/fleet/serve.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #30295      +/-   ##
==========================================
+ Coverage   62.31%   64.20%   +1.88%     
==========================================
  Files        1837     1871      +34     
  Lines      174894   183178    +8284     
  Branches     5315     5315              
==========================================
+ Hits       108980   117603    +8623     
+ Misses      57399    56337    -1062     
- Partials     8515     9238     +723     
Flag Coverage Δ
backend 65.08% <49.85%> (+2.04%) ⬆️

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.

nvq.active = 1
AND nvq.id = ?
AND nvq.request_type = ?
AND status != 'Acknowledged'`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm still a bit confused, the name of the function is GetAcknowledgedMDMCommandsByHost but it returned commands that are not acknowledged?

Do you want to instead get the commands where status is failed (i.e. fleet.MDMAppleStatusError, fleet.MDMAppleStatusCommandFormatError)?

Comment thread server/datastore/mysql/software.go Outdated
gillespi314
gillespi314 previously approved these changes Jun 26, 2025

activateNext := vppAct.Status != string(fleet.SoftwareInstalled)
if vppPtrAct != nil {
activateNext = vppPtrAct.Status != string(fleet.SoftwareInstalled)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Double-checking, we want to block all other upcoming activities until we are able to verify the InstalledApplications list?

Comment thread server/datastore/mysql/vpp.go
Comment thread server/fleet/software.go
Comment thread server/fleet/vpp.go
InstallCommandUUID string `db:"command_uuid"`
InstallCommandAckAt *time.Time `db:"ack_at"`
HostID uint `db:"host_id"`
InstallCommandStatus string `db:"install_command_status"`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there an enum for this?

Comment thread server/service/apple_mdm.go
// Check if this is a result of a "refetch" command sent to iPhones/iPads
// to fetch their device information periodically.
if strings.HasPrefix(cmdResult.CommandUUID, fleet.RefetchBaseCommandUUIDPrefix) {
if strings.HasPrefix(cmdResult.CommandUUID, fleet.RefetchBaseCommandUUIDPrefix) && !strings.HasPrefix(cmdResult.CommandUUID, fleet.RefetchVPPAppInstallsCommandUUIDPrefix) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is there a reason to lump the verify prefix in with the refetch base? Do you currently need to match by prefix for verification (or are you more concerned about future needs)?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@gillespi314 I was more just trying to follow the patterns; I went back and forth about making a dedicated prefix without the refetch base. Chose the refetch base because it's technically refetching, but open to making it its own thing!

commander *apple_mdm.MDMAppleCommander,
logger kitlog.Logger,
verifyTimeout, verifyRequestDelay time.Duration,
) func(ctx context.Context, commandResults fleet.MDMCommandResults) error {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we have a definition for the return type (e.g., MDMCommandResultsFunc)?

Comment thread server/fleet/mdm.go
RefetchDeviceCommandUUIDPrefix = RefetchBaseCommandUUIDPrefix + "DEVICE-"
RefetchAppsCommandUUIDPrefix = RefetchBaseCommandUUIDPrefix + "APPS-"
RefetchCertsCommandUUIDPrefix = RefetchBaseCommandUUIDPrefix + "CERTS-"
RefetchVPPAppInstallsCommandUUIDPrefix = RefetchBaseCommandUUIDPrefix + "VPP-INSTALLS-"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we could use a different prefix for verify commands (e.g., "VERIFY-" rather than "REFETCH-")

return nil, nil
}

type InstalledApplicationListResult interface {
Copy link
Copy Markdown
Contributor

@gillespi314 gillespi314 Jun 26, 2025

Choose a reason for hiding this comment

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

Would it make sense for these types to be in the fleet package? Or perhaps we could be consolidate things under server/mdm/apple in a separate file (e.g., vpp_verifier similar to profile_verifier)?

"github.com/google/uuid"
)

const VPPVerificationJobName = "vpp_verification"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: Maybe the job is apple_software and the task is verify_vpp_installs since the worker/job is concerned primarily with sending the list applications command?

@gillespi314
Copy link
Copy Markdown
Contributor

Feel free to address my comments as you see fit in your follow up PRs

@jahzielv jahzielv merged commit 0c4af0b into main Jun 26, 2025
44 checks passed
@jahzielv jahzielv deleted the 29830-verify-vpp-db-migration branch June 26, 2025 21:55
jahzielv added a commit that referenced this pull request Jul 1, 2025
> Fixes #29851
> Fixes #29902
> Mainly followups from #30295,
plus improved integration testing

# Checklist for submitter

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

<!-- Note that API documentation changes are now addressed by the
product design team. -->

- [x] Input data is properly validated, `SELECT *` is avoided, SQL
injection is prevented (using placeholders for values in statements)
- [x] Added/updated automated 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.

4 participants