Skip to content

Rhel under major 7 yum adapation - #2458

Open
pindo696 wants to merge 2 commits into
RedHatInsights:masterfrom
pindo696:7.9-and-7Server-yum-adapation
Open

Rhel under major 7 yum adapation#2458
pindo696 wants to merge 2 commits into
RedHatInsights:masterfrom
pindo696:7.9-and-7Server-yum-adapation

Conversation

@pindo696

@pindo696 pindo696 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Reproduced on a RHEL 7.9 VM: yum repolist looked the same for 7.9 and after subscription-manager release --set=7Server (and checking redhat.repo). Vulnerability report did not. With rhsm_version=7.9 we got different number of CVEs reported. Same host, different releasever only.

That’s because vmaas filters repos by releasever. So 7.9 and 7Server hit different repo sets - which is intentional as strict matching and caused by setting subscription-manager release --set=7.9 which is a user preference setup.
RHEL 7 has the dual 7.9 and 7Server naming that looks like that yum treats as equivalent. This hotfix drops the releasever for RHEL versions under major 7 which has less narrow match. Returning None (omitting releasever) produces the same results as the old 7Server hardcode RedHatInsights/vmaas-lib#140.
We don’t see this on RHEL 8+ since releasevers are numeric and already match what is being stored (RHEL 8+ uses {major}.{minor}.)

In the second commit I also added logging so we can better track the evaluation and see what is being passed to releasever so we can possibly make the decision process more accurate.

I was unable to reproduce on RHEL 6 as it was unable to register the machine with entitlement server.

TLDR: Drop releasever from vmaas_json request for RHEL major versions under 7.

RHINENG-26908

Secure Coding Checklist

  • Input Validation
  • Output Encoding
  • Authentication and Password Management
  • Session Management
  • Access Control
  • Cryptographic Practices
  • Error Handling and Logging
  • Data Protection
  • Communication Security
  • System Configuration
  • Database Security
  • File Management
  • Memory Management
  • General Coding Practices

Summary by Sourcery

Adjust release version handling for RHEL systems to avoid overly strict repo filtering on RHEL 7 and add feature-flagged logging for release version evaluation.

New Features:

  • Introduce release version adaptation that omits numeric releasever values for RHEL major versions 7 and below when building VMaaS requests.

Enhancements:

  • Add feature-flag controlled logging of release version sources and final value in the inventory processor.
  • Initialize the Unleash feature flag client during listener startup.
  • Extend feature flag definitions with a dedicated flag for release version logging.

Tests:

  • Add unit tests covering release version adaptation logic for different RHEL releasever formats.

@sourcery-ai

sourcery-ai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR adjusts how RHEL releasever is handled when building VMaaS requests, dropping numeric releasevers for RHEL major versions <= 7 and adding optional logging around the releasever evaluation via Unleash feature flags, plus wiring Unleash initialization into the listener startup and adding unit coverage for the new behavior.

Sequence diagram for releasever adaptation during inventory processing

sequenceDiagram
    participant InventoryProcessor
    participant adapt_releasever
    participant UNLEASH
    participant LOGGER
    participant VMaaS

    InventoryProcessor->>InventoryProcessor:_parse_system_data(msg)
    InventoryProcessor->>InventoryProcessor:get rhsm_ver and system_profile.releasever
    InventoryProcessor->>adapt_releasever:adapt_releasever(rhsm_ver_or_sp_releasever)
    adapt_releasever-->>InventoryProcessor:releasever_or_None

    alt UNLEASH.is_enabled(RELEASEVER_LOG_FEATURE)
        InventoryProcessor->>UNLEASH:is_enabled(RELEASEVER_LOG_FEATURE)
        UNLEASH-->>InventoryProcessor:is_enabled_result
        InventoryProcessor->>LOGGER:info(rhsm_ver, sp_releasever, releasever)
    end

    InventoryProcessor->>VMaaS:_format_repo_list(yum_repos, basearch, releasever)
Loading

Sequence diagram for listener startup with Unleash initialization

sequenceDiagram
    participant ListenerMain
    participant initialize_unleash
    participant UNLEASH

    ListenerMain->>ListenerMain:main()
    ListenerMain->>ListenerMain:init_logging()
    ListenerMain->>initialize_unleash:initialize_unleash()
    initialize_unleash->>UNLEASH:configure_client()
    UNLEASH-->>initialize_unleash:client_ready
    ListenerMain->>ListenerMain:a_ensure_minimal_schema_version()
    ListenerMain->>ListenerMain:run()
Loading

File-Level Changes

Change Details Files
Introduce releasever adaptation logic for RHEL <= 7 and use it when constructing VMaaS repo requests.
  • Add adapt_releasever helper that returns None for numeric releasevers whose major version is <= 7 while preserving stream labels, bare majors, RHEL 8+ numeric releasevers, and None inputs.
  • Use adapt_releasever in inventory_processor to compute releasever from rhsm version or system_profile releasever before passing it into _format_repo_list.
