Bug 2158201

Summary: [leapp] Leapp should ignore a wrongly formatted direct.xml config file if the firewalld service is disabled
Product: Red Hat Enterprise Linux 7 Reporter: Christophe Besson <cbesson>
Component: leapp-repositoryAssignee: Leapp Notifications Bot <leapp-notifications-bot>
Status: NEW --- QA Contact: upgrades-and-conversions
Severity: low Docs Contact:
Priority: low    
Version: 7.9Keywords: Reproducer
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Christophe Besson 2023-01-04 15:43:34 UTC
Description of problem:
Customer tried to comment out XML lines with #, leading to a wrongly formatted file in /etc/firewalld/direct.xml. They disabled the service afterwards. Leapp tries to parse that file but should ignore the ParseError like it is done if the file is missing (IOError).

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

How reproducible:
Always

Steps to Reproduce:
1. cat /etc/firewalld/direct.xml
<?xml version="1.0" encoding="utf-8"?>
#<direct>
 # <rule priority="1" table="filter" ipv="ipv4" chain="OUTPUT">-j DROP</rule>
#</direct>

2. leapp preupgrade

Actual results:
Process Process-234:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/lib/python2.7/site-packages/leapp/repository/actor_definition.py", line 72, in _do_run
    actor_instance.run(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/leapp/actors/__init__.py", line 289, in run
    self.process(*args)
  File "/usr/share/leapp-repository/repositories/system_upgrade/el7toel8/actors/firewalldfactsactor/actor.py", line 33, in process
    tree = ElementTree.parse('/etc/firewalld/direct.xml')
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1182, in parse
    tree.parse(source, parser)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 656, in parse
    parser.feed(data)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1642, in feed
    self._raiseerror(v)
  File "/usr/lib64/python2.7/xml/etree/ElementTree.py", line 1506, in _raiseerror
    raise err
ParseError: not well-formed (invalid token): line 2, column 1


======================================================================================================
Actor firewalld_facts_actor unexpectedly terminated with exit code: 1 - Please check the above details
======================================================================================================

Expected results:
Ignore that ParseError, possibly with a warning.

Additional info:
 32         try:
 33             tree = ElementTree.parse('/etc/firewalld/direct.xml')
 34             root = tree.getroot()
 35             facts.ebtablesTablesInUse = firewalldfactsactor.getEbtablesTablesInUse(root)
 36         except IOError:
 37             pass