Skip to content

Commit dd1b4d7

Browse files
committed
Updates for caracal testing support
These updates, on the master branch, are to support testing the caracal packages and support of the charms for caracal. They do NOT lock the charms down, and don't change the testing branches to stable branches. Update unit-test to deal with Py3.11 which is run on Debian Buster and doesn't have /etc/lsb/release file (incorrect mocking issue). Change-Id: Icddaf9f7b091a09ef4627384cd349e43b34b1325
1 parent e6a1f41 commit dd1b4d7

21 files changed

+165
-131
lines changed

build-requirements.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

charmcraft.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,3 @@ bases:
3030
- name: ubuntu
3131
channel: "22.04"
3232
architectures: [amd64, s390x, ppc64el, arm64]
33-
- name: ubuntu
34-
channel: "23.04"
35-
architectures: [amd64, s390x, ppc64el, arm64]
36-
- name: ubuntu
37-
channel: "23.10"
38-
architectures: [amd64, s390x, ppc64el, arm64]

hooks/charmhelpers/contrib/openstack/cert_utils.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -414,18 +414,27 @@ def get_requests_for_local_unit(relation_name=None):
414414
is_legacy_request = set(sent).intersection(legacy_keys)
415415
for unit in related_units(rid):
416416
data = relation_get(rid=rid, unit=unit)
417-
if data.get(raw_certs_key):
418-
bundles.append({
419-
'ca': data['ca'],
420-
'chain': data.get('chain'),
421-
'certs': json.loads(data[raw_certs_key])})
422-
elif is_legacy_request:
423-
bundles.append({
424-
'ca': data['ca'],
425-
'chain': data.get('chain'),
426-
'certs': {sent['common_name']:
427-
{'cert': data.get(local_name + '.server.cert'),
428-
'key': data.get(local_name + '.server.key')}}})
417+
# Note: Bug#2028683 - data may not be available if the certificates
418+
# relation hasn't been populated by the providing charm. If no 'ca'
419+
# in the data then don't attempt the bundle at all.
420+
if data.get('ca'):
421+
if data.get(raw_certs_key):
422+
bundles.append({
423+
'ca': data['ca'],
424+
'chain': data.get('chain'),
425+
'certs': json.loads(data[raw_certs_key])
426+
})
427+
elif is_legacy_request:
428+
bundles.append({
429+
'ca': data['ca'],
430+
'chain': data.get('chain'),
431+
'certs': {
432+
sent['common_name']: {
433+
'cert': data.get(local_name + '.server.cert'),
434+
'key': data.get(local_name + '.server.key')
435+
}
436+
}
437+
})
429438

430439
return bundles
431440

hooks/charmhelpers/contrib/openstack/context.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ def _resolve(key):
545545
'internal_auth_url': internal_auth_url,
546546
})
547547

548-
# we keep all veriables in ctxt for compatibility and
548+
# we keep all variables in ctxt for compatibility and
549549
# add nested dictionary for keystone_authtoken generic
550550
# templating
551551
if keystonemiddleware_os_release:
@@ -557,6 +557,7 @@ def _resolve(key):
557557
# NOTE(jamespage) this is required for >= icehouse
558558
# so a missing value just indicates keystone needs
559559
# upgrading
560+
ctxt['admin_user_id'] = _resolve('service_user_id')
560561
ctxt['admin_tenant_id'] = _resolve('service_tenant_id')
561562
ctxt['admin_domain_id'] = _resolve('service_domain_id')
562563
return ctxt
@@ -1748,9 +1749,9 @@ def __init__(self, name=None, script=None, admin_script=None,
17481749

17491750
def __call__(self):
17501751
total_processes = _calculate_workers()
1751-
enable_wsgi_rotation = config('wsgi-rotation')
1752-
if enable_wsgi_rotation is None:
1753-
enable_wsgi_rotation = True
1752+
enable_wsgi_socket_rotation = config('wsgi-socket-rotation')
1753+
if enable_wsgi_socket_rotation is None:
1754+
enable_wsgi_socket_rotation = True
17541755
ctxt = {
17551756
"service_name": self.service_name,
17561757
"user": self.user,
@@ -1764,7 +1765,7 @@ def __call__(self):
17641765
"public_processes": int(math.ceil(self.public_process_weight *
17651766
total_processes)),
17661767
"threads": 1,
1767-
"wsgi_rotation": enable_wsgi_rotation,
1768+
"wsgi_socket_rotation": enable_wsgi_socket_rotation,
17681769
}
17691770
return ctxt
17701771

hooks/charmhelpers/contrib/openstack/templates/wsgi-openstack-api.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Listen {{ admin_port }}
1212
Listen {{ public_port }}
1313
{% endif -%}
1414

15-
{% if wsgi_rotation -%}
15+
{% if wsgi_socket_rotation -%}
1616
WSGISocketRotation On
1717
{% else -%}
1818
WSGISocketRotation Off

hooks/charmhelpers/contrib/openstack/templates/wsgi-openstack-metadata.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Listen {{ admin_port }}
1212
Listen {{ public_port }}
1313
{% endif -%}
1414

15-
{% if wsgi_rotation -%}
15+
{% if wsgi_socket_rotation -%}
1616
WSGISocketRotation On
1717
{% else -%}
1818
WSGISocketRotation Off

hooks/charmhelpers/contrib/openstack/utils.py

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@
161161
('2022.2', 'zed'),
162162
('2023.1', 'antelope'),
163163
('2023.2', 'bobcat'),
164+
('2024.1', 'caracal'),
164165
])
165166

166167
# The ugly duckling - must list releases oldest to newest
@@ -416,17 +417,6 @@ def get_os_version_codename(codename, version_map=OPENSTACK_CODENAMES,
416417
error_out(e)
417418

418419

419-
def get_os_version_codename_swift(codename):
420-
'''Determine OpenStack version number of swift from codename.'''
421-
# for k, v in six.iteritems(SWIFT_CODENAMES):
422-
for k, v in SWIFT_CODENAMES.items():
423-
if k == codename:
424-
return v[-1]
425-
e = 'Could not derive swift version for '\
426-
'codename: %s' % codename
427-
error_out(e)
428-
429-
430420
def get_swift_codename(version):
431421
'''Determine OpenStack codename that corresponds to swift version.'''
432422
codenames = [k for k, v in SWIFT_CODENAMES.items() if version in v]
@@ -585,7 +575,6 @@ def _do_install():
585575
return openstack_release().get('OPENSTACK_CODENAME')
586576

587577

588-
@cached
589578
def openstack_release():
590579
"""Return /etc/os-release in a dict."""
591580
d = {}
@@ -847,14 +836,10 @@ def openstack_upgrade_available(package):
847836
if not cur_vers:
848837
# The package has not been installed yet do not attempt upgrade
849838
return False
850-
if "swift" in package:
851-
codename = get_os_codename_install_source(src)
852-
avail_vers = get_os_version_codename_swift(codename)
853-
else:
854-
try:
855-
avail_vers = get_os_version_install_source(src)
856-
except Exception:
857-
avail_vers = cur_vers
839+
try:
840+
avail_vers = get_os_version_install_source(src)
841+
except Exception:
842+
avail_vers = cur_vers
858843
apt.init()
859844
return apt.version_compare(avail_vers, cur_vers) >= 1
860845

hooks/charmhelpers/contrib/storage/linux/ceph.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,19 @@ def get_osd_settings(relation_name):
158158
return _order_dict_by_key(osd_settings)
159159

160160

161-
def send_application_name(relid=None):
161+
def send_application_name(relid=None, app_name=None):
162162
"""Send the application name down the relation.
163163
164164
:param relid: Relation id to set application name in.
165165
:type relid: str
166+
:param app_name: Application name to send in the relation.
167+
:type app_name: str
166168
"""
169+
if app_name is None:
170+
app_name = application_name()
167171
relation_set(
168172
relation_id=relid,
169-
relation_settings={'application-name': application_name()})
173+
relation_settings={'application-name': app_name})
170174

171175

172176
def send_osd_settings():

hooks/charmhelpers/contrib/storage/linux/lvm.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
CalledProcessError,
1818
check_call,
1919
check_output,
20-
Popen,
21-
PIPE,
2220
)
2321

2422

