Skip to content

Commit

Permalink
fix(client): Update logging messages
Browse files Browse the repository at this point in the history
* Card ID: CCT-265

This patch updates the logging messages shown to the user when the host
is registered/not-registered with subscription-manager or when the host
is registered/not-registered with insights-client.

Signed-off-by: pkoprda <[email protected]>
  • Loading branch information
pkoprda committed Feb 6, 2025
1 parent 263aaa7 commit ec68be0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 9 deletions.
4 changes: 3 additions & 1 deletion insights/client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,9 @@ def checkin(self):
logger.info("Checking in...")

if not self._fetch_system_by_machine_id():
logger.error("This host is not registered. To register, run 'insights-client --register'.")
logger.error("This host is not registered. "
"Use --register to register this host.\n"
"# insights-client --register")
return False

try:
Expand Down
25 changes: 17 additions & 8 deletions insights/client/phase/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from insights.client.config import InsightsConfig
from insights.client.constants import InsightsConstants as constants
from insights.client.support import InsightsSupport
from insights.client.utilities import validate_remove_file, print_egg_versions
from insights.client.utilities import validate_remove_file, print_egg_versions, _get_rhsm_identity
from insights.client.schedule import get_scheduler

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -56,9 +56,16 @@ def get_phases():
@phase
def pre_update(client, config):

# Check if BASIC auth is used to print a WARNING message
if config.authmethod == 'BASIC':
logger.warning('WARN: BASIC authentication method is being deprecated. Please consider using CERT authentication method.')
# Check if the host is registered with subscription-manager
if config.authmethod == 'BASIC' or not _get_rhsm_identity():
logger.error('This host has not yet been registered, please ensure '
'that the system is\nregistered with subscription-manager '
'and then with insights-client.\n'
'\n1. Register with subscription-manager'
'\n# subscription-manager register\n'
'\n2. Register with insights-client'
'\n# insights-client --register')
sys.exit(constants.sig_kill_bad)

if config.version:
logger.info(constants.version)
Expand Down Expand Up @@ -264,8 +271,9 @@ def post_update(client, config):

# halt here if unregistered
if not reg_check and not config.register:
logger.info('This host has not been registered. '
'Use --register to register this host.')
logger.error('This host is not registered. '
'Use --register to register this host.\n'
'# insights-client --register')
sys.exit(constants.sig_kill_bad)

# --register was called
Expand All @@ -274,8 +282,9 @@ def post_update(client, config):
# system creation and upload are a single event on the platform
if reg_check is False and isfile(constants.machine_id_file):
# Do not register if a machine_id file is found
logger.info("Machine-id found, insights-client can not be registered."
" Please, unregister insights-client first: `insights-client --unregister`")
logger.error('Machine-id found, insights-client can not be registered. '
'Use --unregister to unregister this host first.\n'
'# insights-client --unregister')
sys.exit(constants.sig_kill_bad)
if reg_check:
logger.info('This host has already been registered.')
Expand Down

0 comments on commit ec68be0

Please sign in to comment.