Skip to content

Commit

Permalink
Enable swift payload upgrades for wallaby+
Browse files Browse the repository at this point in the history
Sync charm-helpers to pick up fix for openstack_upgrade_available
that enables successful payload upgrades. This will need backporting
to stable/wallaby.

juju/charm-helpers#869
Closes-Bug: #2040606
Change-Id: Ib6c68845516ebaffe7759e2394ca284567076a74
  • Loading branch information
Corey Bryant committed Oct 31, 2023
1 parent 9725234 commit 157b5a2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
4 changes: 4 additions & 0 deletions charmhelpers/contrib/openstack/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,9 @@ def __init__(self, name=None, script=None, admin_script=None,

def __call__(self):
total_processes = _calculate_workers()
enable_wsgi_socket_rotation = config('wsgi-socket-rotation')
if enable_wsgi_socket_rotation is None:
enable_wsgi_socket_rotation = True
ctxt = {
"service_name": self.service_name,
"user": self.user,
Expand All @@ -1678,6 +1681,7 @@ def __call__(self):
"public_processes": int(math.ceil(self.public_process_weight *
total_processes)),
"threads": 1,
"wsgi_socket_rotation": enable_wsgi_socket_rotation,
}
return ctxt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Listen {{ admin_port }}
Listen {{ public_port }}
{% endif -%}

{% if wsgi_socket_rotation -%}
WSGISocketRotation On
{% else -%}
WSGISocketRotation Off
{% endif -%}

{% if port -%}
<VirtualHost *:{{ port }}>
WSGIDaemonProcess {{ service_name }} processes={{ processes }} threads={{ threads }} user={{ user }} group={{ group }} \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Listen {{ admin_port }}
Listen {{ public_port }}
{% endif -%}

{% if wsgi_socket_rotation -%}
WSGISocketRotation On
{% else -%}
WSGISocketRotation Off
{% endif -%}

{% if port -%}
<VirtualHost *:{{ port }}>
WSGIDaemonProcess {{ service_name }} processes={{ processes }} threads={{ threads }} user={{ user }} group={{ group }} \
Expand Down
23 changes: 4 additions & 19 deletions charmhelpers/contrib/openstack/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,17 +410,6 @@ def get_os_version_codename(codename, version_map=OPENSTACK_CODENAMES):
error_out(e)


def get_os_version_codename_swift(codename):
'''Determine OpenStack version number of swift from codename.'''
# for k, v in six.iteritems(SWIFT_CODENAMES):
for k, v in SWIFT_CODENAMES.items():
if k == codename:
return v[-1]
e = 'Could not derive swift version for '\
'codename: %s' % codename
error_out(e)


def get_swift_codename(version):
'''Determine OpenStack codename that corresponds to swift version.'''
codenames = [k for k, v in SWIFT_CODENAMES.items() if version in v]
Expand Down Expand Up @@ -841,14 +830,10 @@ def openstack_upgrade_available(package):
if not cur_vers:
# The package has not been installed yet do not attempt upgrade
return False
if "swift" in package:
codename = get_os_codename_install_source(src)
avail_vers = get_os_version_codename_swift(codename)
else:
try:
avail_vers = get_os_version_install_source(src)
except Exception:
avail_vers = cur_vers
try:
avail_vers = get_os_version_install_source(src)
except Exception:
avail_vers = cur_vers
apt.init()
return apt.version_compare(avail_vers, cur_vers) >= 1

Expand Down
2 changes: 1 addition & 1 deletion charmhelpers/fetch/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _snap_exec(commands):
:param commands: List commands
:return: Integer exit code
"""
assert type(commands) == list
assert type(commands) is list

retry_count = 0
return_code = None
Expand Down

0 comments on commit 157b5a2

Please sign in to comment.