Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Append two additional facts to the graylist #3520

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/rhsmlib/facts/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
class FactsDict(collections.abc.MutableMapping):
"""A dict for facts that ignores items in 'graylist' on compares."""

graylist = set(["cpu.cpu_mhz", "lscpu.cpu_mhz"])
# see bz #627962
# we would like to have this info, but for now, since it
# can change constantly on laptops, it makes for a lot of
# fact churn, so we report it, but ignore it as an indicator
# that we need to update
GRAYLIST = set(
["cpu.cpu_mhz", "lscpu.cpu_mhz", "proc_cpuinfo.common.cpu_mhz", "lscpu.cpu(s)_scaling_mhz"]
)

def __init__(self, *args, **kwargs):
super(FactsDict, self).__init__(*args, **kwargs)
Expand All @@ -43,12 +50,12 @@ def __len__(self) -> int:
return len(self.data)

def __eq__(self, other) -> bool:
"""Compares all of the items in self.data, except it ignores keys in self.graylist."""
"""Compares all of the items in self.data, except it ignores keys in self.GRAYLIST."""
if not isinstance(other, FactsDict):
return NotImplemented

keys_self = set(self.data).difference(self.graylist)
keys_other = set(other.data).difference(self.graylist)
keys_self = set(self.data).difference(self.GRAYLIST)
keys_other = set(other.data).difference(self.GRAYLIST)
if keys_self == keys_other:
if all(self.data[k] == other.data[k] for k in keys_self):
return True
Expand Down
12 changes: 3 additions & 9 deletions src/subscription_manager/facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@
from datetime import datetime
import logging
import os
from typing import Dict, List, Optional, TYPE_CHECKING
from typing import Dict, Optional, TYPE_CHECKING

from subscription_manager.injection import PLUGIN_MANAGER, require
from subscription_manager.cache import CacheManager
from rhsm import ourjson as json

from rhsmlib.facts.all import AllFactsCollector
from rhsmlib.facts.collection import FactsDict

if TYPE_CHECKING:
from subscription_manager.plugins import PluginManager
Expand All @@ -41,13 +42,6 @@ class Facts(CacheManager):
def __init__(self):
self.facts = {}

# see bz #627962
# we would like to have this info, but for now, since it
# can change constantly on laptops, it makes for a lot of
# fact churn, so we report it, but ignore it as an indicator
# that we need to update
self.graylist: List[str] = ["cpu.cpu_mhz", "lscpu.cpu_mhz"]

# plugin manager so we can add custom facts via plugin
self.plugin_manager: PluginManager = require(PLUGIN_MANAGER)

Expand All @@ -70,7 +64,7 @@ def has_changed(self) -> bool:
# In order to accurately check for changes, we must refresh local data
self.facts = self.get_facts(True)

for key in (set(self.facts) | set(cached_facts)) - set(self.graylist):
for key in (set(self.facts) | set(cached_facts)) - FactsDict.GRAYLIST:
if self.facts.get(key) != cached_facts.get(key):
return True
return False
Expand Down
Loading