Skip to content

Commit

Permalink
Merge pull request #36 from plesk/nvizovitin-mariadb-upgrade-simulate…
Browse files Browse the repository at this point in the history
…-package-install-first-PAUX-6421

Simulate MariaDB upgrade before removing packages.
  • Loading branch information
vizovitin authored Oct 9, 2024
2 parents 789b9be + 034fa5e commit 1f04590
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions cloudlinux7to8/actions/mariadb.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ def _post_action(self) -> action.ActionResult:

mariadb_repo_id, _1, _2, _3, _4, _5 = [repo for repo in rpm.extract_repodata(repofiles[0])][0]

packages = ["MariaDB-client", "MariaDB-server"]
rpm.install_packages(packages, repository=mariadb_repo_id, simulate=True)
_remove_mariadb_packages()
rpm.install_packages(["MariaDB-client", "MariaDB-server"], repository=mariadb_repo_id)
rpm.install_packages(packages, repository=mariadb_repo_id)
return action.ActionResult()

def _revert_action(self) -> action.ActionResult:
Expand Down Expand Up @@ -142,8 +144,10 @@ def _post_action(self) -> action.ActionResult:
files.backup_file(repofile)
os.unlink(repofile)

packages = ["mariadb", "mariadb-server"]
rpm.install_packages(packages, simulate=True)
_remove_mariadb_packages()
rpm.install_packages(["mariadb", "mariadb-server"])
rpm.install_packages(packages)

# We should be sure mariadb is started, otherwise restore wouldn't work
util.logged_check_call(["/usr/bin/systemctl", "start", "mariadb"])
Expand Down Expand Up @@ -254,8 +258,9 @@ def _post_action(self) -> action.ActionResult:
mariadb_module = f"mariadb:cl-MariaDB{mariadb_version.major}{mariadb_version.minor}"
log.debug(f"Going to reinstall following packages with enabled dnf module {mariadb_module!r}: {mariadb_packages}")

rpm.remove_packages(rpm.filter_installed_packages(mariadb_packages))
util.logged_check_call(["dnf", "module", "-y", "enable", mariadb_module])
rpm.install_packages(mariadb_packages, simulate=True)
rpm.remove_packages(rpm.filter_installed_packages(mariadb_packages))
rpm.install_packages(mariadb_packages)

return action.ActionResult()
Expand Down
2 changes: 1 addition & 1 deletion dist-upgrader

0 comments on commit 1f04590

Please sign in to comment.