ROX-36925: Fix VM search by Guest OS - #22806
Conversation
Search, CVE OS counts, and the API all read storage.guest_os. Write the agent-detected string there on every upsert so they match; stamp scans from facts["guestOS"] so scan identity stays on the KubeVirt family name. Associated request: fix Guest OS search/display mismatch (ROX-36925); reuse guest_os; recompute from incoming facts; API reads the column. Partially generated by AI.
|
Skipping CI for Draft Pull Request. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (5)
Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review. 📝 SummarySummary by CodeRabbit
WalkthroughThe change separates the stored guest OS display value from the informer guest OS fact. Internal conversion stores the formatted value, reverse conversion preserves it, and scan lookup reads the informer fact. ChangesGuest OS data flow
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~15 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The reviewed change has no unresolved merge-blocking risk. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #22806 +/- ##
==========================================
- Coverage 51.86% 51.82% -0.05%
==========================================
Files 2896 2897 +1
Lines 182720 182757 +37
==========================================
- Hits 94769 94707 -62
- Misses 79659 79736 +77
- Partials 8292 8314 +22
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
🚀 Build Images ReadyImages are ready for commit 4ce5f0f. To use with deploy scripts: export MAIN_IMAGE_TAG=5.0.x-300-g4ce5f0f205 |
ListVMs with the displayed versioned OS must find the guest; the quoted informer family name must not. Get/List equality alone would not catch the index mismatch. Associated request: add Guest OS search coverage to the VM e2e. Partially generated by AI.
|
/test ocp-4-14-vm-scanning-e2e-tests ocp-4-18-vm-scanning-e2e-tests ocp-4-22-vm-scanning-e2e-tests |
|
/test ocp-4-22-vm-scanning-e2e-tests |
|
@vikin91: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
lookupGuestOS reads facts["guestOS"], not GuestOs. The v2 unknown case now matches v1 so it hits the sentinel filter instead of passing because the fact was missing. Associated request: follow-up branch piotr/vm-papercuts for PR #22806 review (set Facts on the unknown guest OS test). Partially generated by AI.
Description
VM list/detail and
GET /v2/virtualmachinesshowed the agent-detected guest OS when it was present (for exampleRed Hat Enterprise Linux 8.10). Search, sort, CVE “Guest OS affected”, and the affected-VMs table usedstorage.VirtualMachineV2.guest_os, which was the KubeVirt informer string (Red Hat Enterprise Linux).Quoted search is exact, so filtering on the header string returned nothing, while
Guest OS:"Red Hat Enterprise Linux"returned every RHEL VM. The CVE counter then reported one distinct OS.This writes the displayed string into
guest_oson every Sensor upsert: agent-detected when that fact is non-empty, otherwise the informer value, otherwiseunknown. The API copies that column with no overlay. Search and CVE counts follow the same field.Scan stamping still uses
facts["guestOS"](the informer family name). Agentos_versioncan move; aScanOschange replaces the whole scan, so the versioned display string must not become scan identity.Existing rows keep the old informer string until the next Sensor upsert. Central upgrade does not rewrite VM rows by itself.
Quoted
Guest OS:"Red Hat Enterprise Linux"no longer matches versioned guests. Unquoted prefix search still matches all of them.User-facing documentation
Testing and quality
Automated testing
How I validated my change
VirtualMachineV2GuestOSSearchpass on all 3.state without search:

searching for OS version of one VM:

searching for OS version of another VM:

searching string common to both VMs:

searching something unrelated:

searching

(three spaces):