Skip to content
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-16] Do not disable RHSM repos before pkg backup #627

Merged

Conversation

hosekadam
Copy link
Member

There is a problem with backing up the packages on systems which use satellite server. During the conversion is system unregistered from previous subscription - in that step we lose access to the CentOS repositories. And then we need to backup packages, which could come from CentOS.

So the step with backup and remove the package is moved before the unregistration. With that show up another problem - the backed up and then removed package remove os-release file too. The file is needed for subscribing the system, so it is restored from backup and then removed (if it won't be removed, the file would stay there after conversion as os-release.rpmorig)

Jira Issue: RHELC-16

Checklist

  • PR meets acceptance criteria specified in the Jira issue
  • PR has been tested manually in a VM (either author or reviewer)
  • Jira issue has been made public if possible
  • [RHELC-] is part of the PR title
  • Code and tests are documented properly
  • The commits are squashed to as few commits as possible (without losing data)
  • When merged: Jira issue has been updated to Release Pending

@codecov
Copy link

codecov bot commented Oct 10, 2022

Codecov Report

Base: 93.47% // Head: 93.57% // Increases project coverage by +0.09% 🎉

Coverage data is based on head (994d3dc) compared to base (8bd5beb).
Patch coverage: 90.47% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #627      +/-   ##
==========================================
+ Coverage   93.47%   93.57%   +0.09%     
==========================================
  Files          22       22              
  Lines        3188     3222      +34     
  Branches      568      575       +7     
==========================================
+ Hits         2980     3015      +35     
+ Misses        146      142       -4     
- Partials       62       65       +3     
Flag Coverage Δ
centos-linux-6 89.94% <83.33%> (+0.10%) ⬆️
centos-linux-7 89.42% <83.33%> (+0.11%) ⬆️
centos-linux-8 89.58% <83.33%> (+0.11%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
convert2rhel/main.py 91.82% <66.66%> (-0.59%) ⬇️
convert2rhel/backup.py 98.98% <84.61%> (-1.02%) ⬇️
convert2rhel/subscription.py 94.10% <93.33%> (+1.05%) ⬆️
convert2rhel/systeminfo.py 97.23% <100.00%> (+0.14%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

convert2rhel/subscription.py Outdated Show resolved Hide resolved
convert2rhel/main.py Outdated Show resolved Hide resolved
convert2rhel/backup.py Show resolved Hide resolved
@hosekadam hosekadam force-pushed the do-not-disable-rhsm-repos-before-pkg-backup branch 2 times, most recently from d4290ed to 436b8a8 Compare October 26, 2022 15:47
@hosekadam hosekadam force-pushed the do-not-disable-rhsm-repos-before-pkg-backup branch from 436b8a8 to ad30c15 Compare November 3, 2022 15:42
@hosekadam
Copy link
Member Author

Rebased, conflict solved

convert2rhel/backup.py Outdated Show resolved Hide resolved
convert2rhel/backup.py Outdated Show resolved Hide resolved
@hosekadam hosekadam force-pushed the do-not-disable-rhsm-repos-before-pkg-backup branch from ad30c15 to 0fd2d2c Compare November 4, 2022 14:19
Venefilyn
Venefilyn previously approved these changes Nov 9, 2022
@hosekadam
Copy link
Member Author

Heh, I used probably a wrong command and I see there is a bit mess...

@r0x0d r0x0d force-pushed the do-not-disable-rhsm-repos-before-pkg-backup branch from 328d550 to 8bda952 Compare November 11, 2022 17:07
@hosekadam
Copy link
Member Author

hosekadam commented Nov 14, 2022

There are few things left that needs to be done to get the integration test running properly:

  1. Merge this merge request
  2. In the satellite repo for CentOS7 is the old version of kernel, so we need to wait to sync the repositories

Otherwise the test works just for the CentOS 7 so I think I should limit that just for this system and not to run it with others. The second variant is to ask satellite guys to provide servers that we need for another systems. What do you think @SpyTec or @r0x0d?

@r0x0d
Copy link
Member

r0x0d commented Nov 14, 2022

There are few things left that needs to be done to get the integration test running properly:

1. Merge this [merge request](https://gitlab.cee.redhat.com/oamg/convert2rhel/convert2rhel-secrets/-/merge_requests/9)

2. In the satellite repo for CentOS7 is the old version of kernel, so we need to wait to sync the repositories

Otherwise the test works just for the CentOS 7 so I think I should limit that just for this system and not to run it with others. The second variant is to ask satellite guys to provide servers that we need for another systems. What do you think @SpyTec or @r0x0d?

@hosekadam ping @kokesak to merge your PR. I don't have write access to that repository.

I don't know how the satellite guys would react if we ask them for more servers for the other distros we use… Furthermore, I don't know if @SpyTec or @bocekm knows how that works, if so, can any of you help us here?

As far as limiting the test to CentOS 7, I think it's a good idea if your test is only related to CentOS 7 and not anything else... But looking at your PR, I see that you changed the preparation of one test that runs under all distros to use the activation key for CentOS 7 you created, is that supposed to like that?

@hosekadam
Copy link
Member Author

@r0x0d I had a discussion with @kokesak and we agreed on, that this test is the case we need. As you can see, I've removed the variables for unsupported conversion and the reproducer for this task is the same as the case, we were testing there.

@@ -26,7 +26,7 @@
logging.basicConfig(level="DEBUG" if env.str("DEBUG") else "INFO", stream=sys.stderr)
logger = logging.getLogger(__name__)

SATELLITE_URL = "satellite.sat.engineering.redhat.com"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are actually trying to use the new satellite URL (https://issues.redhat.com/browse/RHELC-732). The dogfood is going to be removed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I see. But if you register the system using subscription-manager to get the CentOS 7 satellite server, there are still urls to the dogfood in /etc/yum.repos.d/redhat.repo. Maybe adding both of them, so once it would be finally changed, nothing breaks and just be needed to remove the dogfood url from /etc/dnsmasq.conf?

@kokesak
Copy link
Member

kokesak commented Nov 14, 2022

The test was running for all distros so I would keep that.

IIUC, it's the offline-conversion test in which we currently use the env variables to omit bug this PR fixes. However, we need centos and oracle content in the satellite server, currently, we have just centos7 right?. Is this fix going to be in the next release?

I would rather have it tested on all distros before merging.

@hosekadam
Copy link
Member Author

@kokesak yes, I see there that there is available satellite just for CentOS 7 (and Centos 8 Stream, but it's useless for us I think).

And this PR should be in the next release (from Jira).

@danmyway
Copy link
Member

/packit test

# Need to remove the file, if it would stay there would be leftover /etc/os-release.rpmorig
# after conversion
# RHELC-16
os_release_file.remove()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part feels a little unclean but we can fix it in the next release. I've written up what's unclean about it and how we can fix it later here: https://issues.redhat.com/browse/RHELC-809

Comment on lines +183 to +191
# The file /etc/os-release is needed for subscribing the system and is being removed with
# <system-name>-release package in one of the steps before
# RHELC-16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# The file /etc/os-release is needed for subscribing the system and is being removed with
# <system-name>-release package in one of the steps before
# RHELC-16
# The file /etc/os-release is needed for subscribing the system and is being removed with
# <system-name>-release package in one of the previous steps:
# Fixes RHELC-16
#
# This code should be cleaned up in the future. See https://issues.redhat.com/browse/RHELC-809
# for what should be done.

@danmyway
Copy link
Member

/packit test

@kokesak
Copy link
Member

kokesak commented Nov 21, 2022

On centos7 it seems that the satellite repos do not have the kernel we update to during the update system phase:

22:17:29         out: CRITICAL - The version of the loaded kernel is different from the latest version in the enabled system repositories.
22:17:29         out:  Latest kernel version available in Satellite_Engineering_CentOS_7_Updates_x86_64: 3.10.0-1160.76.1.el7
22:17:29         out:  Loaded kernel version: 3.10.0-1160.80.1.el7
22:17:29         out: 
22:17:29         out: To proceed with the conversion, update the kernel version by executing the following step:
22:17:29         out: 
22:17:29         out: 1. yum install kernel-3.10.0-1160.76.1.el7 -y
22:17:29         out: 2. reboot
22:17:29         out: [11/18/2022 17:17:29] DEBUG - Traceback (most recent call last):
22:17:29         out:   File "/usr/lib/python2.7/site-packages/convert2rhel/main.py", line 101, in main
22:17:29         out:     checks.perform_system_checks()
22:17:29         out:   File "/usr/lib/python2.7/site-packages/convert2rhel/checks.py", line 127, in perform_system_checks
22:17:29         out:     is_loaded_kernel_latest()
22:17:29         out:   File "/usr/lib/python2.7/site-packages/convert2rhel/checks.py", line 780, in is_loaded_kernel_latest
22:17:29         out:     "2. reboot" % (repos_message, repoid, latest_kernel, loaded_kernel, package_to_check, latest_kernel)
22:17:29         out:   File "/usr/lib/python2.7/site-packages/convert2rhel/logger.py", line 195, in _critical
22:17:29         out:     sys.exit(msg)
22:17:29         out: SystemExit: The version of the loaded kernel is different from the latest version in the enabled system repositories.
22:17:29         out:  Latest kernel version available in Satellite_Engineering_CentOS_7_Updates_x86_64: 3.10.0-1160.76.1.el7
22:17:29         out:  Loaded kernel version: 3.10.0-1160.80.1.el7
22:17:29         out: 
22:17:29         out: To proceed with the conversion, update the kernel version by executing the following step:
22:17:29         out: 
22:17:29         out: 1. yum install kernel-3.10.0-1160.76.1.el7 -y
22:17:29         out: 2. reboot

@hosekadam
Copy link
Member Author

@kokesak Yes, I've mentioned this problem in the comment :D Do you know somebody who we can contact to help us with that? I thought, they (who prepared the satellite server) have some automated way to stay updated with the original repositories.

When I was testing that, I used the older version of vagrant box and removed the update step from ansible setup.

@hosekadam hosekadam force-pushed the do-not-disable-rhsm-repos-before-pkg-backup branch 2 times, most recently from f974d0b to 42a80d7 Compare November 23, 2022 15:42
@kokesak kokesak force-pushed the do-not-disable-rhsm-repos-before-pkg-backup branch from 42a80d7 to d1eef72 Compare November 24, 2022 10:05
@kokesak
Copy link
Member

kokesak commented Nov 24, 2022

Hmm, seem that passing the the env var CONVERT2RHEL_UNSUPPORTED_SKIP_KERNEL_CURRENCY_CHECK did not work. I think I will need to make some other workaround, though it's weird that this envar is ommited

@kokesak kokesak force-pushed the do-not-disable-rhsm-repos-before-pkg-backup branch from 5e90827 to e683f85 Compare November 25, 2022 09:04
convert2rhel/subscription.py Fixed Show fixed Hide fixed
convert2rhel/systeminfo.py Fixed Show fixed Hide fixed
We had to do a workaround around the get_avail_subs function to place a
releasever file in /etc/dnf/vars for it to work again.

Signed-off-by: Rodolfo Olivieri <[email protected]>
@r0x0d r0x0d force-pushed the do-not-disable-rhsm-repos-before-pkg-backup branch from ff72fd4 to cc7cc06 Compare November 25, 2022 18:25
@@ -26,11 +26,11 @@
import pytest
import six

from convert2rhel import logger, systeminfo, unit_tests, utils # Imports unit_tests/__init__.py
from convert2rhel import logger, pkgmanager, systeminfo, unit_tests, utils # Imports unit_tests/__init__.py

Check notice

Code scanning / CodeQL

Unused import

Import of 'pkgmanager' is not used.
@kokesak
Copy link
Member

kokesak commented Nov 28, 2022

/packit test

@kokesak
Copy link
Member

kokesak commented Nov 28, 2022

/packit build

1 similar comment
@r0x0d
Copy link
Member

r0x0d commented Nov 28, 2022

/packit build

@kokesak
Copy link
Member

kokesak commented Nov 28, 2022

/packit build

@kokesak kokesak requested review from r0x0d and danmyway November 29, 2022 14:08
Copy link
Member

@danmyway danmyway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of minor changes, we can sort this out with another PR.

Comment on lines +239 to +244
- name: workaround_kernel
how: shell
script: "yum install kernel-3.10.0-1160.76.1.el7 -y && yum remove kernel-3.10.0-1160.80.1.el7 -y"
- name: reboot machine
how: ansible
playbook: tests/ansible_collections/roles/reboot/main.yml
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to reboot?
Wouldn't grubby --set-default-kernel be sufficient?
I would probably add some comment about the kernel workaround being temporary.
Or a #TODO to remove it, when the repository gets synced over at Satellite.
But I guess for the sake of saving some time, we can also keep it as is.

Copy link
Member

@kokesak kokesak Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reboot is needed I believe as the c2r check is done against the running kernel which changes only after reboot.

Comment on lines +1 to +3
summary: |
Convert systems that have no access to the Internet. This test require having the repositories of original
distro available in the satellite server. As of now we only have CentOS7 repositories available.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary should be shorter, 50 characters if possible.
Description can be longer.
But we can fix this whenever.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created a Jira issue for this so we can tackle all the missing stuff in future fix and not block current PR.
Link to the Jira: https://issues.redhat.com/browse/RHELC-824

@Venefilyn Venefilyn merged commit 46a2cf9 into oamg:main Nov 30, 2022
@Venefilyn Venefilyn mentioned this pull request Nov 30, 2022
abadger pushed a commit to Andrew-ang9/convert2rhel that referenced this pull request Dec 7, 2022
Venefilyn pushed a commit that referenced this pull request Jun 19, 2023
Co-authored-by: Rodolfo Olivieri <[email protected]>
Co-authored-by: Martin Litwora <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants