Skip to content

Commit

Permalink
fix: Hide subscription management "errors" in container mode
Browse files Browse the repository at this point in the history
* Card ID: CCT-322
* Card ID: RHEL-7199

When `dnf` is run in a container that gets its content from a host,
extra messages were displayed:

- Updating Subscription Management repositories.
> Unable to read consumer identity
- subscription-manager is operating in container mode.
> This system is not registered with an entitlement server. You can use
  subscription-manager to register.

Only the first line and third should be displayed; the second and fourth
are not relevant in container mode.
  • Loading branch information
m-horky committed May 21, 2024
1 parent 3cc6ee7 commit d2dd29a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/plugins/dnf/subscription_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ def _config(self):
if os.getuid() == 0:
# Try to update entitlement certificates and redhat.repo file
self._update(cache_only)
self._warn_or_give_usage_message()
if not config.in_container():
self._warn_or_give_usage_message()
else:
logger.info(_("Not root, Subscription Management repositories not updated"))
self._warn_expired()
Expand Down Expand Up @@ -159,7 +160,7 @@ def _update(cache_only):
# valid entitlement certificates, but does not yet have any identity.
# We have access to the content, so we shouldn't be reporting missing
# identity certificate.
if not identity.is_valid() and len(ent_dir.list_valid()) == 0:
if not config.in_container() and not identity.is_valid() and len(ent_dir.list_valid()) == 0:
logger.info(_("Unable to read consumer identity"))

if config.in_container():
Expand Down

0 comments on commit d2dd29a

Please sign in to comment.