Correct package list post-upgrade

The list of packages to install post-upgrade was being retrieved
using the pre-upgrade OpenStack release version due to the
os_release function using a caches value.

This change syncs in charmhelpers which includes the reset_os_release
function to clear the cache. This charm now uses that function to
clear the cache after the dist-upgrade

Change-Id: I23f7af2b464c7e710423c15122c06bcea84e27a3
Closes-Bug: 1631897
This commit is contained in:
Liam Young 2016-10-10 12:34:58 +00:00
parent 19203bc59b
commit a5b680daa6
6 changed files with 30 additions and 19 deletions

View File

@ -156,7 +156,7 @@ class OpenStackAmuletDeployment(AmuletDeployment):
use_source = list(set( use_source = list(set(
use_source + ['mysql', 'mongodb', 'rabbitmq-server', 'ceph', use_source + ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
'ceph-osd', 'ceph-radosgw', 'ceph-mon', 'ceph-osd', 'ceph-radosgw', 'ceph-mon',
'ceph-proxy'])) 'ceph-proxy', 'percona-cluster', 'lxd']))
# Charms which can not use openstack-origin, ie. many subordinates # Charms which can not use openstack-origin, ie. many subordinates
no_origin = list(set( no_origin = list(set(

View File

@ -306,10 +306,8 @@ class OpenStackAmuletUtils(AmuletUtils):
password, tenant): password, tenant):
"""Authenticates admin user with cinder.""" """Authenticates admin user with cinder."""
# NOTE(beisner): cinder python client doesn't accept tokens. # NOTE(beisner): cinder python client doesn't accept tokens.
service_ip = \ keystone_ip = keystone_sentry.info['public-address']
keystone_sentry.relation('shared-db', ept = "http://{}:5000/v2.0".format(keystone_ip.strip().decode('utf-8'))
'mysql:shared-db')['private-address']
ept = "http://{}:5000/v2.0".format(service_ip.strip().decode('utf-8'))
return cinder_client.Client(username, password, tenant, ept) return cinder_client.Client(username, password, tenant, ept)
def authenticate_keystone_admin(self, keystone_sentry, user, password, def authenticate_keystone_admin(self, keystone_sentry, user, password,
@ -317,10 +315,9 @@ class OpenStackAmuletUtils(AmuletUtils):
keystone_ip=None): keystone_ip=None):
"""Authenticates admin user with the keystone admin endpoint.""" """Authenticates admin user with the keystone admin endpoint."""
self.log.debug('Authenticating keystone admin...') self.log.debug('Authenticating keystone admin...')
unit = keystone_sentry
if not keystone_ip: if not keystone_ip:
keystone_ip = unit.relation('shared-db', keystone_ip = keystone_sentry.info['public-address']
'mysql:shared-db')['private-address']
base_ep = "http://{}:35357".format(keystone_ip.strip().decode('utf-8')) base_ep = "http://{}:35357".format(keystone_ip.strip().decode('utf-8'))
if not api_version or api_version == 2: if not api_version or api_version == 2:
ep = base_ep + "/v2.0" ep = base_ep + "/v2.0"

View File

@ -229,6 +229,7 @@ GIT_DEFAULT_REPOS = {
GIT_DEFAULT_BRANCHES = { GIT_DEFAULT_BRANCHES = {
'liberty': 'stable/liberty', 'liberty': 'stable/liberty',
'mitaka': 'stable/mitaka', 'mitaka': 'stable/mitaka',
'newton': 'stable/newton',
'master': 'master', 'master': 'master',
} }
@ -409,14 +410,26 @@ def get_os_version_package(pkg, fatal=True):
os_rel = None os_rel = None
def os_release(package, base='essex'): def reset_os_release():
'''Unset the cached os_release version'''
global os_rel
os_rel = None
def os_release(package, base='essex', reset_cache=False):
''' '''
Returns OpenStack release codename from a cached global. Returns OpenStack release codename from a cached global.
If reset_cache then unset the cached os_release version and return the
freshly determined version.
If the codename can not be determined from either an installed package or If the codename can not be determined from either an installed package or
the installation source, the earliest release supported by the charm should the installation source, the earliest release supported by the charm should
be returned. be returned.
''' '''
global os_rel global os_rel
if reset_cache:
reset_os_release()
if os_rel: if os_rel:
return os_rel return os_rel
os_rel = (git_os_codename_install_source(config('openstack-origin-git')) or os_rel = (git_os_codename_install_source(config('openstack-origin-git')) or
@ -735,12 +748,12 @@ def git_os_codename_install_source(projects_yaml):
if projects in GIT_DEFAULT_BRANCHES.keys(): if projects in GIT_DEFAULT_BRANCHES.keys():
if projects == 'master': if projects == 'master':
return 'newton' return 'ocata'
return projects return projects
if 'release' in projects: if 'release' in projects:
if projects['release'] == 'master': if projects['release'] == 'master':
return 'newton' return 'ocata'
return projects['release'] return projects['release']
return None return None

View File

@ -54,6 +54,7 @@ from charmhelpers.contrib.openstack.utils import (
make_assess_status_func, make_assess_status_func,
os_release, os_release,
pause_unit, pause_unit,
reset_os_release,
resume_unit, resume_unit,
os_application_version_set, os_application_version_set,
) )
@ -807,6 +808,9 @@ def do_openstack_upgrade(configs):
apt_update(fatal=True) apt_update(fatal=True)
apt_upgrade(options=dpkg_opts, apt_upgrade(options=dpkg_opts,
fatal=True, dist=True) fatal=True, dist=True)
# The cached version of os_release will now be invalid as the pkg version
# should have changed during the upgrade.
reset_os_release()
apt_install(get_early_packages(), fatal=True) apt_install(get_early_packages(), fatal=True)
apt_install(get_packages(), fatal=True) apt_install(get_packages(), fatal=True)
configs.set_release(openstack_release=new_os_rel) configs.set_release(openstack_release=new_os_rel)

View File

@ -156,7 +156,7 @@ class OpenStackAmuletDeployment(AmuletDeployment):
use_source = list(set( use_source = list(set(
use_source + ['mysql', 'mongodb', 'rabbitmq-server', 'ceph', use_source + ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
'ceph-osd', 'ceph-radosgw', 'ceph-mon', 'ceph-osd', 'ceph-radosgw', 'ceph-mon',
'ceph-proxy'])) 'ceph-proxy', 'percona-cluster', 'lxd']))
# Charms which can not use openstack-origin, ie. many subordinates # Charms which can not use openstack-origin, ie. many subordinates
no_origin = list(set( no_origin = list(set(

View File

@ -306,10 +306,8 @@ class OpenStackAmuletUtils(AmuletUtils):
password, tenant): password, tenant):
"""Authenticates admin user with cinder.""" """Authenticates admin user with cinder."""
# NOTE(beisner): cinder python client doesn't accept tokens. # NOTE(beisner): cinder python client doesn't accept tokens.
service_ip = \ keystone_ip = keystone_sentry.info['public-address']
keystone_sentry.relation('shared-db', ept = "http://{}:5000/v2.0".format(keystone_ip.strip().decode('utf-8'))
'mysql:shared-db')['private-address']
ept = "http://{}:5000/v2.0".format(service_ip.strip().decode('utf-8'))
return cinder_client.Client(username, password, tenant, ept) return cinder_client.Client(username, password, tenant, ept)
def authenticate_keystone_admin(self, keystone_sentry, user, password, def authenticate_keystone_admin(self, keystone_sentry, user, password,
@ -317,10 +315,9 @@ class OpenStackAmuletUtils(AmuletUtils):
keystone_ip=None): keystone_ip=None):
"""Authenticates admin user with the keystone admin endpoint.""" """Authenticates admin user with the keystone admin endpoint."""
self.log.debug('Authenticating keystone admin...') self.log.debug('Authenticating keystone admin...')
unit = keystone_sentry
if not keystone_ip: if not keystone_ip:
keystone_ip = unit.relation('shared-db', keystone_ip = keystone_sentry.info['public-address']
'mysql:shared-db')['private-address']
base_ep = "http://{}:35357".format(keystone_ip.strip().decode('utf-8')) base_ep = "http://{}:35357".format(keystone_ip.strip().decode('utf-8'))
if not api_version or api_version == 2: if not api_version or api_version == 2:
ep = base_ep + "/v2.0" ep = base_ep + "/v2.0"