Skip to content

Remove duplicate RHEL kernel in os_version#39746

Merged
mostlikelee merged 6 commits intomainfrom
39737-double-kernel
Feb 12, 2026
Merged

Remove duplicate RHEL kernel in os_version#39746
mostlikelee merged 6 commits intomainfrom
39737-double-kernel

Conversation

@mostlikelee
Copy link
Contributor

@mostlikelee mostlikelee commented Feb 12, 2026

Related issue: Resolves #39737

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)

Testing

  • Added/updated automated tests

  • QA'd all new/changed functionality manually

Database migrations

  • Checked schema for all modified table for columns that will auto-update timestamps during migration.

Summary by CodeRabbit

Bug Fixes

  • Fixed reporting of duplicate kernel entries for RHEL-family distributions (RHEL, AlmaLinux, CentOS, Rocky, Fedora) in the OS versions API, improving data accuracy and consistency for kernel version information.

Tests

  • Updated test cases to validate kernel data normalization across different package sources.

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

❌ Patch coverage is 63.15789% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.25%. Comparing base (fb37ede) to head (303b10b).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
.../tables/20260211200153_UnmarkKernelCoreAsKernel.go 66.66% 4 Missing and 2 partials ⚠️
server/service/osquery_utils/queries.go 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #39746      +/-   ##
==========================================
- Coverage   66.25%   66.25%   -0.01%     
==========================================
  Files        2438     2439       +1     
  Lines      195270   195288      +18     
  Branches     8605     8605              
==========================================
+ Hits       129384   129392       +8     
- Misses      54171    54177       +6     
- Partials    11715    11719       +4     
Flag Coverage Δ
backend 68.05% <63.15%> (-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.

🚀 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.

@mostlikelee
Copy link
Contributor Author

@coderabbitai full review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

✅ Actions performed

Full review triggered.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 12, 2026

Walkthrough

This pull request fixes duplicate kernel reporting for RHEL-family distributions by adding a database migration that unmarks the kernel-core RPM package as a kernel, consolidating kernel identification to use only the "kernel" package name. The migration updates the software_titles table to set is_kernel = 0 for kernel-core entries and deletes corresponding kernel_host_counts rows. The kernel detection logic in osquery utilities is updated to use a single rpmKernelName constant instead of separate legacy constants. Supporting test files and schema references are updated accordingly.

Possibly related PRs

  • 31214 linux vulns optimization #31722: Changes kernel identification and mapping at the datastore level, directly affected by this PR's migration that updates software_titles.is_kernel for RPM kernel packages.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: removing duplicate RHEL kernel entries from the OS version API by eliminating kernel-core as a kernel designation.
Description check ✅ Passed The PR description follows the template and includes all critical sections: linked issue reference, relevant checklist items completed (changes file, input validation, automated tests, QA), and migration checks acknowledged.
Linked Issues check ✅ Passed Code changes comprehensively address issue #39737: migration unmarking kernel-core as kernel [20260211200153], queries updated to use rpmKernelName instead of kernel-core [queries.go], and tests updated reflecting the change [operating_system_vulnerabilities_test.go, integration_enterprise_vulns_test.go].
Out of Scope Changes check ✅ Passed All changes are directly related to resolving #39737: removing kernel-core from kernel detection and unmarking it in the database. No extraneous modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 39737-double-kernel

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Fix all issues with AI agents
In
`@server/datastore/mysql/migrations/tables/20260211200153_UnmarkKernelCoreAsKernel_test.go`:
- Line 90: The assertion message for the require.Equal call is wrong: it asserts
require.Equal(t, 1, finalCount, ...) but the message says "Should have 2 ...".
Update the message on the require.Equal that checks finalCount in
UnmarkKernelCoreAsKernel_test.go (the require.Equal invocation) to reflect 1
(e.g., "Should have 1 kernel_host_counts entry after migration (one deleted)")
so the expectation and message match.
- Line 43: The assertion message in the test referencing require.Equal(t, 2,
initialCount, ...) is wrong — it says "Should have 3 kernel_host_counts entries
before migration" while the expected count is 2; update the message text in the
require.Equal call (the one that checks initialCount) to correctly state "Should
have 2 kernel_host_counts entries before migration" so the failure message
matches the expected value and the inserted rows.

var initialCount int
err = db.Get(&initialCount, `SELECT COUNT(*) FROM kernel_host_counts`)
require.NoError(t, err)
require.Equal(t, 2, initialCount, "Should have 3 kernel_host_counts entries before migration")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Assertion message is incorrect — says "3" but should say "2".

Only two kernel_host_counts rows are inserted, and the assertion correctly checks for 2, but the message string says "Should have 3". This will produce a confusing failure message if the assertion ever fails.

Proposed fix
-	require.Equal(t, 2, initialCount, "Should have 3 kernel_host_counts entries before migration")
+	require.Equal(t, 2, initialCount, "Should have 2 kernel_host_counts entries before migration")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
require.Equal(t, 2, initialCount, "Should have 3 kernel_host_counts entries before migration")
require.Equal(t, 2, initialCount, "Should have 2 kernel_host_counts entries before migration")
🤖 Prompt for AI Agents
In
`@server/datastore/mysql/migrations/tables/20260211200153_UnmarkKernelCoreAsKernel_test.go`
at line 43, The assertion message in the test referencing require.Equal(t, 2,
initialCount, ...) is wrong — it says "Should have 3 kernel_host_counts entries
before migration" while the expected count is 2; update the message text in the
require.Equal call (the one that checks initialCount) to correctly state "Should
have 2 kernel_host_counts entries before migration" so the failure message
matches the expected value and the inserted rows.

var finalCount int
err := db.Get(&finalCount, `SELECT COUNT(*) FROM kernel_host_counts`)
require.NoError(t, err)
require.Equal(t, 1, finalCount, "Should have 2 kernel_host_counts entries after migration (one deleted)")
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Assertion message is incorrect — says "2" but should say "1".

Same issue: the assertion checks for 1 (correct), but the message says "Should have 2".

Proposed fix
-	require.Equal(t, 1, finalCount, "Should have 2 kernel_host_counts entries after migration (one deleted)")
+	require.Equal(t, 1, finalCount, "Should have 1 kernel_host_counts entry after migration (one deleted)")
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
require.Equal(t, 1, finalCount, "Should have 2 kernel_host_counts entries after migration (one deleted)")
require.Equal(t, 1, finalCount, "Should have 1 kernel_host_counts entry after migration (one deleted)")
🤖 Prompt for AI Agents
In
`@server/datastore/mysql/migrations/tables/20260211200153_UnmarkKernelCoreAsKernel_test.go`
at line 90, The assertion message for the require.Equal call is wrong: it
asserts require.Equal(t, 1, finalCount, ...) but the message says "Should have 2
...". Update the message on the require.Equal that checks finalCount in
UnmarkKernelCoreAsKernel_test.go (the require.Equal invocation) to reflect 1
(e.g., "Should have 1 kernel_host_counts entry after migration (one deleted)")
so the expectation and message match.

@mostlikelee mostlikelee marked this pull request as ready for review February 12, 2026 14:06
@mostlikelee mostlikelee requested a review from a team as a code owner February 12, 2026 14:06
@mostlikelee mostlikelee merged commit 548a2cc into main Feb 12, 2026
47 checks passed
@mostlikelee mostlikelee deleted the 39737-double-kernel branch February 12, 2026 16:13
@coderabbitai coderabbitai bot mentioned this pull request Feb 12, 2026
4 tasks
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.

RHEL based systems showing duplicate kernels on OS Page

2 participants