Skip to content

Commit a592611

Browse files
committed
CI: use pre-existing ssh key on multinode jobs
In initially fixing the multinode key access to the subnode, we inadvertently now broke ssh access post-upgrade to the controller local host as it is attempting to generate and leverage an ssh key locally which can't really work. So instead, used the provided keys if present. Change-Id: I930f034c47bd1d2729ce43cd07c28cc7c1126402
1 parent ee332f2 commit a592611

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

devstack/plugin.sh

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,18 @@ function configure_generic_switch_ssh_keypair {
7777
fi
7878
# copy over stack user's authorized_keys to GENERIC_SWITCH_USER
7979
# mostly needed for multinode gate job
80-
if [[ -e "$HOME/.ssh/authorized_keys" ]];then
80+
if [[ -e "$HOME/.ssh/authorized_keys" ]]; then
8181
cat "$HOME/.ssh/authorized_keys" | sudo tee -a $GENERIC_SWITCH_KEY_AUTHORIZED_KEYS_FILE
8282
fi
8383
if [[ ! -e $GENERIC_SWITCH_KEY_FILE ]]; then
8484
if [[ ! -d $(dirname $GENERIC_SWITCH_KEY_FILE) ]]; then
8585
mkdir -p $(dirname $GENERIC_SWITCH_KEY_FILE)
8686
fi
87-
echo -e 'n\n' | ssh-keygen -q -t rsa -P '' -m PEM -f $GENERIC_SWITCH_KEY_FILE
87+
if [[ "$HOST_TOPLOGY" != "multinode" ]]; then
88+
# NOTE(TheJulia): Self management of ssh keys only works locally
89+
# and multinode CI jobs cannot leverage it.
90+
echo -e 'n\n' | ssh-keygen -q -t rsa -P '' -m PEM -f $GENERIC_SWITCH_KEY_FILE
91+
fi
8892
fi
8993
# NOTE(vsaienko) check for new line character, add if doesn't exist.
9094
if [[ "$(sudo tail -c1 $GENERIC_SWITCH_KEY_AUTHORIZED_KEYS_FILE | wc -l)" == "0" ]]; then
@@ -133,6 +137,13 @@ function configure_generic_switch {
133137
done
134138
fi
135139

140+
if [ -e "$HOME/.ssh/id_rsa" ] && [[ "$HOST_TOPOLOGY" == "multinode" ]]; then
141+
# NOTE(TheJulia): Reset the key pair to utilize a pre-existing key,
142+
# this is instead of generating one, which doesn't work in multinode
143+
# environments. This is because the keys are managed and placed by zuul.
144+
GENERIC_SWITCH_KEY_FILE="${HOME}/.ssh/id_rsa"
145+
fi
146+
136147
# Create generic_switch ml2 config
137148
for switch in $GENERIC_SWITCH_TEST_BRIDGE $IRONIC_VM_NETWORK_BRIDGE; do
138149
local bridge_mac
@@ -145,12 +156,6 @@ function configure_generic_switch {
145156
if [ -n "$HOST_TOPOLOGY_SUBNODES" ]; then
146157
# NOTE(vsaienko) with multinode topology we need to add switches from all
147158
# the subnodes to the config on primary node
148-
# NOTE(TheJulia) We *also* need to use the local key which will have
149-
# access to the subnode instead of attemping to configure our own,
150-
# as the plugins execute separately.
151-
if [ -e "$HOME/.ssh/id_rsa" ]; then
152-
GENERIC_SWITCH_KEY_FILE="${HOME}/.ssh/id_rsa"
153-
fi
154159
local cnt=0
155160
local section
156161
for node in $HOST_TOPOLOGY_SUBNODES; do

0 commit comments

Comments
 (0)