Skip to content

Commit

Permalink
[RHELC-1629] hotfix/Fix provisioning of CentOS images (#1290)
Browse files Browse the repository at this point in the history
* Fix provisioning of CentOS images

* TF probably made some changes in the repofiles, so the provisioning
  now fails with duplicate baseurl entry
* additionally extras repo is left unchanged causing the yum calls to
  fail
* comment out all baseurl and mirrorlist options, leave just valid vault
  baseurl uncommented
* fix the failing cve test
* fix the extras repo for centos 7 playbook

* Remove add-extras-repo role
* the extras repo is defined already in the repofiles on the systems we
  use
* Mitigate repo url changed to default

* in rare cases the repofiles might get restored to its original state
  pointing the url back to mirrorlist
* add an autouse fixture pointing back to vault

Signed-off-by: Daniel Diblik <[email protected]>

---------

Signed-off-by: Daniel Diblik <[email protected]>
  • Loading branch information
danmyway authored Jul 10, 2024
1 parent 8c68f6c commit 52054d3
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .packit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
# For some targets we use official AWS marketplace images, those do not support root ssh login as default,
# therefore we need to pass post-install-script to enable root login on the host
# Additionally we rewrite the URLs in the repofiles to point to the vault, given CentOS(Stream) 8 is EOL
tf_post_install_script: '#!/bin/bash\nsudo sed -i "s/^.*ssh-rsa/ssh-rsa/" /root/.ssh/authorized_keys; sed -i -e "s|^\(mirrorlist=.*\)|#\1|" -e "s|^#baseurl=http://mirror\(.*\)|baseurl=http://vault\1|" /etc/yum.repos.d/CentOS-Linux-*.repo'
tf_post_install_script: '#!/bin/bash\nsudo sed -i "s/^.*ssh-rsa/ssh-rsa/" /root/.ssh/authorized_keys; sed -i -e "s|^\(mirrorlist=.*\)|#\1|" -e "s|^baseurl=\(.*\)|#baseurl=\1|" -e "s|^#baseurl=http://mirror\(.*\)|baseurl=http://vault\1|" /etc/yum.repos.d/CentOS-*'
tf_extra_params:
environments:
- settings:
Expand Down
3 changes: 0 additions & 3 deletions plans/stream.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ adjust+:
script: pytest --setup-show -svv tests/integration/*/destructive/single-yum-transaction/install_multilib_packages.py
/yum_distro_sync:
prepare+:
- name: enable CentOS' extras repo
how: ansible
playbook: tests/integration/tier0/destructive/yum-distro-sync/add-extras-repo/main.yml
- name: Install problematic package
how: shell
script: pytest --setup-show -svv tests/integration/*/destructive/yum-distro-sync/install_problematic_package.py
Expand Down
3 changes: 0 additions & 3 deletions plans/tier0.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ adjust+:

/yum_distro_sync:
prepare+:
- name: enable CentOS' extras repo
how: ansible
playbook: tests/integration/tier0/destructive/yum-distro-sync/add-extras-repo/main.yml
- name: Install problematic package
how: shell
script: pytest --setup-show -svv tests/integration/*/destructive/yum-distro-sync/install_problematic_package.py
Expand Down
16 changes: 16 additions & 0 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ def missing_os_release_package_workaround(shell):

# Since we try to mitigate any damage caused by the incomplete rollback
# try to update the system, in case anything got downgraded
print("TESTS >>> Updating the system.")
shell("yum update -y", silent=True)


Expand Down Expand Up @@ -944,3 +945,18 @@ def workaround_remove_uek():
subprocess.run(["yum", "remove", "-y", "kernel-uek"], check=False)

yield


@pytest.fixture(autouse=True)
def keep_centos_pointed_to_vault(shell):
"""
Fixture.
In some rare cases we (re)install the centos-release package.
This overwrites the repofiles to its default state using mirrorlist instead of vault
which won't work since the EOL.
Make sure the repositories are pointed to the vault to keep the system usable.
"""
if "C2R_TESTS_NONDESTRUCTIVE" in os.environ and "centos" in SystemInformationRelease.distribution:
sed_repos_to_vault = 'sed -i -e "s|^\(mirrorlist=.*\)|#\1|" -e "s|^#baseurl=http://mirror\(.*\)|baseurl=http://vault\1|" /etc/yum.repos.d/CentOS-*'
print("TESTS >>> Resetting the repos to vault")
shell(sed_repos_to_vault, silent=True)

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,8 @@ def test_rhsm_error_logged(convert2rhel):
# We just need to make sure the file does not exist.
pass

# Now trigger a rollback, so we can see if it handles the missing
# certificate
c2r.sendcontrol("c")

assert c2r.exitstatus == 1
# Let the conversion fail on the subscription-manager register call
assert c2r.exitstatus == 2

# Verify the error message is not present in the log file
with open("/var/log/convert2rhel/convert2rhel.log", "r") as logfile:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ def watchdog():
"""
while True:
for process in psutil.process_iter():
# For some reason the psutil catches subscription-manager in process.name()
# as 'subscription-ma', thus using 'subscription' to catch it
if "subscription" in process.name():
return process.cmdline()
try:
# For some reason the psutil catches subscription-manager in process.name()
# as 'subscription-ma', thus using 'subscription' to catch it
if "subscription" in process.name():
return process.cmdline()
# psutil might raise an exception when trying to reach an already exited process
# continue the loop when this happens
except psutil.NoSuchProcess:
continue


@pytest.mark.test_passing_password_to_submgr
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
},
"oracle-7": {
"original_kernel": ORIGINAL_KERNEL,
"custom_kernel": "http://mirror.centos.org/centos/7/os/x86_64/Packages/kernel-3.10.0-1160.el7.x86_64.rpm",
"custom_kernel": "http://vault.centos.org/centos/7/os/x86_64/Packages/kernel-3.10.0-1160.el7.x86_64.rpm",
"grub_substring": "Oracle Linux Server 7.9, with Linux 3.10.0-1160.el7.x86_64",
},
# Install CentOS 8.5 kernel
Expand Down

0 comments on commit 52054d3

Please sign in to comment.