diff mbox series

Fix remove_hosts() function

Message ID 20241111214425.712423-1-cel@kernel.org (mailing list archive)
State New
Headers show
Series Fix remove_hosts() function | expand

Checks

Context Check Description
mcgrof/vmtest-main-PR success PR summary
mcgrof/vmtest-main-VM_Test-3 success Logs for Setup and Run Make Targets (debian:testing)
mcgrof/vmtest-main-VM_Test-2 success Logs for Setup and Run Make Targets (debian:testing)
mcgrof/vmtest-main-VM_Test-4 success Logs for Setup and Run Make Targets (fedora:latest)
mcgrof/vmtest-main-VM_Test-6 success Logs for Setup and Run Make Targets (opensuse/tumbleweed)
mcgrof/vmtest-main-VM_Test-5 success Logs for Setup and Run Make Targets (fedora:latest)
mcgrof/vmtest-main-VM_Test-7 success Logs for Setup and Run Make Targets (opensuse/tumbleweed)
mcgrof/vmtest-main-VM_Test-1 success Logs for Run kdevops CI
mcgrof/vmtest-main-VM_Test-0 success Logs for Run kdevops CI

Commit Message

Chuck Lever Nov. 11, 2024, 9:44 p.m. UTC
From: Chuck Lever <chuck.lever@oracle.com>

Commit 3b6fbaaaf1df ("update_ssh_config.py: add IP address on Host
line") added an IP address at the end of each Host line. This extra
field breaks the simple host entry matching logic in the
remove_hosts() function, making "--remove" a no-op.

If the ssh_config entries are not removed, the config file grows
without bounds. If new hostnames are added that have the same name
as existing entries, ssh to those hosts fails, which makes certain
Ansible tasks hang for a bit and then fail.

Fixes: 3b6fbaaaf1df ("update_ssh_config.py: add IP address on Host line")
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 update_ssh_config/update_ssh_config.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

This is the simple patch that address the immediate concern about
"--remove" not working. I can push it directly to the github repo,
or I can open a github PR, or you can apply it. Let me know.

Comments

Luis Chamberlain Nov. 12, 2024, 8:20 p.m. UTC | #1
On Mon, Nov 11, 2024 at 04:44:25PM -0500, cel@kernel.org wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
> 
> Commit 3b6fbaaaf1df ("update_ssh_config.py: add IP address on Host
> line") added an IP address at the end of each Host line. This extra
> field breaks the simple host entry matching logic in the
> remove_hosts() function, making "--remove" a no-op.
> 
> If the ssh_config entries are not removed, the config file grows
> without bounds. If new hostnames are added that have the same name
> as existing entries, ssh to those hosts fails, which makes certain
> Ansible tasks hang for a bit and then fail.
> 
> Fixes: 3b6fbaaaf1df ("update_ssh_config.py: add IP address on Host line")
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>  update_ssh_config/update_ssh_config.py | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> This is the simple patch that address the immediate concern about
> "--remove" not working. I can push it directly to the github repo,
> or I can open a github PR, or you can apply it. Let me know.

Please just push! All patches posted to the kdevops mailing list get
automatically tested now thanks to our integration with kpd [0] the
results published on the kdevops-kpd tree [1].

[0] https://github.com/linux-kdevops/kdevops/blob/main/docs/kernel-ci/README.md
[1] https://github.com/linux-kdevops/kdevops-kpd/actions

  Luis
diff mbox series

Patch

diff --git a/update_ssh_config/update_ssh_config.py b/update_ssh_config/update_ssh_config.py
index feac31d2272f..731533d3cc76 100755
--- a/update_ssh_config/update_ssh_config.py
+++ b/update_ssh_config/update_ssh_config.py
@@ -41,7 +41,7 @@  def remove_hosts(args):
         if len(kv) > 1:
             key, value = kv
             if key.lower() == "host":
-                if value in hosts:
+                if value.split(' ')[0] in hosts:
                     rm_this_host = True
                     continue
                 else: