Skip to content

ROX-36925: Fix VM search by Guest OS - #22806

Merged
vikin91 merged 2 commits into
masterfrom
piotr/rox-36925-guest-os-search
Sep 15, 2026
Merged

vikin91 merged 2 commits into
masterfrom
piotr/rox-36925-guest-os-search

Conversation

@vikin91

@vikin91 vikin91 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Description

VM list/detail and GET /v2/virtualmachines showed the agent-detected guest OS when it was present (for example Red Hat Enterprise Linux 8.10). Search, sort, CVE “Guest OS affected”, and the affected-VMs table used storage.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_os on every Sensor upsert: agent-detected when that fact is non-empty, otherwise the informer value, otherwise unknown. 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). Agent os_version can move; a ScanOs change 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

  • the change is production ready: the change is GA, or otherwise the functionality is gated by a feature flag
  • CI results are inspected

Automated testing

  • added unit tests
  • added e2e tests
  • added regression tests
  • added compatibility tests
  • modified existing tests

How I validated my change

  • CI
    • e2e 4.14 - ❄️ failing for 1 of 3 VMs (flake) - VirtualMachineV2GuestOSSearch pass on all 3.
    • e2e 4.18 - ✅ passing (this is sufficient)
    • e2e 4.22 - ❌ infra issues
  • Manually in UI

state without search:
Screenshot 2026-09-14 at 11 51 09

searching for OS version of one VM:
Screenshot 2026-09-14 at 11 51 21

searching for OS version of another VM:
Screenshot 2026-09-14 at 11 51 32

searching string common to both VMs:
Screenshot 2026-09-14 at 11 51 51

searching something unrelated:
Screenshot 2026-09-14 at 11 52 08

searching (three spaces):
Screenshot 2026-09-14 at 11 52 23

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.
@openshift-ci

openshift-ci Bot commented Sep 11, 2026

Copy link
Copy Markdown

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@vikin91 vikin91 changed the title ROX-36925: store displayed Guest OS in the search column ROX-36925: Fix VM search by Guest OS Sep 11, 2026
@coderabbitai

coderabbitai Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Enterprise

Run ID: 1c98a98f-782b-470f-b7b6-0ac7ef965eee

📥 Commits

Reviewing files that changed from the base of the PR and between 590b4ba and b6fa9c5.

📒 Files selected for processing (5)
  • tests/vm_scanning_test.go
  • tests/vmhelpers/central.go
  • tests/vmhelpers/central_test.go
  • tests/vmhelpers/central_v2.go
  • tests/vmhelpers/central_v2_test.go

Included review availability: Your plan provides up to 12 included reviews per hour; 10 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Improved guest OS information handling across virtual machine details, lists, and scans.
    • Displayed guest OS values now consistently use detected information when available, with an appropriate fallback when unavailable.
    • Preserved stored guest OS values during conversion instead of replacing them with alternate detected values.
    • Scans now use the underlying detected guest OS value rather than the formatted display value.
    • Improved virtual machine filtering by guest OS while preserving accurate namespace and name matching.

Walkthrough

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

Changes

Guest OS data flow

Layer / File(s) Summary
Store guest OS display value
central/convert/internaltostorage/virtual_machine_v2.go, central/convert/internaltostorage/virtual_machine_v2_test.go, pkg/virtualmachine/facts.go
Internal conversion uses DisplayGuestOS with detected facts and the informer fallback. Tests and documentation reflect the stored value.
Preserve stored guest OS
central/convert/storagetov2/virtual_machine_v2.go, central/convert/storagetov2/virtual_machine_v2_test.go
List-item and detail conversions return the stored GuestOs value without recomputing it from detected facts.
Read informer guest OS for scans and filters
central/sensor/service/pipeline/virtualmachineindex/pipeline.go, central/sensor/service/pipeline/virtualmachineindex/pipeline_test.go, tests/vm_scanning_test.go, tests/vmhelpers/*
Enhanced-data-model lookup reads facts["guestOS"]. Helper and integration tests validate exact guest OS filtering.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Suggested reviewers: stehessel, janisz

Merge Risk: ⚪ Minimal · up to b6fa9

The reviewed change has no unresolved merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 18 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the primary change: fixing VM search by Guest OS.
Description check ✅ Passed The description explains the problem, implementation, behavior changes, compatibility impact, documentation status, automated tests, CI results, and manual validation.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch piotr/rox-36925-guest-os-search

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

@codecov

codecov Bot commented Sep 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 51.82%. Comparing base (a8f1e98) to head (b6fa9c5).
⚠️ Report is 4 commits behind head on master.

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     
Flag Coverage Δ
go-unit-tests 51.82% <100.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

🚀 Build Images Ready

Images 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.
@vikin91

vikin91 commented Sep 11, 2026

Copy link
Copy Markdown
Contributor Author

/test ocp-4-14-vm-scanning-e2e-tests ocp-4-18-vm-scanning-e2e-tests ocp-4-22-vm-scanning-e2e-tests

@vikin91

vikin91 commented Sep 12, 2026

Copy link
Copy Markdown
Contributor Author

/test ocp-4-22-vm-scanning-e2e-tests

@vikin91
vikin91 marked this pull request as ready for review September 14, 2026 06:55
@openshift-ci

openshift-ci Bot commented Sep 14, 2026

Copy link
Copy Markdown

@vikin91: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/ocp-4-14-vm-scanning-e2e-tests b6fa9c5 link false /test ocp-4-14-vm-scanning-e2e-tests
ci/prow/ocp-4-22-vm-scanning-e2e-tests b6fa9c5 link false /test ocp-4-22-vm-scanning-e2e-tests
ci/prow/ocp-4-22-qa-e2e-tests b6fa9c5 link false /test ocp-4-22-qa-e2e-tests
ci/prow/ocp-4-22-nongroovy-e2e-tests b6fa9c5 link false /test ocp-4-22-nongroovy-e2e-tests
ci/prow/ocp-4-12-qa-e2e-tests b6fa9c5 link false /test ocp-4-12-qa-e2e-tests
ci/prow/ocp-4-12-operator-e2e-tests b6fa9c5 link false /test ocp-4-12-operator-e2e-tests
ci/prow/ocp-4-22-ui-e2e-tests b6fa9c5 link false /test ocp-4-22-ui-e2e-tests
ci/prow/ocp-4-22-operator-e2e-tests b6fa9c5 link false /test ocp-4-22-operator-e2e-tests
ci/prow/ocp-4-12-nongroovy-e2e-tests b6fa9c5 link false /test ocp-4-12-nongroovy-e2e-tests

Full PR test history. Your PR dashboard.

Details

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

@vikin91
vikin91 requested review from guzalv and lvalerom September 14, 2026 09:29
@vikin91
vikin91 merged commit 4ce5f0f into master Sep 15, 2026
125 of 134 checks passed
@vikin91
vikin91 deleted the piotr/rox-36925-guest-os-search branch September 15, 2026 08:14
vikin91 added a commit that referenced this pull request Sep 16, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants