Skip to content

Commit cd8a059

Browse files
committed
Apply AZL4 support fixes to chrony, kdump, kill, modprobe, dhclient
1 parent 45abe8e commit cd8a059

5 files changed

Lines changed: 34 additions & 16 deletions

File tree

lisa/tools/chrony.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626

2727
class Chrony(Tool):
2828
# Leap status : Normal
29-
__leap_status_pattern = re.compile(
30-
r"([\w\W]*?)Leap status.*:.*Normal$", re.MULTILINE
31-
)
29+
__leap_status_pattern = re.compile(r"Leap status\s*:\s*Normal")
3230
__no_server_set = "Number of sources = 0"
3331
__service_not_ready = "503 No such source"
3432

@@ -69,7 +67,7 @@ def restart(self) -> None:
6967
def check_tracking(self) -> None:
7068
cmd_result = self.run("tracking", force_run=True, sudo=True)
7169
cmd_result.assert_exit_code()
72-
if not self.__leap_status_pattern.match(cmd_result.stdout):
70+
if not self.__leap_status_pattern.search(cmd_result.stdout):
7371
raise LisaException(
7472
f"Leap status of {self.command} tracking is not expected,"
7573
" please check the service status of chrony."

lisa/tools/dhclient.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
from lisa.base_tools import Cat
77
from lisa.executable import Tool
8-
from lisa.operating_system import Debian, Fedora, Redhat, Suse
8+
from lisa.operating_system import CBLMariner, Debian, Fedora, Redhat, Suse
99
from lisa.util import LisaException, UnsupportedDistroException, find_group_in_lines
1010

1111
from .ls import Ls
@@ -71,8 +71,17 @@ def get_timeout(self) -> int:
7171
if group and not group["default"]:
7272
value = int(group["number"])
7373
is_default_value = False
74-
elif isinstance(self.node.os, Fedora):
75-
# the default value in fedora is 300
74+
elif isinstance(self.node.os, (Fedora, CBLMariner)):
75+
# Fedora and AZL4+ use NetworkManager for DHCP; default timeout is 300.
76+
# AZL2/3 used dhcpcd (handled by the Debian-like path above via Redhat
77+
# inheritance), but AZL4 switched to NetworkManager.
78+
if isinstance(self.node.os, CBLMariner) and (
79+
self.node.os.information.version.major < 4
80+
):
81+
raise UnsupportedDistroException(
82+
os=self.node.os,
83+
message="CBLMariner < 4 dhclient timeout is not supported here",
84+
)
7685
value = 300
7786
result = self.node.execute("NetworkManager --print-config", sudo=True)
7887
group = find_group_in_lines(result.stdout, self._fedora_pattern)

lisa/tools/kdump.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ def create(cls, node: "Node", *args: Any, **kwargs: Any) -> Tool:
226226
elif isinstance(node.os, Suse):
227227
return KdumpSuse(node)
228228
elif isinstance(node.os, CBLMariner):
229+
if node.os.information.version.major >= 4:
230+
return KdumpFedora(node)
229231
return KdumpCBLMariner(node)
230232
elif type(node.os) is Fedora:
231233
return KdumpFedora(node)
@@ -585,7 +587,7 @@ def command(self) -> str:
585587
return "kdumpctl"
586588

587589
def _install(self) -> bool:
588-
assert isinstance(self.node.os, Fedora)
590+
assert isinstance(self.node.os, (Fedora, CBLMariner))
589591
self.node.os.install_packages("kdump-utils")
590592
return self._check_exists()
591593

lisa/tools/kill.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from lisa.util import LisaException
77
from lisa.util.constants import SIGKILL
88

9+
from .pgrep import Pgrep
910
from .pidof import Pidof
1011

1112

@@ -21,17 +22,20 @@ def can_install(self) -> bool:
2122
def by_name(
2223
self, process_name: str, signum: int = SIGKILL, ignore_not_exist: bool = False
2324
) -> None:
24-
# attempt kill by name first
25-
kill_by_name = self.run(
26-
f"-s {signum} {process_name}", sudo=True, shell=True, force_run=True
27-
)
28-
if kill_by_name.exit_code == 0:
25+
# Find PIDs via pgrep (works even when the process was started
26+
# through sudo/sh wrappers, unlike pidof).
27+
pgrep = self.node.tools[Pgrep]
28+
processes = pgrep.get_processes(process_name)
29+
if processes:
30+
for proc in processes:
31+
self.by_pid(proc.id, signum, ignore_not_exist)
2932
return
3033

31-
# fallback to kill by pid if first attempt fails for some reason
34+
# Fallback: try pidof in case pgrep missed it
3235
pids = self.node.tools[Pidof].get_pids(process_name, sudo=True)
33-
for pid in pids:
34-
self.by_pid(pid, signum, ignore_not_exist)
36+
if pids:
37+
for pid in pids:
38+
self.by_pid(pid, signum, ignore_not_exist)
3539
else:
3640
self._log.debug(
3741
f"Kill for {process_name} did not find any processes to kill."

lisa/tools/modprobe.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ def reload(
242242
"\nTrying to reconnect to the remote node in 2 sec..."
243243
)
244244
time.sleep(2)
245+
# Reset the stale SSH transport so the next retry establishes
246+
# a fresh connection. Without this, the retry loop keeps
247+
# reusing the broken session and every attempt fails with
248+
# "cannot connect to TCP port 22".
249+
self.node.close()
245250

246251
self._log.debug(
247252
f"Time taken to reload {mod_name}: {timer.elapsed(False)} seconds"

0 commit comments

Comments
 (0)