Merge "21.04 libraries freeze for charms on master branch"
This commit is contained in:
commit
548a675f5a
@ -1,4 +1,4 @@
|
||||
repo: https://github.com/juju/charm-helpers
|
||||
repo: https://github.com/juju/charm-helpers@stable/21.04
|
||||
destination: hooks/charmhelpers
|
||||
include:
|
||||
- core
|
||||
|
@ -28,6 +28,7 @@ import uuid
|
||||
import charmhelpers.contrib.openstack.policy_rcd as policy_rcd
|
||||
import charmhelpers.core.hookenv as hookenv
|
||||
import charmhelpers.core.host as host
|
||||
import charmhelpers.core.unitdata as unitdata
|
||||
|
||||
import subprocess
|
||||
|
||||
@ -361,3 +362,49 @@ def check_restart_timestamps():
|
||||
level='DEBUG')
|
||||
else:
|
||||
clear_deferred_restarts([event.service])
|
||||
|
||||
|
||||
def set_deferred_hook(hookname):
|
||||
"""Record that a hook has been deferred.
|
||||
|
||||
:param hookname: Name of hook that was deferred.
|
||||
:type hookname: str
|
||||
"""
|
||||
with unitdata.HookData()() as t:
|
||||
kv = t[0]
|
||||
deferred_hooks = kv.get('deferred-hooks', [])
|
||||
if hookname not in deferred_hooks:
|
||||
deferred_hooks.append(hookname)
|
||||
kv.set('deferred-hooks', sorted(list(set(deferred_hooks))))
|
||||
|
||||
|
||||
def get_deferred_hooks():
|
||||
"""Get a list of deferred hooks.
|
||||
|
||||
:returns: List of hook names.
|
||||
:rtype: List[str]
|
||||
"""
|
||||
with unitdata.HookData()() as t:
|
||||
kv = t[0]
|
||||
return kv.get('deferred-hooks', [])
|
||||
|
||||
|
||||
def clear_deferred_hooks():
|
||||
"""Clear any deferred hooks."""
|
||||
with unitdata.HookData()() as t:
|
||||
kv = t[0]
|
||||
kv.set('deferred-hooks', [])
|
||||
|
||||
|
||||
def clear_deferred_hook(hookname):
|
||||
"""Clear a specific deferred hooks.
|
||||
|
||||
:param hookname: Name of hook to remove.
|
||||
:type hookname: str
|
||||
"""
|
||||
with unitdata.HookData()() as t:
|
||||
kv = t[0]
|
||||
deferred_hooks = kv.get('deferred-hooks', [])
|
||||
if hookname in deferred_hooks:
|
||||
deferred_hooks.remove(hookname)
|
||||
kv.set('deferred-hooks', deferred_hooks)
|
||||
|
@ -151,6 +151,7 @@ OPENSTACK_RELEASES = (
|
||||
'train',
|
||||
'ussuri',
|
||||
'victoria',
|
||||
'wallaby',
|
||||
)
|
||||
|
||||
UBUNTU_OPENSTACK_RELEASE = OrderedDict([
|
||||
@ -173,6 +174,7 @@ UBUNTU_OPENSTACK_RELEASE = OrderedDict([
|
||||
('eoan', 'train'),
|
||||
('focal', 'ussuri'),
|
||||
('groovy', 'victoria'),
|
||||
('hirsute', 'wallaby'),
|
||||
])
|
||||
|
||||
|
||||
@ -196,6 +198,7 @@ OPENSTACK_CODENAMES = OrderedDict([
|
||||
('2019.2', 'train'),
|
||||
('2020.1', 'ussuri'),
|
||||
('2020.2', 'victoria'),
|
||||
('2021.1', 'wallaby'),
|
||||
])
|
||||
|
||||
# The ugly duckling - must list releases oldest to newest
|
||||
@ -304,8 +307,8 @@ PACKAGE_CODENAMES = {
|
||||
('14', 'rocky'),
|
||||
('15', 'stein'),
|
||||
('16', 'train'),
|
||||
('18', 'ussuri'),
|
||||
('19', 'victoria'),
|
||||
('18', 'ussuri'), # Note this was actually 17.0 - 18.3
|
||||
('19', 'victoria'), # Note this is really 18.6
|
||||
]),
|
||||
'ceilometer-common': OrderedDict([
|
||||
('5', 'liberty'),
|
||||
@ -1092,6 +1095,12 @@ def _determine_os_workload_status(
|
||||
svc_msg = "Services queued for restart: {}".format(
|
||||
', '.join(sorted(deferred_restarts)))
|
||||
message = "{}. {}".format(message, svc_msg)
|
||||
deferred_hooks = deferred_events.get_deferred_hooks()
|
||||
if deferred_hooks:
|
||||
svc_msg = "Hooks skipped due to disabled auto restarts: {}".format(
|
||||
', '.join(sorted(deferred_hooks)))
|
||||
message = "{}. {}".format(message, svc_msg)
|
||||
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
@ -1576,6 +1585,33 @@ def is_unit_paused_set():
|
||||
return False
|
||||
|
||||
|
||||
def is_hook_allowed(hookname, check_deferred_restarts=True):
|
||||
"""Check if hook can run.
|
||||
|
||||
:param hookname: Name of hook to check..
|
||||
:type hookname: str
|
||||
:param check_deferred_restarts: Whether to check deferred restarts.
|
||||
:type check_deferred_restarts: bool
|
||||
"""
|
||||
permitted = True
|
||||
reasons = []
|
||||
if is_unit_paused_set():
|
||||
reasons.append(
|
||||
"Unit is pause or upgrading. Skipping {}".format(hookname))
|
||||
permitted = False
|
||||
|
||||
if check_deferred_restarts:
|
||||
if deferred_events.is_restart_permitted():
|
||||
permitted = True
|
||||
deferred_events.clear_deferred_hook(hookname)
|
||||
else:
|
||||
if not config().changed('enable-auto-restarts'):
|
||||
deferred_events.set_deferred_hook(hookname)
|
||||
reasons.append("auto restarts are disabled")
|
||||
permitted = False
|
||||
return permitted, " and ".join(reasons)
|
||||
|
||||
|
||||
def manage_payload_services(action, services=None, charm_func=None):
|
||||
"""Run an action against all services.
|
||||
|
||||
@ -2627,14 +2663,17 @@ def restart_services_action_helper(all_services):
|
||||
restart_services_action(services=services)
|
||||
|
||||
|
||||
def show_deferred_restarts_action_helper():
|
||||
def show_deferred_events_action_helper():
|
||||
"""Helper to run the show-deferred-restarts action."""
|
||||
output = []
|
||||
restarts = []
|
||||
for event in deferred_events.get_deferred_events():
|
||||
output.append('{} {} {}'.format(
|
||||
restarts.append('{} {} {}'.format(
|
||||
str(event.timestamp),
|
||||
event.service.ljust(40),
|
||||
event.reason))
|
||||
output.sort()
|
||||
restarts.sort()
|
||||
output = {
|
||||
'restarts': restarts,
|
||||
'hooks': deferred_events.get_deferred_hooks()}
|
||||
action_set({'output': "{}".format(
|
||||
yaml.dump(output, default_flow_style=False))})
|
||||
|
@ -96,12 +96,14 @@ def cmp_pkgrevno(package, revno, pkgcache=None):
|
||||
the pkgcache argument is None. Be sure to add charmhelpers.fetch if
|
||||
you call this function, or pass an apt_pkg.Cache() instance.
|
||||
"""
|
||||
from charmhelpers.fetch import apt_pkg
|
||||
from charmhelpers.fetch import apt_pkg, get_installed_version
|
||||
if not pkgcache:
|
||||
from charmhelpers.fetch import apt_cache
|
||||
pkgcache = apt_cache()
|
||||
pkg = pkgcache[package]
|
||||
return apt_pkg.version_compare(pkg.current_ver.ver_str, revno)
|
||||
current_ver = get_installed_version(package)
|
||||
else:
|
||||
pkg = pkgcache[package]
|
||||
current_ver = pkg.current_ver
|
||||
|
||||
return apt_pkg.version_compare(current_ver.ver_str, revno)
|
||||
|
||||
|
||||
@cached
|
||||
|
@ -105,6 +105,7 @@ if __platform__ == "ubuntu":
|
||||
get_upstream_version = fetch.get_upstream_version
|
||||
apt_pkg = fetch.ubuntu_apt_pkg
|
||||
get_apt_dpkg_env = fetch.get_apt_dpkg_env
|
||||
get_installed_version = fetch.get_installed_version
|
||||
elif __platform__ == "centos":
|
||||
yum_search = fetch.yum_search
|
||||
|
||||
|
@ -200,6 +200,14 @@ CLOUD_ARCHIVE_POCKETS = {
|
||||
'victoria/proposed': 'focal-proposed/victoria',
|
||||
'focal-victoria/proposed': 'focal-proposed/victoria',
|
||||
'focal-proposed/victoria': 'focal-proposed/victoria',
|
||||
# Wallaby
|
||||
'wallaby': 'focal-updates/wallaby',
|
||||
'focal-wallaby': 'focal-updates/wallaby',
|
||||
'focal-wallaby/updates': 'focal-updates/wallaby',
|
||||
'focal-updates/wallaby': 'focal-updates/wallaby',
|
||||
'wallaby/proposed': 'focal-proposed/wallaby',
|
||||
'focal-wallaby/proposed': 'focal-proposed/wallaby',
|
||||
'focal-proposed/wallaby': 'focal-proposed/wallaby',
|
||||
}
|
||||
|
||||
|
||||
@ -831,6 +839,22 @@ def get_upstream_version(package):
|
||||
return ubuntu_apt_pkg.upstream_version(pkg.current_ver.ver_str)
|
||||
|
||||
|
||||
def get_installed_version(package):
|
||||
"""Determine installed version of a package
|
||||
|
||||
@returns None (if not installed) or the installed version as
|
||||
Version object
|
||||
"""
|
||||
cache = apt_cache()
|
||||
dpkg_result = cache._dpkg_list([package]).get(package, {})
|
||||
current_ver = None
|
||||
installed_version = dpkg_result.get('version')
|
||||
|
||||
if installed_version:
|
||||
current_ver = ubuntu_apt_pkg.Version({'ver_str': installed_version})
|
||||
return current_ver
|
||||
|
||||
|
||||
def get_apt_dpkg_env():
|
||||
"""Get environment suitable for execution of APT and DPKG tools.
|
||||
|
||||
|
@ -42,8 +42,8 @@ oslo.utils<=3.41.0;python_version<'3.6'
|
||||
|
||||
coverage>=4.5.2
|
||||
pyudev # for ceph-* charm unit tests (need to fix the ceph-* charm unit tests/mocking)
|
||||
git+https://github.com/openstack-charmers/zaza.git#egg=zaza;python_version>='3.0'
|
||||
git+https://github.com/openstack-charmers/zaza-openstack-tests.git#egg=zaza.openstack
|
||||
git+https://github.com/openstack-charmers/zaza.git@stable/21.04#egg=zaza;python_version>='3.0'
|
||||
git+https://github.com/openstack-charmers/zaza-openstack-tests.git@stable/21.04#egg=zaza.openstack
|
||||
|
||||
# Needed for charm-glance:
|
||||
git+https://opendev.org/openstack/tempest.git#egg=tempest;python_version>='3.6'
|
||||
|
Loading…
Reference in New Issue
Block a user