mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-26 16:16:31 -06:00
Treat container subplatforms like main platform
ipa-server-upgrade does not like platform mismatches. Upgrade from an old container to recent container fails with error message: ``` IPA server upgrade failed: Inspect /var/log/ipaupgrade.log and run command ipa-server-upgrade manually. ("Unable to execute IPA upgrade: platform mismatch (expected 'fedora', current 'fedora_container')", 1) ``` Upgrade state now treats a container subplatform like its main platform. ``fedora_container`` is really a ``fedora`` platform with some paths redirected to ``/data`` partition. The patch also enhances debug logging for installer and upgrader. Related: https://pagure.io/freeipa/issue/8401 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
parent
e5c09675f3
commit
e89b400713
@ -28,6 +28,7 @@ import os
|
||||
import traceback
|
||||
from optparse import OptionGroup # pylint: disable=deprecated-module
|
||||
|
||||
from ipaplatform.osinfo import osinfo
|
||||
from ipapython import version
|
||||
from ipapython import config
|
||||
from ipapython.ipa_log_manager import standard_logging_setup
|
||||
@ -304,6 +305,8 @@ class AdminTool:
|
||||
logger.debug('%s was invoked with arguments %s and options: %s',
|
||||
self.command_name, self.args, self.safe_options)
|
||||
logger.debug('IPA version %s', version.VENDOR_VERSION)
|
||||
logger.debug('IPA platform %s', osinfo.platform)
|
||||
logger.debug('IPA os-release %s %s', osinfo.name, osinfo.version)
|
||||
|
||||
def log_failure(self, error_message, return_value, exception, backtrace):
|
||||
logger.debug('%s', ''.join(traceback.format_tb(backtrace)))
|
||||
|
@ -1054,13 +1054,26 @@ def load_external_cert(files, ca_subject):
|
||||
return cert_file, ca_file
|
||||
|
||||
|
||||
def get_current_platform():
|
||||
"""Get current platform (without container suffix)
|
||||
|
||||
'fedora' and 'fedora_container' are considered the same platform. This
|
||||
normalization ensures that older freeipa-container images can be upgraded
|
||||
without a platform mismatch.
|
||||
"""
|
||||
platform = ipaplatform.NAME
|
||||
if platform.endswith('_container'):
|
||||
platform = platform[:-10]
|
||||
return platform
|
||||
|
||||
|
||||
def store_version():
|
||||
"""Store current data version and platform. This is required for check if
|
||||
upgrade is required.
|
||||
"""
|
||||
sysupgrade.set_upgrade_state('ipa', 'data_version',
|
||||
version.VENDOR_VERSION)
|
||||
sysupgrade.set_upgrade_state('ipa', 'platform', ipaplatform.NAME)
|
||||
sysupgrade.set_upgrade_state('ipa', 'platform', get_current_platform())
|
||||
|
||||
|
||||
def check_version():
|
||||
@ -1070,12 +1083,14 @@ def check_version():
|
||||
:raise UpgradeDataNewerVersionError: older version of IPA was detected than data
|
||||
:raise UpgradeMissingVersionError: if platform or version is missing
|
||||
"""
|
||||
platform = sysupgrade.get_upgrade_state('ipa', 'platform')
|
||||
if platform is not None:
|
||||
if platform != ipaplatform.NAME:
|
||||
state_platform = sysupgrade.get_upgrade_state('ipa', 'platform')
|
||||
current_platform = get_current_platform()
|
||||
if state_platform is not None:
|
||||
if state_platform != current_platform:
|
||||
raise UpgradePlatformError(
|
||||
"platform mismatch (expected '%s', current '%s')" % (
|
||||
platform, ipaplatform.NAME)
|
||||
state_platform, current_platform
|
||||
)
|
||||
)
|
||||
else:
|
||||
raise UpgradeMissingVersionError("no platform stored")
|
||||
|
@ -140,3 +140,19 @@ def test_gpg_asymmetric(tempdir, gpgkey):
|
||||
assert os.path.isfile(src)
|
||||
with open(src) as f:
|
||||
assert f.read() == payload
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"platform, expected",
|
||||
[
|
||||
("fedora", "fedora"),
|
||||
("fedora_container", "fedora"),
|
||||
("fedora_containers", "fedora_containers"),
|
||||
("fedoracontainer", "fedoracontainer"),
|
||||
("rhel", "rhel"),
|
||||
("rhel_container", "rhel"),
|
||||
]
|
||||
)
|
||||
def test_get_current_platform(monkeypatch, platform, expected):
|
||||
monkeypatch.setattr(installutils.ipaplatform, "NAME", platform)
|
||||
assert installutils.get_current_platform() == expected
|
||||
|
Loading…
Reference in New Issue
Block a user