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

Include retry install package logic in case of lock file is currently in use #5421

Merged
merged 3 commits into from
May 23, 2024

Conversation

Rebits
Copy link
Member

@Rebits Rebits commented May 22, 2024

Description

This PR adds lock-in-use errors to the list of known installation issues that trigger a retry during package installation. This enhancement aims to make our E2E tests more resilient to background upgrade processes.

Testing performed

Test Install Package retry lock

Test

import logging

from wazuh_testing.tools.system import HostManager
from threading import Thread


logger = logging.getLogger("5421Test")
logger.setLevel(logging.DEBUG)

hm = HostManager('nv.yaml')

hm.install_package('agent1', 'https://dl.grafana.com/oss/release/grafana-8.5.5-1.x86_64.rpm', system='centos')
hm.install_package('manager1', 'https://dl.grafana.com/oss/release/grafana_8.5.5_amd64.deb', system='ubuntu')

Preconditions

  • Hold the lock file in both hosts at the beginning of the test:

Manager1

# root@ip-172-31-15-71:/home/qa# apt remove firefox
# Reading package lists... Done
# Building dependency tree... Done
# Reading state information... Done
# The following packages will be REMOVED:
#   firefox
# 0 upgraded, 0 newly installed, 1 to remove and 331 not upgraded.
# After this operation, 261 kB disk space will be freed.
# Do you want to continue? [Y/n]

agent1

# ==============================================================================================
#  Package           Arch             Version                           Repository         Size
# ==============================================================================================
# Installing:
#  firefox           x86_64           115.10.0-1.el7.centos             updates           115 M

# Transaction Summary
# ==============================================================================================
# Install  1 Package

# Total download size: 115 M
# Installed size: 287 M
# Is this ok [y/d/N]:
  • In the middle of the test, when the first attemp fails, release the lock file

Results

python3 test_5421.py 
ERROR:root:Error installing https://dl.grafana.com/oss/release/grafana-8.5.5-1.x86_64.rpm in agent1: Retrying installation...
ERROR:root:Error installing https://dl.grafana.com/oss/release/grafana_8.5.5_amd64.deb in manager1: Retrying installation...

No RunTime Exception was raised. In addition, by checking manually remote hosts we can see that the provided package was installed correctly

[root@ip-172-31-15-33 qa]# yum list installed | grep grafana
grafana.x86_64                          8.5.5-1                       @/grafana-8.5.5-1.x86_64RXZq55
root@ip-172-31-15-71:/home/qa# apt list --installed| grep grafana

WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

grafana/now 8.5.5 amd64 [installed,local]

@Rebits Rebits self-assigned this May 22, 2024
@Rebits Rebits marked this pull request as ready for review May 22, 2024 16:23
rafabailon
rafabailon previously approved these changes May 23, 2024
Copy link
Member

@rafabailon rafabailon left a comment

Choose a reason for hiding this comment

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

LGTM

@juliamagan juliamagan merged commit aeed348 into 4.8.0 May 23, 2024
0 of 2 checks passed
@juliamagan juliamagan deleted the fix/5415-include-retry-install-package branch May 23, 2024 08:43
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.

Include install package retry logic in case of unable to acquire the dpkg frontend lock
3 participants