fix: pass ip commands as single strings to avoid bash -c argument splitting (#1459)

exec_cmd_in_pod wraps commands with `bash -c` when no base_command is
specified. Passing ["ip", "-br", "addr", "show"] produces
["bash", "-c", "ip", "-br", "addr", "show"]. Due to bash -c semantics,
only the first argument after -c ("ip") is treated as the command
string; the rest become unused positional parameters. This caused bare
`ip` to run with no arguments, printing help/usage text instead of
interface data.

The egress scenario was unaffected because it uses base_command="chroot"
which constructs commands correctly without bash -c wrapping.

Pass each command as a single string (e.g. ["ip -br addr show"]) so
bash -c treats it as one complete command.

Closes #1380

Signed-off-by: Rahul Shetty <rashetty@redhat.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Rahul Shetty
2026-07-10 17:45:08 +05:30
committed by GitHub
co-authored by Claude Opus 4.6
parent 98a88ccb46
commit a2e57b7b51
@@ -185,7 +185,7 @@ def get_default_interface(node: str, pod_template, kubecli: KrknKubernetes, imag
kubecli.create_pod(pod_body, "default", 300)
pod_name = f"fedtools-{pod_name_regex}"
try:
cmd = ["ip", "r"]
cmd = ["ip r"]
output = kubecli.exec_cmd_in_pod(cmd, pod_name, "default")
if not output:
@@ -238,7 +238,7 @@ def verify_interface(
pod_name = f"fedtools-{pod_name_regex}"
try:
if input_interface_list == []:
cmd = ["ip", "r"]
cmd = ["ip r"]
output = kubecli.exec_cmd_in_pod(cmd, pod_name, "default")
if not output:
@@ -254,7 +254,7 @@ def verify_interface(
input_interface_list = [default_route.split()[4]]
else:
cmd = ["ip", "-br", "addr", "show"]
cmd = ["ip -br addr show"]
output = kubecli.exec_cmd_in_pod(cmd, pod_name, "default")
if not output: