public inbox for kdevops@lists.linux.dev
 help / color / mirror / Atom feed
From: cel@kernel.org
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: <kdevops@lists.linux.dev>, Chuck Lever <chuck.lever@oracle.com>
Subject: [PATCH] Fix remove_hosts() function
Date: Mon, 11 Nov 2024 16:44:25 -0500	[thread overview]
Message-ID: <20241111214425.712423-1-cel@kernel.org> (raw)

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.

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:
-- 
2.47.0


             reply	other threads:[~2024-11-11 21:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-11 21:44 cel [this message]
2024-11-12 20:20 ` [PATCH] Fix remove_hosts() function Luis Chamberlain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241111214425.712423-1-cel@kernel.org \
    --to=cel@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=kdevops@lists.linux.dev \
    --cc=mcgrof@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox