Conversation
Introduces a new method GetSoftwareCategoryNameToIDMap to retrieve a mapping of software category names to their IDs, allowing for partial category matches when adding maintained apps. Updates service, tests, and mocks to use the new method, improving compatibility with older Fleet versions where some categories may not exist.
Changed AppCleaner category from 'Productivity' to 'Utilities' and NordVPN from 'Productivity' to 'Security' in both input and output JSON files.
|
For testing, set |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #38303 +/- ##
==========================================
+ Coverage 66.19% 66.28% +0.08%
==========================================
Files 2424 2448 +24
Lines 194202 196859 +2657
Branches 8457 8439 -18
==========================================
+ Hits 128549 130482 +1933
- Misses 53967 54514 +547
- Partials 11686 11863 +177
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Here is what I tested:
These changes should help going forward if categories change but will not help any customer not running a latest version of Fleet. Another way to prevent this going forward would be an FE to set the Category before the user clicks Add, but that would also only help from that merge forward. I don't think we can do a backwards compatible fix, only a fix that will prevent this from being an issue going forward. |
|
We will want to remove any of the changes made to the |
…older-versions-of-fleet-fail-to-add
Removed unused imports from maintained_apps.go
mna
left a comment
There was a problem hiding this comment.
PR looks good to me, looks like you already removed the stuff you mentioned here #38303 (comment) ?
Just a minor thing to clean up, doesn't change the logic at all.
|
|
||
| var categories []fleet.SoftwareCategory | ||
| if err := sqlx.SelectContext(ctx, ds.reader(ctx), &categories, stmt, args...); err != nil { | ||
| if !errors.Is(err, sql.ErrNoRows) { |
There was a problem hiding this comment.
Nit, but SelectContext never returns sql.ErrNoRows, only sqlx.GetContext does, so you can remove the if condition and always return the error here.
FYI @allenhouchins: We will want to remove any of the changes made to the ee folder in this PR before merging since these files were added for testing
Related issue: Resolves #38254
This pull request updates how Fleet-maintained apps handle default categories, improving compatibility with older Fleet builds that may not recognize newer categories. It introduces a more flexible approach for category assignment, ensuring apps can still be added even if some categories do not exist in the current database.
Category compatibility improvements:
GetSoftwareCategoryNameToIDMapmethod in the datastore to return a mapping of known category names to their IDs, only including those that exist. This is used in both production and test code. [1] [2] [3] [4] [5]App category updates:
appcleanerfrom "Productivity" to "Utilities" in both input and output JSON files. [1] [2]nordvpnfrom "Productivity" to "Security" in both input and output JSON files. [1] [2]Test and codebase adjustments:
GetSoftwareCategoryNameToIDMapmethod instead of the previous category ID list approach. [1] [2]fmt) frommaintained_apps.gofor cleanup.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/oree/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)If paths of existing endpoints are modified without backwards compatibility, checked the frontend/CLI for any necessary changes
Testing
Added/updated automated tests
Where appropriate, automated tests simulate multiple hosts and test for host isolation (updates to one hosts's records do not affect another)
QA'd all new/changed functionality manually
For unreleased bug fixes in a release candidate, one of:
Database migrations
COLLATE utf8mb4_unicode_ci).New Fleet configuration settings
If you didn't check the box above, follow this checklist for GitOps-enabled settings:
fleetctl generate-gitopsfleetd/orbit/Fleet Desktop
runtime.GOOSis used as needed to isolate changes