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

feat: Add warning message about release version to dnf plugin #3385

Merged
merged 2 commits into from
Mar 28, 2024
Merged
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
25 changes: 24 additions & 1 deletion src/plugins/dnf/subscription_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@

from configparser import ConfigParser

from typing import TYPE_CHECKING
from typing import TYPE_CHECKING, Optional

if TYPE_CHECKING:
from subscription_manager.certdirectory import EntitlementDirectory
from subscription_manager.identity import Identity
from subscription_manager.cache import ReleaseStatusCache


expired_warning = _(
Expand Down Expand Up @@ -70,6 +71,12 @@
"""
)

release_lock_warning = _(
"""
This system has release set to {release_version} and it receives updates only for this release.
"""
)

log = logging.getLogger("rhsm-app." + __name__)


Expand Down Expand Up @@ -206,6 +213,22 @@ def _warn_or_give_usage_message():
msg = not_registered_warning
elif len(ent_dir.list_valid()) == 0 and not is_simple_content_access(identity=identity):
msg = no_subs_warning
else:
# Try to read release version ONLY from cache document.
# When cache document does not exist, then do not try to get this information
# from candlepin server and slow down DNF plugin!
release_cache: ReleaseStatusCache = inj.require(inj.RELEASE_STATUS_CACHE)
release_version_dict: Optional[dict] = release_cache.read_cache_only()
if release_version_dict:
try:
release_version: str = release_version_dict["releaseVer"]
except KeyError:
log.warning("The 'releaseVer' not included in the release version document")
else:
# Skip the case, when release does not exist at all, or it was unset
# and it is empty string
if release_version:
msg = release_lock_warning.format(release_version=release_version)
finally:
if msg:
logger.info(msg)
Expand Down
2 changes: 1 addition & 1 deletion src/subscription_manager/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def _cache_exists(self) -> bool:

def read_status(
self, uep: connection.UEPConnection, uuid: str, on_date: Optional[datetime.datetime] = None
) -> Optional[str]:
) -> Optional[dict]:
"""
Return status, from cache if it exists, otherwise load_status
and write cache and return it.
Expand Down
Loading