Ensure context templating doesn't fail on incomplete relation data

This is a rebuild/make sync for charms to pickup the fix in
charmhelpers to fix a change in netaddr library not allowing
falsy addresses anymore. Fix in charmhelpers is in [1].

[1] https://github.com/juju/charm-helpers/pull/921

Change-Id: I0200dcfd398757bf5cfeebac5fdda8c203045529
Signed-off-by: Guillaume Boutry <guillaume.boutry@canonical.com>
This commit is contained in:
Guillaume Boutry 2025-04-22 10:34:14 +02:00
parent 1a70d1bf38
commit 033fbfcf44
No known key found for this signature in database
GPG Key ID: 0DD77DC1796E98CD
3 changed files with 12 additions and 6 deletions

View File

@ -134,6 +134,8 @@ def get_address_in_network(network, fallback=None, fatal=False):
def is_ipv6(address):
"""Determine whether provided address is IPv6 or not."""
if not address:
return False
try:
address = netaddr.IPAddress(address)
except netaddr.AddrFormatError:

View File

@ -357,7 +357,7 @@ def init_is_systemd(service_name=None):
return os.path.isdir(SYSTEMD_SYSTEM)
def adduser(username, password=None, shell='/bin/bash',
def adduser(username, password=None, shell=None,
system_user=False, primary_group=None,
secondary_groups=None, uid=None, home_dir=None):
"""Add a user to the system.
@ -389,11 +389,14 @@ def adduser(username, password=None, shell='/bin/bash',
if home_dir:
cmd.extend(['--home', str(home_dir)])
if system_user or password is None:
cmd.append('--system')
cmd.extend([
'--system',
'--shell', shell if shell else '/usr/sbin/nologin'
])
else:
cmd.extend([
'--create-home',
'--shell', shell,
'--shell', shell if shell else '/bin/bash',
'--password', password,
])
if not primary_group:

View File

@ -341,7 +341,7 @@ UBUNTU_OPENSTACK_RELEASE = OrderedDict([
])
APT_NO_LOCK = 100 # The return code for "couldn't acquire lock" in APT.
APT_ERROR_CODE = 100 # The return code for APT errors.
CMD_RETRY_DELAY = 10 # Wait 10 seconds between command retries.
CMD_RETRY_COUNT = 10 # Retry a failing fatal command X times.
@ -464,6 +464,8 @@ def apt_upgrade(options=None, fatal=False, dist=False):
def apt_update(fatal=False):
"""Update local apt cache."""
cmd = ['apt-get', 'update']
if fatal:
cmd.append("--error-on=any")
_run_apt_command(cmd, fatal)
@ -1021,8 +1023,7 @@ def _run_apt_command(cmd, fatal=False, quiet=False):
"""
if fatal:
_run_with_retries(
cmd, retry_exitcodes=(1, APT_NO_LOCK,),
retry_message="Couldn't acquire DPKG lock",
cmd, retry_exitcodes=(1, APT_ERROR_CODE,),
quiet=quiet)
else:
kwargs = {}