listener/common.py
listener/inventory_processor.py
Add feature-flagged logging for releasever selection and initialize Unleash in the listener process.
  • Gate new releasever selection logging behind RELEASEVER_LOG_FEATURE via the global UNLEASH client and log rhsm version, system_profile releasever, and the adapted releasever when enabled.
  • Define RELEASEVER_LOG_FEATURE in the feature_flags module and initialize the Unleash client during listener main startup.
listener/inventory_processor.py
listener/listener.py
common/feature_flags.py
Extend tests to cover the new releasever adaptation behavior.
  • Add unit tests verifying that numeric RHEL <= 7 releasevers are dropped, stream labels are preserved, RHEL 8+ numeric releasevers are left unchanged, and None input passes through unchanged.
tests/listener_tests/test_common.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hey - I've found 2 issues, and left some high level feedback:

  • The adapt_releasever docstring and inline comments could be clarified to explicitly describe the exact conditions under which the releasever is set to None (numeric with a dot and major <= 7) to avoid confusion for future maintainers.
  • Consider making adapt_releasever slightly more defensive about unexpected releasever formats (e.g., using split('.') and validating the major component) so it is easier to reason about and less sensitive to odd input values.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The `adapt_releasever` docstring and inline comments could be clarified to explicitly describe the exact conditions under which the releasever is set to `None` (numeric with a dot and major <= 7) to avoid confusion for future maintainers.
- Consider making `adapt_releasever` slightly more defensive about unexpected `releasever` formats (e.g., using `split('.')` and validating the major component) so it is easier to reason about and less sensitive to odd input values.

## Individual Comments

### Comment 1
<location path="listener/common.py" line_range="71-78" />
<code_context>
+def adapt_releasever(releasever: str | None) -> str | None:
+    """
+    Drop RHEL <= 7 numeric releasevers.
+    This supresses user ``subscription-manager release --set=...``
+    setup, which is intended in this case
+    to match xServer yum repos for x.y releasever.
+    This can be removed once the RHEL 7 dies.
+    """
+    if not releasever:
</code_context>
<issue_to_address>
**nitpick (typo):** Minor wording/typo issues in the new docstring.

Please fix the spelling of `supresses``suppresses`, and rephrase "once the RHEL 7 dies" to something like "once RHEL 7 reaches end of life" for clearer documentation.

```suggestion
def adapt_releasever(releasever: str | None) -> str | None:
    """
    Drop RHEL <= 7 numeric releasevers.
    This suppresses user ``subscription-manager release --set=...``
    setup, which is intended in this case
    to match xServer yum repos for x.y releasever.
    This can be removed once RHEL 7 reaches end of life.
    """
```
</issue_to_address>

### Comment 2
<location path="listener/inventory_processor.py" line_range="156-162" />
<code_context>
             basearch = system_profile.get("basearch") or system_profile.get("arch")
             rhsm_ver = system_profile.get("rhsm", {}).get("version")
-            releasever = rhsm_ver or system_profile.get("releasever")
+            releasever = adapt_releasever(rhsm_ver or system_profile.get("releasever"))
+            if UNLEASH.is_enabled(RELEASEVER_LOG_FEATURE):
+                LOGGER.info(
+                    "releasever sources: rhsm_ver=%s, sp_releasever=%s, result_releasever=%s",
+                    rhsm_ver,
+                    system_profile.get("releasever"),
+                    releasever,
+                )

</code_context>
<issue_to_address>
**suggestion (performance):** Consider how often the info-level releasever logging will fire and whether that aligns with expectations.

This log line will run on every inventory message when the feature flag is enabled, using `LOGGER.info`. In high-traffic environments that could generate substantial log volume and affect noise or storage. If this is mainly for diagnostics, consider `debug` level or sampling/throttling; if `info` is intentional, documenting that in the feature flag or rollout notes would help set expectations.

Suggested implementation:

```python
            releasever = adapt_releasever(rhsm_ver or system_profile.get("releasever"))
            if UNLEASH.is_enabled(RELEASEVER_LOG_FEATURE):
                LOGGER.debug(
                    "releasever sources: rhsm_ver=%s, sp_releasever=%s, result_releasever=%s",
                    rhsm_ver,
                    system_profile.get("releasever"),

```

1. Update the documentation/comments for `RELEASEVER_LOG_FEATURE` (wherever it is defined) to note that the logging is at `debug` level and intended for diagnostics in high-traffic environments.
2. If there are rollout notes or operational docs describing this feature flag, adjust them to match the new log level and expected usage.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread listener/common.py
Comment thread listener/inventory_processor.py
Ommit releasever in vmaas_json for rhel major versions <= 7 when matching repos so rhel repolist is closer to yum. RHINENG-26908
Added an unleash debug log so we can better see what is being passed to releasever so we can possibly make the decission process of releasever more accurate for rhel <= 7 as I am not able to access inventory.
@pindo696
pindo696 force-pushed the 7.9-and-7Server-yum-adapation branch from 45c0c1f to df1624a Compare August 12, 2026 08:32
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