Skip to content

Commit ead0f4a

Browse files
twangboydwoz
authored andcommitted
Fix remaining Ubuntu 26.04 CI failures across systemd, docker, and apt tests
- systemd_service: guard _runlevel() against a missing `runlevel` binary (Ubuntu 26.04 ships without sysvinit-utils) instead of passing None into cmd.run and crashing with IndexError; this was breaking test_service.py across the unit, functional/modules, and functional/states suites - dockermod: ignore the live `Status`/IPAM-usage field in compare_networks(), which was leaking into docker_network.present's changes dict and failing test_docker_network.py - test_debian (pkgrepo): apply the same apt-key/signed-by fallback used by every other test in the file to the multiple_comps_state_tree fixture, so it doesn't hit "missing 'signedby' option" on Ubuntu 26.04's apt-key-less apt - test_system: broaden the teardown except clause to also catch CommandExecutionError, not just AssertionError, so a failed date restore doesn't crash setup_teardown_vars and leak state into later tests - mysql test support: generate each MySQLCombo's container_id fresh per module-fixture instantiation instead of once at import time, so cache/modules/states test_mysql.py (and reruns) stop colliding on the same fixed container name
1 parent 4431dc7 commit ead0f4a

5 files changed

Lines changed: 24 additions & 35 deletions

File tree

‎salt/modules/dockermod.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ def _check_ipconfig(ret, net_name, **kwargs):
12881288
return ret
12891289

12901290

1291-
def compare_networks(first, second, ignore="Name,Id,Created,Containers"):
1291+
def compare_networks(first, second, ignore="Name,Id,Created,Containers,Status"):
12921292
"""
12931293
.. versionadded:: 2018.3.0
12941294
@@ -1300,7 +1300,7 @@ def compare_networks(first, second, ignore="Name,Id,Created,Containers"):
13001300
second
13011301
Name or ID of second container
13021302
1303-
ignore : Name,Id,Created,Containers
1303+
ignore : Name,Id,Created,Containers,Status
13041304
A comma-separated list (or Python list) of keys to ignore when
13051305
comparing.
13061306

‎salt/modules/systemd_service.py‎

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,18 @@ def _runlevel():
285285
contextkey = "systemd._runlevel"
286286
if contextkey in __context__:
287287
return __context__[contextkey]
288-
out = __salt__["cmd.run"](
289-
salt.utils.path.which("runlevel"), python_shell=False, ignore_retcode=True
290-
)
291-
try:
292-
ret = out.split()[1]
293-
except IndexError:
294-
# The runlevel is unknown, return the default
288+
runlevel_bin = salt.utils.path.which("runlevel")
289+
if runlevel_bin is None:
290+
# No runlevel binary (e.g. Ubuntu 26.04 ships without sysvinit-utils),
291+
# return the default
295292
ret = _default_runlevel()
293+
else:
294+
out = __salt__["cmd.run"](runlevel_bin, python_shell=False, ignore_retcode=True)
295+
try:
296+
ret = out.split()[1]
297+
except IndexError:
298+
# The runlevel is unknown, return the default
299+
ret = _default_runlevel()
296300
__context__[contextkey] = ret
297301
return ret
298302

‎tests/pytests/functional/modules/test_system.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def setup_teardown_vars(file, service, system):
101101
finally:
102102
try:
103103
_restore_time(system, _orig_time)
104-
except AssertionError:
104+
except (AssertionError, CommandExecutionError):
105105
pass
106106

107107
if _machine_info is not False:

‎tests/pytests/functional/states/pkgrepo/test_debian.py‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,14 @@ def multiple_comps_repo_file_backports(grains):
319319
def multiple_comps_state_tree(
320320
multiple_comps_repo_file_caconical, multiple_comps_repo_file_backports, state_tree
321321
):
322+
aptkey = True if salt.utils.path.which("apt-key") else False
323+
signedby = ""
324+
if not aptkey:
325+
signedby = " [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg]"
322326
sls_contents = """
323327
ubuntu-backports:
324328
pkgrepo.managed:
325-
- name: 'deb http://fi.archive.ubuntu.com/ubuntu focal-backports'
329+
- name: 'deb{signedby} http://fi.archive.ubuntu.com/ubuntu focal-backports'
326330
- comps: main, restricted, universe, multiverse
327331
- refresh: false
328332
- disabled: false
@@ -333,7 +337,7 @@ def multiple_comps_state_tree(
333337
334338
canonical-ubuntu:
335339
pkgrepo.managed:
336-
- name: 'deb http://archive.canonical.com/ubuntu {{{{ salt['grains.get']('oscodename') }}}}'
340+
- name: 'deb{signedby} http://archive.canonical.com/ubuntu {{{{ salt['grains.get']('oscodename') }}}}'
337341
- comps: partner
338342
- refresh: false
339343
- disabled: false
@@ -342,6 +346,7 @@ def multiple_comps_state_tree(
342346
""".format(
343347
multiple_comps_repo_file_backports,
344348
multiple_comps_repo_file_caconical,
349+
signedby=signedby,
345350
)
346351
with pytest.helpers.temp_file("multiple-comps-repos.sls", sls_contents, state_tree):
347352
yield

‎tests/support/pytest/mysql.py‎

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
class MySQLImage:
1919
name = attr.ib()
2020
tag = attr.ib()
21-
container_id = attr.ib()
2221

2322
def __str__(self):
2423
return f"{self.name}:{self.tag}"
@@ -64,31 +63,13 @@ def get_test_versions():
6463
test_versions = []
6564
name = "mysql-server"
6665
for version in ("5.5", "5.6", "5.7", "8.0"):
67-
test_versions.append(
68-
MySQLImage(
69-
name=name,
70-
tag=version,
71-
container_id=random_string(f"mysql-{version}-"),
72-
)
73-
)
66+
test_versions.append(MySQLImage(name=name, tag=version))
7467
name = "mariadb"
7568
for version in ("10.3", "10.4", "10.5"):
76-
test_versions.append(
77-
MySQLImage(
78-
name=name,
79-
tag=version,
80-
container_id=random_string(f"mariadb-{version}-"),
81-
)
82-
)
69+
test_versions.append(MySQLImage(name=name, tag=version))
8370
name = "percona"
8471
for version in ("5.6", "5.7", "8.0"):
85-
test_versions.append(
86-
MySQLImage(
87-
name=name,
88-
tag=version,
89-
container_id=random_string(f"percona-{version}-"),
90-
)
91-
)
72+
test_versions.append(MySQLImage(name=name, tag=version))
9273
return test_versions
9374

9475

@@ -112,7 +93,6 @@ def create_mysql_combo(mysql_image):
11293
mysql_version=mysql_image.tag,
11394
mysql_user="salt-mysql-user",
11495
mysql_passwd="Pa55w0rd!",
115-
container_id=mysql_image.container_id,
11696
)
11797

11898

0 commit comments

Comments
 (0)