From what I can tell, /etc/openstack-release is used in juju charm-helpers, and
zaza-openstack-tests from openstack-charmers. It doesn't seem to be anywhere
else.

Charm helpers:

https://github.com/juju/charm-
helpers/blob/master/charmhelpers/contrib/openstack/utils.py#L582

def get_installed_os_version():
    """Determine the OpenStack release code name from openstack-release pkg.

    This uses the "openstack-release" pkg (if it exists) to return the
    OpenStack release codename (e.g. usurri, mitaka, ocata, etc.)

    Note, it caches the result so that it is only done once per hook.

    :returns: the OpenStack release codename, if available
    :rtype: Optional[str]
    """
    @cached
    def _do_install():
        apt_install(filter_installed_packages(['openstack-release']),
                    fatal=False, quiet=True)

    _do_install()
    return openstack_release().get('OPENSTACK_CODENAME')

def openstack_release():
    """Return /etc/os-release in a dict."""
    d = {}
    try:
        with open('/etc/openstack-release', 'r') as lsb:
            for l in lsb:
                s = l.split('=')
                if len(s) != 2:
                    continue
                d[s[0].strip()] = s[1].strip()
    except FileNotFoundError:
        pass
    return d

I think charmhelpers uses this information to determine what API versions are
active and maybe if any upgrade hooks need to execute.

Zaza tests:

https://github.com/openstack-charmers/zaza-openstack-
tests/blob/2b040ba790c1a0b69f4773653d22a605d0d51e5e/zaza/openstack/utilities/openstack.py#L1975

def get_openstack_release(application, model_name=None):
    """Return the openstack release codename based on /etc/openstack-release.

    This will only return a codename if the openstack-release package is
    installed on the unit.

    :param application: Application name
    :type application: string
    :param model_name: Name of model to query.
    :type model_name: str
    :returns: OpenStack release codename for application
    :rtype: string
    """
    versions = []
    units = model.get_units(application, model_name=model_name)
    for unit in units:
        cmd = 'cat /etc/openstack-release | grep OPENSTACK_CODENAME'
        try:
            out = juju_utils.remote_run(unit.entity_id, cmd,
                                        model_name=model_name)
        except model.CommandRunFailed:
            logging.debug('Fall back to version check for OpenStack codename')
        else:
            codename = out.split('=')[1].strip()
            versions.append(codename)
    if len(set(versions)) == 0:
        return None
    elif len(set(versions)) > 1:
        raise Exception('Unexpected mix of OpenStack releases for {}: {}',
                        application, versions)
    return versions[0]


def get_current_os_versions(deployed_applications, model_name=None):
    """Determine OpenStack codename of deployed applications.

    Initially, see if the openstack-release pkg is available and use it
    instead.

    If it isn't then it falls back to the existing method of checking the
    version of the package passed and then resolving the version from that
    using lookup tables.

    :param deployed_applications: List of deployed applications
    :type deployed_applications: list
    :param model_name: Name of model to query.
    :type model_name: str
    :returns: List of aplication to codenames dictionaries
    :rtype: list
    """
    versions = {}
    for application in UPGRADE_SERVICES:
        if application['name'] not in deployed_applications:
            continue
        logging.info("looking at application: {}".format(application))

        codename = get_openstack_release(application['name'],
                                         model_name=model_name)
        if codename:
            versions[application['name']] = codename
        else:
            version = generic_utils.get_pkg_version(application['name'],
                                                    application['type']['pkg'],
                                                    model_name=model_name)
            versions[application['name']] = (
                get_os_code_info(application['type']['pkg'], version))
    return versions

def get_current_os_release_pair(application='keystone'):
    """Return OpenStack Release pair name.

    :param application: Name of application
    :type application: string
    :returns: Name of the OpenStack release pair
    :rtype: str
    :raises: exceptions.ApplicationNotFound
    :raises: exceptions.SeriesNotFound
    :raises: exceptions.OSVersionNotFound
    """
    try:
        machine = list(juju_utils.get_machines_for_application(application))[0]
    except IndexError:
        raise exceptions.ApplicationNotFound(application)

    series = juju_utils.get_machine_series(machine)
    if not series:
        raise exceptions.SeriesNotFound()

    os_version = get_current_os_versions([application]).get(application)
    if not os_version:
        raise exceptions.OSVersionNotFound()

    return '{}_{}'.format(series, os_version)

def get_os_release(release_pair=None, application='keystone'):
    """Return index of release in OPENSTACK_RELEASES_PAIRS.

    :param release_pair: OpenStack release pair eg 'focal_ussuri'
    :type release_pair: string
    :param application: Name of application to derive release pair from.
    :type application: string
    :returns: Index of the release
    :rtype: int
    :raises: exceptions.ReleasePairNotFound
    """
    if release_pair is None:
        release_pair = get_current_os_release_pair(application=application)
    try:
        index = OPENSTACK_RELEASES_PAIRS.index(release_pair)
    except ValueError:
        msg = 'Release pair: {} not found in {}'.format(
            release_pair,
            OPENSTACK_RELEASES_PAIRS
        )
        raise exceptions.ReleasePairNotFound(msg)
    return index

I suppose if your VM units had differing versions from having a mix of old and
new openstack-release packages installed, you could get 
exceptions.ReleasePairNotFound.

The zaza tests seem to use /etc/openstack-release to gate what asserts are
enabled and what tests are executed. So, by going from flamingo to gazpacho you
might get additional tests running from before, and possibly new failures.

All of these things happen at cluster deployment time, or testing new packages
locally before they are uploaded etc, so the risk seems fairly low for deployed
clusters. They all seem to be closely coupled to charmed openstack too, and not
sunbeam, which is what resolute will run.

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2158020

Title:
  [SRU] Gazpacho release in Resolute

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/openstack-release/+bug/2158020/+subscriptions


-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to