Skip to content

Commit 42d2757

Browse files
committed
guestfs: enhance ssh config choice
The ssh configuration file we use when we set up guests with guestfs is is simply ~/.ssh/config_kdevops_$KDEVOPS_HOSTS_PREFIX. This has scaled for a while but now that we have CI support each self-hosted will want to use the relevant git commit ID upstream from the upstream repo as the prefix, when that is used then technically we can't test the same test for different subsystems. Additionally even we can't run kdevops on the same host with the default prefix on the same distro more than once without creating an overwrite of the file. For example debian13 systems will use .ssh/config_kdevops_debian13 for both XFS and even if NFS tests. Enhance support to scale by having a unique prefix for the ssh configuration. We choose the current working directory for kdevops as the unique pivot for what we'll use, so we can just compute the sha256sum of the current working directory. To remain backward compatible add TOPDIR_PATH_HAS_SHA256SUM which default to y, so that in older setups if folks git pull, things will still work with the old prefix. Signed-off-by: Luis Chamberlain <[email protected]>
1 parent 4f967e0 commit 42d2757

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@ config TOPDIR_PATH
1010
output yaml
1111
default $(shell, echo $TOPDIR_PATH)
1212

13+
config TOPDIR_PATH_HAS_SHA256SUM
14+
bool
15+
output yaml
16+
default y
17+
18+
config TOPDIR_PATH_SHA256SUM
19+
string
20+
output yaml
21+
default $(shell, ./scripts/compute_sha256sum.sh $(TOPDIR_PATH))
22+
1323
config HAVE_KDEVOPS_CUSTOM_DEFAULTS
1424
bool
1525
default n

scripts/destroy_guestfs.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ if [ -f "$GUESTFSDIR/kdevops_nodes.yaml" ]; then
2727
done
2828
fi
2929

30-
rm -f ~/.ssh/config_kdevops_$CONFIG_KDEVOPS_HOSTS_PREFIX
30+
if [[ "$CONFIG_TOPDIR_PATH_HAS_SHA256SUM" == "y" ]]; then
31+
rm -f ~/.ssh/config_kdevops_$CONFIG_TOPDIR_PATH_SHA256SUM
32+
else
33+
rm -f ~/.ssh/config_kdevops_$CONFIG_KDEVOPS_HOSTS_PREFIX
34+
fi
3135
rm -f $GUESTFSDIR/.provisioned_once
3236
rm -f $GUESTFSDIR/kdevops_nodes.yaml

scripts/update_ssh_config_guestfs.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ def main():
7575
with open(f'{topdir}/{extra_vars["kdevops_nodes"]}') as stream:
7676
nodes = yaml.safe_load(stream)
7777

78-
ssh_config = f'{Path.home()}/.ssh/config_kdevops_{extra_vars["kdevops_host_prefix"]}'
78+
if extra_vars.get("topdir_path_has_sha256sum", False):
79+
ssh_config = f'{Path.home()}/.ssh/config_kdevops_{extra_vars["topdir_path_sha256sum"]}'
80+
else:
81+
ssh_config = f'{Path.home()}/.ssh/config_kdevops_{extra_vars["kdevops_host_prefix"]}'
7982

8083
# make a stanza for each node
8184
sshconf = open(ssh_config, 'w')

0 commit comments

Comments
 (0)