@@ -58,9 +56,7 @@ def remove_lvm_physical_volume(block_device):
5856
5957
:param block_device: str: Full path of block device to scrub.
6058
'''
61-
p = Popen(['pvremove', '-ff', block_device],
62-
stdin=PIPE)
63-
p.communicate(input='y\n')
59+
check_call(['pvremove', '-ff', '--yes', block_device])
6460

6561

6662
def list_lvm_volume_group(block_device):

hooks/charmhelpers/core/unitdata.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ def config_changed():
151151
import datetime
152152
import itertools
153153
import json
154+
import logging
154155
import os
155156
import pprint
156157
import sqlite3
@@ -521,6 +522,42 @@ class DeltaSet(Record):
521522

522523
def kv():
523524
global _KV
525+
526+
# If we are running unit tests, it is useful to go into memory-backed KV store to
527+
# avoid concurrency issues when running multiple tests. This is not a
528+
# problem when juju is running normally.
529+
530+
env_var = os.environ.get("CHARM_HELPERS_TESTMODE", "auto").lower()
531+
if env_var not in ["auto", "no", "yes"]:
532+
logging.warning("Unknown value for CHARM_HELPERS_TESTMODE '%s'"
533+
", assuming 'no'", env_var)
534+
env_var = "no"
535+
536+
if env_var == "no":
537+
in_memory_db = False
538+
elif env_var == "yes":
539+
in_memory_db = True
540+
elif env_var == "auto":
541+
# If UNIT_STATE_DB is set, respect this request
542+
if "UNIT_STATE_DB" in os.environ:
543+
in_memory_db = False
544+
# Autodetect normal juju execution by looking for juju variables
545+
elif "JUJU_CHARM_DIR" in os.environ or "JUJU_UNIT_NAME" in os.environ:
546+
in_memory_db = False
547+
else:
548+
# We are probably running in unit test mode
549+
logging.warning("Auto-detected unit test environment for KV store.")
550+
in_memory_db = True
551+
else:
552+
# Help the linter realise that in_memory_db is always set
553+
raise Exception("Cannot reach this line")
554+
524555
if _KV is None:
525-
_KV = Storage()
556+
if in_memory_db:
557+
_KV = Storage(":memory:")
558+
else:
559+
_KV = Storage()
560+
else:
561+
if in_memory_db and _KV.db_path != ":memory:":
562+
logging.warning("Running with in_memory_db and KV is not set to :memory:")
526563
return _KV

hooks/charmhelpers/fetch/snap.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def _snap_exec(commands):
5252
:param commands: List commands
5353
:return: Integer exit code
5454
"""
55-
assert type(commands) == list
55+
assert isinstance(commands, list)
5656

5757
retry_count = 0
5858
return_code = None

hooks/charmhelpers/fetch/ubuntu.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,14 @@
246246
'bobcat/proposed': 'jammy-proposed/bobcat',
247247
'jammy-bobcat/proposed': 'jammy-proposed/bobcat',
248248
'jammy-proposed/bobcat': 'jammy-proposed/bobcat',
249+
# caracal
250+
'caracal': 'jammy-updates/caracal',
251+
'jammy-caracal': 'jammy-updates/caracal',
252+
'jammy-caracal/updates': 'jammy-updates/caracal',
253+
'jammy-updates/caracal': 'jammy-updates/caracal',
254+
'caracal/proposed': 'jammy-proposed/caracal',
255+
'jammy-caracal/proposed': 'jammy-proposed/caracal',
256+
'jammy-proposed/caracal': 'jammy-proposed/caracal',
249257

250258
# OVN
251259
'focal-ovn-22.03': 'focal-updates/ovn-22.03',
@@ -279,6 +287,7 @@
279287
'zed',
280288
'antelope',
281289
'bobcat',
290+
'caracal',
282291
)
283292

284293

@@ -308,6 +317,7 @@
308317
('kinetic', 'zed'),
309318
('lunar', 'antelope'),
310319
('mantic', 'bobcat'),
320+
('noble', 'caracal'),
311321
])
312322

313323

hooks/charmhelpers/osplatform.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,13 @@ def get_platform():
99
will be returned (which is the name of the module).
1010
This string is used to decide which platform module should be imported.
1111
"""
12-
# linux_distribution is deprecated and will be removed in Python 3.7
13-
# Warnings *not* disabled, as we certainly need to fix this.
14-
if hasattr(platform, 'linux_distribution'):
15-
tuple_platform = platform.linux_distribution()
16-
current_platform = tuple_platform[0]
17-
else:
18-
current_platform = _get_platform_from_fs()
12+
current_platform = _get_current_platform()
1913

2014
if "Ubuntu" in current_platform:
2115
return "ubuntu"
2216
elif "CentOS" in current_platform:
2317
return "centos"
24-
elif "debian" in current_platform:
18+
elif "debian" in current_platform or "Debian" in current_platform:
2519
# Stock Python does not detect Ubuntu and instead returns debian.
2620
# Or at least it does in some build environments like Travis CI
2721
return "ubuntu"
@@ -36,6 +30,24 @@ def get_platform():
3630
.format(current_platform))
3731

3832

33+
def _get_current_platform():
34+
"""Return the current platform information for the OS.
35+
36+
Attempts to lookup linux distribution information from the platform
37+
module for releases of python < 3.7. For newer versions of python,
38+
the platform is determined from the /etc/os-release file.
39+
"""
40+
# linux_distribution is deprecated and will be removed in Python 3.7
41+
# Warnings *not* disabled, as we certainly need to fix this.
42+
if hasattr(platform, 'linux_distribution'):
43+
tuple_platform = platform.linux_distribution()
44+
current_platform = tuple_platform[0]
45+
else:
46+
current_platform = _get_platform_from_fs()
47+
48+
return current_platform
49+
50+
3951
def _get_platform_from_fs():
4052
"""Get Platform from /etc/os-release."""
4153
with open(os.path.join(os.sep, 'etc', 'os-release')) as fin:

metadata.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ description: |
1616
L2 connectivity on nova-compute services.
1717
docs: https://discourse.charmhub.io/t/neutron-openvswitch-docs-index/11001
1818
tags:
19-
- openstack
19+
- openstack
2020
series:
21-
- jammy
22-
- lunar
23-
- mantic
21+
- jammy
2422
extra-bindings:
2523
data:
2624
provides:

0 commit comments

Comments
 (0)