-
Notifications
You must be signed in to change notification settings - Fork 84
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
[RHELC-1180] OL 8: Prevent conversion failure with firewalld running #953
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #953 +/- ##
==========================================
- Coverage 93.87% 93.77% -0.10%
==========================================
Files 46 47 +1
Lines 4296 4340 +44
Branches 755 766 +11
==========================================
+ Hits 4033 4070 +37
- Misses 188 192 +4
- Partials 75 78 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
convert2rhel/actions/system_checks/check_firewalld_availability.py
Outdated
Show resolved
Hide resolved
convert2rhel/actions/system_checks/check_firewalld_availability.py
Outdated
Show resolved
Hide resolved
/packit test |
db4b15d
to
a3367f9
Compare
93ad69f
to
7d8f4a9
Compare
/packit test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left suggested edits.
convert2rhel/actions/system_checks/check_firewalld_availability.py
Outdated
Show resolved
Hide resolved
convert2rhel/actions/system_checks/check_firewalld_availability.py
Outdated
Show resolved
Hide resolved
convert2rhel/actions/system_checks/check_firewalld_availability.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A couple of nitpicks, otherwise looks, good, thank you!
tests/ansible_collections/roles/oracle-linux-specific/tasks/stop_firewalld_workaround.yml
Outdated
Show resolved
Hide resolved
tests/integration/tier0/non-destructive/firewalld-inhibitor/test_firewalld_inhibitor.py
Outdated
Show resolved
Hide resolved
tests/integration/tier0/non-destructive/firewalld-inhibitor/test_firewalld_inhibitor.py
Outdated
Show resolved
Hide resolved
tests/integration/tier0/non-destructive/firewalld-inhibitor/main.fmf
Outdated
Show resolved
Hide resolved
tests/integration/tier0/non-destructive/firewalld-inhibitor/main.fmf
Outdated
Show resolved
Hide resolved
tests/integration/tier0/non-destructive/firewalld-inhibitor/main.fmf
Outdated
Show resolved
Hide resolved
d7efd86
to
52636df
Compare
/packit test |
/packit test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
/packit retest-failed |
324565d
to
f9f456a
Compare
Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Co-authored-by: Michal Bocek <mbocek@redhat.com>
Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Fixed the detection of the CleanupModulesOnExit inside the firewalld.conf and updated the tests cases Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Co-authored-by: Michal Bocek <mbocek@redhat.com>
Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
0db1f6d
to
5709cb9
Compare
/packit test |
convert2rhel/actions/system_checks/check_firewalld_availability.py
Outdated
Show resolved
Hide resolved
convert2rhel/actions/system_checks/check_firewalld_availability.py
Outdated
Show resolved
Hide resolved
Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
/packit test |
/packit test |
) | ||
return | ||
|
||
logger.info("Skipping the check as it is relevant only for Oracle Linux 8.8 and above.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a PR blocker, but: If none of the above condition is true, then this message is printed.
Scenario:
- we are on oracle8.8
- the firewalld is running
- the config file contains the
CleanupModulesOnExit=no
then all the ifs are skipped and no defaultreturn
is present, so thelogger.info("Skipping the check as it is relevant only for Oracle Linux 8.8 and above.")
is printed even though we are on 8.8 :D
14:28:50 out: [2023-10-30T14:28:50+0000] TASK - [Prepare: Gather system information] *******************************
14:28:50 out: [2023-10-30T14:28:50+0000] DEBUG - Calling command 'uname -i'
14:28:50 out: Skipping the execution of 'rpm -Va'.
14:28:50 out: [2023-10-30T14:28:50+0000] DEBUG - Calling command 'uname -r'
14:28:50 out: [2023-10-30T14:28:50+0000] DEBUG - Booted kernel VRA (version, release, architecture): 4.18.0-477.27.1.el8_8.x86_64
14:28:50 out: Checking internet connectivity using address 'https://static.redhat.com/test/rhel-networkmanager.txt'.
14:28:50 out: Successfully connected to address 'https://static.redhat.com/test/rhel-networkmanager.txt', internet connection seems to be available.
14:28:50 out: [2023-10-30T14:28:50+0000] DEBUG - Calling command '/usr/bin/systemctl show -p ActiveState dbus'
14:28:50 out: Name: Oracle Linux Server
14:28:50 out: OS version: 8.8
14:28:50 out: Architecture: x86_64
14:28:50 out: Config filename: oracle-8-x86_64.cfg
14:28:53 out:
14:28:53 out: [2023-10-30T14:28:53+0000] TASK - [Prepare: Clear YUM/DNF version locks] *****************************
14:28:53 out: Usage of YUM/DNF versionlock plugin not detected.
14:28:53 out:
14:28:53 out: [2023-10-30T14:28:53+0000] TASK - [Prepare: Clean yum cache metadata] ********************************
14:28:53 out: [2023-10-30T14:28:53+0000] DEBUG - Calling command 'yum clean metadata --enablerepo=* --quiet'
14:28:53 out: [2023-10-30T14:28:53+0000] DEBUG - Output of yum clean metadata:
14:28:53 out:
14:28:53 out: Cached repositories metadata cleaned successfully.
14:28:53 out:
14:28:53 out: [2023-10-30T14:28:53+0000] TASK - [Prepare: Check whether system is ready for conversion] ************
14:28:53 out:
14:28:53 out: [2023-10-30T14:28:53+0000] TASK - [Prepare: Check that firewalld is running] *************************
14:28:53 out: [2023-10-30T14:28:53+0000] DEBUG - Calling command '/usr/bin/systemctl show -p ActiveState firewalld'
14:28:53 out: [2023-10-30T14:28:53+0000] DEBUG - CleanupModulesOnExit option is disabled in /etc/firewalld/firewalld.conf
14:28:53 out: Skipping the check as it is relevant only for Oracle Linux 8.8 and above.
14:28:53 out: CHECK_FIREWALLD_AVAILABILITY has succeeded
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just couple of nitpicks, we can discuss and revisit later @kokesak.
I wouldn't block the merge on this.
|
||
from envparse import env | ||
|
||
from convert2rhel.actions.system_checks.check_firewalld_availability import FIREWALLD_CONFIG_FILE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather see this hardcoded than imported TBH.
Verify that on the OL8.8 the conversion is inhibited due to | ||
running firewalld on the system and the `CleanupModulesOnExit` configuration | ||
option is set to `yes` in firewalld configuration file. | ||
The reference ticket: https://issues.redhat.com/browse/RHELC-1180 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify that on the OL8.8 the conversion is inhibited due to | |
running firewalld on the system and the `CleanupModulesOnExit` configuration | |
option is set to `yes` in firewalld configuration file. | |
The reference ticket: https://issues.redhat.com/browse/RHELC-1180 | |
Verify that on the OL8.8 the conversion is inhibited with the firewalld system unit | |
running on the system with the `CleanupModulesOnExit` configuration | |
option is set to `yes` in the firewalld configuration file. | |
The reference ticket: https://issues.redhat.com/browse/RHELC-1180 |
assert shell(f"grep 'CleanupModulesOnExit=yes' {FIREWALLD_CONFIG_FILE}").returncode == 0 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be tricky, I mean we have more or less the system under our control, but if for whatever reason the Oracle changes this, we won't match and the test will fail too soon.
I would either backup the original and provide our own config with the option disabled, or try regex matching more variants.
assert shell( | ||
"grep 'Firewalld running on Oracle Linux 8 can lead to a conversion failure' /var/log/convert2rhel/convert2rhel.log" | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be unnecessary since we check for the WARNING in the c2r runtime already.
@@ -0,0 +1,16 @@ | |||
summary: | | |||
Running conversion when firewalld is running and the proper configuration option is used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running conversion when firewalld is running and the proper configuration option is used. | |
Running firewalld remediation |
|
||
from envparse import env | ||
|
||
from convert2rhel.actions.system_checks.check_firewalld_availability import FIREWALLD_CONFIG_FILE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as in the other case, I would rather see this hardcoded than imported.
@pytest.mark.test_firewalld_config | ||
def test_firewalld_config_ol8(shell, convert2rhel): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pytest.mark.test_firewalld_config | |
def test_firewalld_config_ol8(shell, convert2rhel): | |
@pytest.mark.test_running_firewalld_remediation | |
def test_running_firewalld_remediation_ol8(shell, convert2rhel): |
if not os.path.exists(FIREWALLD_CONFIG_FILE): | ||
pytest.fail("Firewalld configuration file does not exist") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if not os.path.exists(FIREWALLD_CONFIG_FILE): | |
pytest.fail("Firewalld configuration file does not exist") | |
if not os.path.exists(FIREWALLD_CONFIG_FILE): | |
pytest.fail("Firewalld configuration file does not exist") |
This might come and bite us in the future.
Consider this being not so probable edge case, but if for whatever reason a new image will be provided without the config, the test will fail at this point providing no valid results.
Firewalld will fall back to a default option in case no config file is provided, that being CleanupModulesOnExit=yes
.
assert ( | ||
shell(f"sed -i 's/CleanupModulesOnExit=yes/CleanupModulesOnExit=no/g' {FIREWALLD_CONFIG_FILE}").returncode == 0 | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will fail if we fail to match CleanupModulesOnExit=yes
.
We might consider the suggestion from the other (non-destructive) test case. To provide and copy over our own config file and back up the existing one.
assert c2r.exitstatus == 0 | ||
|
||
# There should not be any problems | ||
assert shell("grep -i 'traceback' /var/log/convert2rhel/convert2rhel.log").returncode == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this is here.
If there would be a traceback, the c2r.exitstatus won't return 0.
On the other hand we might evaluate occurences of traceback in the logfile in one of the checks after conversion, which scans through the log file.
# config parser for firewalld as well: | ||
# https://github.com/firewalld/firewalld/blob/46d54dcbdff94423686d67befc78ca8d601fce60/src/firewall/core/io/firewalld_conf.py#L85 | ||
option_present = any( | ||
item.strip().startswith("CleanupModulesOnExit") for item in contents if not item.startswith(("#", ";")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ ipython
In [1]: lines = ["option", "#option"]
In [2]: for line in lines:
...: print(line.strip().startswith("option"))
True
False
This is what I meant. When the line starts with #
or ;
, the startswith("CleanupModulesOnExit") returns False.
" sed -i -- 's/CleanupModulesOnExit=yes/CleanupModulesOnExit=no/g' /etc/firewalld/firewalld.conf\n && firewall-cmd --reload." | ||
" You can change the option back to yes after the system reboot " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
" sed -i -- 's/CleanupModulesOnExit=yes/CleanupModulesOnExit=no/g' /etc/firewalld/firewalld.conf\n && firewall-cmd --reload." | |
" You can change the option back to yes after the system reboot " | |
" sed -i -- 's/^CleanupModulesOnExit.*/CleanupModulesOnExit=no/g' /etc/firewalld/firewalld.conf\n && firewall-cmd --reload\n" | |
"You can change the option back to yes after the system reboot " |
This is safer as it ignores the line if commented out (^
) and it replaces the line even when it's not exactly CleanupModulesOnExit=yes
because CleanupModulesOnExit = True
is legit as well.
This PR introduces a few cleanups that were made as comments in oamg#953. Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
This PR introduces a few cleanups that were made as comments in oamg#953. Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
This PR introduces a few cleanups that were made as comments in #953. Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Firewalld is having problems with the python-nftables package after we replace the packages in the system to their rhel counterparts. This commit introduces a way to check if firewalld is running and the CleanupModulesOnExit firewalld option is enabled, and if so, we ask the user to disable the option.
If firewalld is left running with the option on during the conversion, the user will see a set of errors happening in the systemctl logs for firewalld and they will be unable to ssh into the machine after the conversion is done.
Jira Issues: RHELC-1180
Checklist
[RHELC-]
is part of the PR titleRelease Pending
if relevant