From 55cd5cbdd9ab30c31e9c67d195ec41e0979eb125 Mon Sep 17 00:00:00 2001 From: smethnani <82812166+smethnani@users.noreply.github.com> Date: Tue, 6 Oct 2026 07:53:05 +0100 Subject: [PATCH] patch: fix is_service_started --- opensearch_single_kernel/workload/vm.py | 2 +- tests/integration/ha/helpers.py | 6 +++--- tests/integration/ha/k8s_helpers/helpers.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/opensearch_single_kernel/workload/vm.py b/opensearch_single_kernel/workload/vm.py index fe346598..b08c1e27 100644 --- a/opensearch_single_kernel/workload/vm.py +++ b/opensearch_single_kernel/workload/vm.py @@ -207,7 +207,7 @@ def is_service_started(self, paused: bool | None = False) -> bool: # Now, we must dig deeper into the actual status of systemd and the JVM process. # First, we want to make sure the process is not stopped, dead or zombie. try: - pid = self.run_cmd("lsof", args="-ti:9200").out.rstrip() + pid = self.run_cmd("lsof", args="-ti:9200 -sTCP:LISTEN").out.rstrip() if not pid or not os.path.exists(f"/proc/{pid}/stat"): return False with open(f"/proc/{pid}/stat") as f: diff --git a/tests/integration/ha/helpers.py b/tests/integration/ha/helpers.py index 3e1b4527..b0b50899 100644 --- a/tests/integration/ha/helpers.py +++ b/tests/integration/ha/helpers.py @@ -310,7 +310,7 @@ async def all_processes_down(ops_test: OpsTest, app: str) -> bool: """Check if all processes are down.""" for unit_id in get_application_unit_ids(ops_test, app): unit_name = f"{app}/{unit_id}" - get_pid_cmd = f"ssh {unit_name} -- sudo lsof -ti:9200" + get_pid_cmd = f"ssh {unit_name} -- sudo lsof -ti:9200 -sTCP:LISTEN" try: for attempt in Retrying(stop=stop_after_delay(60), wait=wait_fixed(3)): with attempt: @@ -337,9 +337,9 @@ async def send_kill_signal_to_process( if opensearch_pid is None: if substrate == "vm": - get_pid_cmd = f"ssh {unit_name} -- sudo lsof -ti:9200" + get_pid_cmd = f"ssh {unit_name} -- sudo lsof -ti:9200 -sTCP:LISTEN" else: - get_pid_cmd = f"ssh --container opensearch {unit_name} lsof -ti:9200" + get_pid_cmd = f"ssh --container opensearch {unit_name} lsof -ti:9200 -sTCP:LISTEN" _, opensearch_pid, _ = await ops_test.juju( *get_pid_cmd.split(), check=False, stdin=NO_TTY_STDIN ) diff --git a/tests/integration/ha/k8s_helpers/helpers.py b/tests/integration/ha/k8s_helpers/helpers.py index b9906439..7be6c8cc 100644 --- a/tests/integration/ha/k8s_helpers/helpers.py +++ b/tests/integration/ha/k8s_helpers/helpers.py @@ -304,7 +304,7 @@ def pebble_patch_restart_delay( for attempt in Retrying(stop=stop_after_delay(120), wait=wait_fixed(3)): with attempt: result = subprocess.run( - f"juju ssh --container opensearch {unit_name} lsof -ti:9200".split(), + f"juju ssh --container opensearch {unit_name} lsof -ti:9200 -sTCP:LISTEN".split(), capture_output=True, text=True, stdin=subprocess.DEVNULL,