Charmhelpers sync stable/zed

Using "make sync".

Change-Id: If5a57cf7ac2e07b245a4cd877b2b86c382e69e6b
This commit is contained in:
Rodrigo Barbieri 2024-02-06 12:36:58 -03:00
parent a2f0cd9ec7
commit f3e70f4b2e
7 changed files with 48 additions and 34 deletions

View File

@ -414,18 +414,27 @@ def get_requests_for_local_unit(relation_name=None):
is_legacy_request = set(sent).intersection(legacy_keys) is_legacy_request = set(sent).intersection(legacy_keys)
for unit in related_units(rid): for unit in related_units(rid):
data = relation_get(rid=rid, unit=unit) data = relation_get(rid=rid, unit=unit)
if data.get(raw_certs_key): # Note: Bug#2028683 - data may not be available if the certificates
bundles.append({ # relation hasn't been populated by the providing charm. If no 'ca'
'ca': data['ca'], # in the data then don't attempt the bundle at all.
'chain': data.get('chain'), if data.get('ca'):
'certs': json.loads(data[raw_certs_key])}) if data.get(raw_certs_key):
elif is_legacy_request: bundles.append({
bundles.append({ 'ca': data['ca'],
'ca': data['ca'], 'chain': data.get('chain'),
'chain': data.get('chain'), 'certs': json.loads(data[raw_certs_key])
'certs': {sent['common_name']: })
{'cert': data.get(local_name + '.server.cert'), elif is_legacy_request:
'key': data.get(local_name + '.server.key')}}}) bundles.append({
'ca': data['ca'],
'chain': data.get('chain'),
'certs': {
sent['common_name']: {
'cert': data.get(local_name + '.server.cert'),
'key': data.get(local_name + '.server.key')
}
}
})
return bundles return bundles

View File

@ -1748,6 +1748,9 @@ class WSGIWorkerConfigContext(WorkerConfigContext):
def __call__(self): def __call__(self):
total_processes = _calculate_workers() 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 = { ctxt = {
"service_name": self.service_name, "service_name": self.service_name,
"user": self.user, "user": self.user,
@ -1761,6 +1764,7 @@ class WSGIWorkerConfigContext(WorkerConfigContext):
"public_processes": int(math.ceil(self.public_process_weight * "public_processes": int(math.ceil(self.public_process_weight *
total_processes)), total_processes)),
"threads": 1, "threads": 1,
"wsgi_socket_rotation": enable_wsgi_socket_rotation,
} }
return ctxt return ctxt

View File

@ -12,6 +12,12 @@ Listen {{ admin_port }}
Listen {{ public_port }} Listen {{ public_port }}
{% endif -%} {% endif -%}
{% if wsgi_socket_rotation -%}
WSGISocketRotation On
{% else -%}
WSGISocketRotation Off
{% endif -%}
{% if port -%} {% if port -%}
<VirtualHost *:{{ port }}> <VirtualHost *:{{ port }}>
WSGIDaemonProcess {{ service_name }} processes={{ processes }} threads={{ threads }} user={{ user }} group={{ group }} \ WSGIDaemonProcess {{ service_name }} processes={{ processes }} threads={{ threads }} user={{ user }} group={{ group }} \

View File

@ -12,6 +12,12 @@ Listen {{ admin_port }}
Listen {{ public_port }} Listen {{ public_port }}
{% endif -%} {% endif -%}
{% if wsgi_socket_rotation -%}
WSGISocketRotation On
{% else -%}
WSGISocketRotation Off
{% endif -%}
{% if port -%} {% if port -%}
<VirtualHost *:{{ port }}> <VirtualHost *:{{ port }}>
WSGIDaemonProcess {{ service_name }} processes={{ processes }} threads={{ threads }} user={{ user }} group={{ group }} \ WSGIDaemonProcess {{ service_name }} processes={{ processes }} threads={{ threads }} user={{ user }} group={{ group }} \

View File

@ -414,17 +414,6 @@ def get_os_version_codename(codename, version_map=OPENSTACK_CODENAMES,
error_out(e) 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): def get_swift_codename(version):
'''Determine OpenStack codename that corresponds to swift version.''' '''Determine OpenStack codename that corresponds to swift version.'''
codenames = [k for k, v in SWIFT_CODENAMES.items() if version in v] codenames = [k for k, v in SWIFT_CODENAMES.items() if version in v]
@ -845,14 +834,10 @@ def openstack_upgrade_available(package):
if not cur_vers: if not cur_vers:
# The package has not been installed yet do not attempt upgrade # The package has not been installed yet do not attempt upgrade
return False return False
if "swift" in package: try:
codename = get_os_codename_install_source(src) avail_vers = get_os_version_install_source(src)
avail_vers = get_os_version_codename_swift(codename) except Exception:
else: avail_vers = cur_vers
try:
avail_vers = get_os_version_install_source(src)
except Exception:
avail_vers = cur_vers
apt.init() apt.init()
return apt.version_compare(avail_vers, cur_vers) >= 1 return apt.version_compare(avail_vers, cur_vers) >= 1

View File

@ -159,15 +159,19 @@ def get_osd_settings(relation_name):
return _order_dict_by_key(osd_settings) return _order_dict_by_key(osd_settings)
def send_application_name(relid=None): def send_application_name(relid=None, app_name=None):
"""Send the application name down the relation. """Send the application name down the relation.
:param relid: Relation id to set application name in. :param relid: Relation id to set application name in.
:type relid: str :type relid: str
:param app_name: Application name to send in the relation.
:type app_name: str
""" """
if app_name is None:
app_name = application_name()
relation_set( relation_set(
relation_id=relid, relation_id=relid,
relation_settings={'application-name': application_name()}) relation_settings={'application-name': app_name})
def send_osd_settings(): def send_osd_settings():

View File

@ -52,7 +52,7 @@ def _snap_exec(commands):
:param commands: List commands :param commands: List commands
:return: Integer exit code :return: Integer exit code
""" """
assert type(commands) == list assert type(commands) is list
retry_count = 0 retry_count = 0
return_code = None return_code = None