RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2101840 - Leapp fails while executing an SQL insert request containing the hostname (leapp.db)
Summary: Leapp fails while executing an SQL insert request containing the hostname (le...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: leapp
Version: 7.9
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Leapp team
QA Contact: Upgrades and Supportability
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-06-28 14:07 UTC by Christophe Besson
Modified: 2022-11-09 12:33 UTC (History)
3 users (show)

Fixed In Version: leapp-0.15.0-1.el7_9
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-11-09 12:33:16 UTC
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Issue Tracker OAMG-7102 0 None None None 2022-06-28 14:32:36 UTC
Red Hat Issue Tracker RHELPLAN-126504 0 None None None 2022-06-28 14:32:41 UTC

Description Christophe Besson 2022-06-28 14:07:08 UTC
Description of problem:
Leapp fails while executing an SQL insert request containing the hostname (leapp.db)

Version-Release number of selected component (if applicable):
leapp-upgrade-el7toel8-0.16.0-4.el7_9

How reproducible:
Always for the customer.

Actual results:
# leapp preupgrade --target 8.4
Traceback (most recent call last):
  File "/bin/leapp", line 9, in <module>
    load_entry_point('leapp==0.14.0', 'console_scripts', 'leapp')()
  File "/usr/lib/python2.7/site-packages/leapp/cli/__init__.py", line 37, in main
    cli.command.execute('leapp version {}'.format(VERSION))
  File "/usr/lib/python2.7/site-packages/leapp/utils/clicmd.py", line 106, in execute
    args.func(args)
  File "/usr/lib/python2.7/site-packages/leapp/utils/clicmd.py", line 128, in called
    self.target(args)
  File "/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/breadcrumbs.py", line 94, in wrapper
    return f(*args, breadcrumbs=breadcrumbs, **kwargs)
  File "/usr/lib/python2.7/site-packages/leapp/cli/commands/preupgrade/__init__.py", line 48, in preupgrade
    logger = configure_logger('leapp-preupgrade.log')
  File "/usr/lib/python2.7/site-packages/leapp/logger/__init__.py", line 88, in configure_logger
    _logger.info('Logging has been initialized')
  File "/usr/lib64/python2.7/logging/__init__.py", line 1149, in info
    self._log(INFO, msg, args, **kwargs)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1268, in _log
    self.handle(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1278, in handle
    self.callHandlers(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 1318, in callHandlers
    hdlr.handle(record)
  File "/usr/lib64/python2.7/logging/__init__.py", line 749, in handle
    self.emit(record)
  File "/usr/lib/python2.7/site-packages/leapp/logger/__init__.py", line 40, in emit
    self._do_emit(log_data)
  File "/usr/lib/python2.7/site-packages/leapp/logger/__init__.py", line 45, in _do_emit
    Audit(**log_data).store()
  File "/usr/lib/python2.7/site-packages/leapp/utils/audit/__init__.py", line 88, in store
    self.do_store(connection)
  File "/usr/lib/python2.7/site-packages/leapp/utils/audit/__init__.py", line 359, in do_store
    super(Audit, self).do_store(connection)
  File "/usr/lib/python2.7/site-packages/leapp/utils/audit/__init__.py", line 215, in do_store
    super(DataSource, self).do_store(connection)
  File "/usr/lib/python2.7/site-packages/leapp/utils/audit/__init__.py", line 162, in do_store
    (self.context, self.hostname))
sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.

Additional info:
- The issue happens in /usr/lib/python2.7/site-packages/leapp/utils/audit/__init__.py

159     def do_store(self, connection):
160         super(Host, self).do_store(connection)
161         import sys; sys.stdout.write("DO_STORE: hostname=%s context=%s\n" % (self.hostname, self.context))     # <===
162         connection.execute('INSERT OR IGNORE INTO host (context, hostname) VALUES(?, ?)',
163                            (self.context, self.hostname))
164         cursor = connection.execute('SELECT id FROM host WHERE context = ? AND hostname = ?',
165                                     (self.context, self.hostname))
166         self._host_id = cursor.fetchone()[0]

- Printing the hostname shows the following data (line 161)

DO_STORE: hostname='HOSTNAME.XXX.YYY.ZZZ     HOSTNAME   ALIAS.XXX.YYY.ZZZ        ALIAS' context='TESTING-CONTEXT'

=> it contains both fqdn hostname and aliases (on my test box, it prints "foo.bar" only).
=> this is the content of the /etc/hosts file for the host IP

- the customer had duplicate entries in /etc/hosts for the host IP. Removing the duplicate fixed the issue for the customer (but it didn't help me to reproduce the issue, it's weird).

Comment 3 Petr Stodulka 2022-08-17 15:55:49 UTC
The upstream PR fixing the issue:
    https://github.com/oamg/leapp/pull/790

The hostname on the machine is invalid. In such a case we will replace the invalid hostname in leapp reports & db by the 'invalid.hostname' string.

Comment 4 Petr Stodulka 2022-08-23 16:40:18 UTC
The PR has been merged in the upstream.

Comment 9 errata-xmlrpc 2022-11-09 12:33:16 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (leapp and leapp-repository bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2022:7895


Note You need to log in before you can comment on or make changes to this bug.