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

Clear bootstrap package and enrollment profile with GitOps #26095

Merged
merged 21 commits into from
Feb 7, 2025

Conversation

getvictor
Copy link
Member

@getvictor getvictor commented Feb 5, 2025

For #25648

Fixed issue where fleetctl gitops was NOT deleting macOS setup experience bootstrap package and enrollment profile. GitOps should clear all settings that are not explicitly set in YAML config files.

Checklist for submitter

  • 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

…th-in-no-team' into victor/25648-gitops-bootstrap

# Conflicts:
#	cmd/fleetctl/gitops.go
Copy link

codecov bot commented Feb 5, 2025

Codecov Report

Attention: Patch coverage is 73.97260% with 38 lines in your changes missing coverage. Please review.

Project coverage is 63.64%. Comparing base (55423f6) to head (4ea7767).
Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
server/service/client.go 55.73% 20 Missing and 7 partials ⚠️
server/service/client_mdm.go 76.19% 4 Missing and 1 partial ⚠️
pkg/spec/gitops.go 92.10% 2 Missing and 1 partial ⚠️
server/fleet/app.go 86.95% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #26095      +/-   ##
==========================================
- Coverage   63.64%   63.64%   -0.01%     
==========================================
  Files        1631     1631              
  Lines      156363   156387      +24     
  Branches     4132     4104      -28     
==========================================
+ Hits        99523    99533      +10     
- Misses      49000    49010      +10     
- Partials     7840     7844       +4     
Flag Coverage Δ
backend 64.48% <73.97%> (+<0.01%) ⬆️

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.

@getvictor getvictor changed the title WIP Clear bootstrap package and enrollment profile with GitOps Feb 6, 2025
@getvictor getvictor marked this pull request as ready for review February 6, 2025 19:43
@getvictor getvictor requested a review from a team as a code owner February 6, 2025 19:43
…ootstrap

# Conflicts:
#	cmd/fleetctl/gitops.go
#	pkg/spec/gitops.go
)
}
controlsFilePath := yamlFilename
err := processControlsPathIfNeeded(controlsTop, result, &controlsFilePath)
Copy link
Member Author

@getvictor getvictor Feb 7, 2025

Choose a reason for hiding this comment

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

Refactoring: extract method, except for resolveScriptPaths

@@ -248,7 +265,7 @@ func (c *Client) validateMacOSSetupAssistant(fileName string) ([]byte, error) {
}

func (c *Client) uploadMacOSSetupAssistant(data []byte, teamID *uint, name string) error {
verb, path := "POST", "/api/latest/fleet/mdm/apple/enrollment_profile"
verb, path := http.MethodPost, "/api/latest/fleet/enrollment_profiles/automatic"
Copy link
Member Author

Choose a reason for hiding this comment

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

Updating to non-deprected path

Copy link
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. It might be helpful to future readers to expand on the comments a little more to clarify the assumptions and business rules going into each case.

return nil, nil, nil, nil, fmt.Errorf("applying fleet config: %w", err)
}
}
case macosSetup.BootstrapPackage.Valid && !opts.DryRun &&
appconfig != nil && appconfig.MDM.EnabledAndConfigured && appconfig.License.IsPremium():
// bootstrap package is explicitly empty (only for GitOps)
Copy link
Contributor

Choose a reason for hiding this comment

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

Just making sure that I'm following flows, are you saying that we know it is explicitly empty because the first case was not triggered? If so, what do you think about expanding the comment to something along the lines below?

// we know bootstrap package is explicitly empty because the first case was not triggered so we process according to the GitOps default rule, which is to delete any prior bootstrap package

Similarly, the other comments in the PR could be expanded. And for the non-GitOps apply flows, the comments can spell out the business rule, which by contrast is to leave any prior value in place.

Copy link
Member Author

Choose a reason for hiding this comment

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

@gillespi314 How about this: https://github.com/fleetdm/fleet/pull/26184/files ?

We need to refactor ApplyGroup into ApplyGroup and ApplyGitOps. apply is effectively deprecated since we are not adding new features to it.

@getvictor getvictor merged commit 2eb5119 into main Feb 7, 2025
37 checks passed
@getvictor getvictor deleted the victor/25648-gitops-bootstrap branch February 7, 2025 20:35
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