Skip to content

Conversation

@romprod
Copy link

@romprod romprod commented Jan 3, 2026

Summary

This PR fixes false positive reboot detection (#379, #390) where systems with virtual kernel meta-packages were incorrectly flagged as needing a reboot.

Problem

Virtual kernel meta-packages like linux-image-virtual and linux-image-generic were being compared directly against the running kernel version, causing mismatches:

  • Installed: virtual (meta-package name)
  • Running: 5.15.0-164-generic (actual kernel)
  • Result: False positive needs_reboot=true

Solution

  1. Enhanced meta-package detection in getLatestKernelFromDpkg()

    • Now recognizes: virtual, generic, lowlatency, cloud, generic-hwe meta-packages
    • Resolves each to the actual kernel it depends on
  2. New resolveMetaPackageKernel() function

    • Uses apt-cache depends to query meta-package dependencies
    • Safely extracts the actual kernel package name
    • Gracefully handles missing apt-cache (non-Debian systems)
  3. Comprehensive test coverage in new internal/system/reboot_test.go

    • 22+ test cases covering version parsing, comparison, and edge cases
    • Tests for all known meta-package variants
    • Tests for fallback behavior

Impact

  • Affected systems: Ubuntu/Debian with virtual kernel meta-packages (22.04+, 24.04+)
  • Risk level: Low - only affects reboot detection logic
  • Backward compatible: Yes - non-meta-package systems unaffected
  • Performance impact: None

Files Changed

  • internal/system/reboot.go - Enhanced kernel detection logic (+116 lines)
  • internal/system/reboot_test.go - New comprehensive test suite (229 lines)

Testing

Run tests with: go test -v ./internal/system

Fixes #379 Fixes #390

…ersions

Fixes #379 Fixes #390

Issue:
Virtual kernel meta-packages (linux-image-virtual, linux-image-generic, etc.)
were incorrectly marked as needs_reboot=true because the agent compared the
meta-package name against the running kernel version instead of the actual
kernel the meta-package depends on.

Root Cause:
- Agent extracted meta-package name: 'virtual'
- Compared against running kernel: '5.15.0-164-generic'
- Mismatch triggered false positive needs_reboot=true

Solution:
- Expanded meta-package detection to cover all variants
- Added resolveMetaPackageKernel() to resolve meta-packages to actual kernels
- Uses apt-cache depends to find kernel dependencies
- Gracefully falls back if apt-cache unavailable (non-Debian systems)

Changes:
- Modified getLatestKernelFromDpkg() in internal/system/reboot.go
  - Now skips: virtual, generic, lowlatency, cloud, generic-hwe meta-packages
  - Resolves each meta-package to its actual kernel package
- Added resolveMetaPackageKernel() function
  - Queries apt-cache for package dependencies
  - Parses kernel package information
  - Logs resolution attempts for debugging
- Added comprehensive tests in internal/system/reboot_test.go
  - 22+ test cases covering parsing, comparison, and edge cases
  - Tests for all known meta-package variants
  - Tests for missing/unavailable apt-cache fallback

Impact:
- Affects: Ubuntu/Debian systems with virtual kernel meta-packages
- Risk: Low - only changes reboot detection logic
- Backward compatible: Non-meta-package systems unaffected
- Performance: No impact
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.

1 participant