Skip to content

Commit 9cac77c

Browse files
rebtoorcursoragent
andcommitted
ovn_adoption: fix scp with IPv6 addresses in cluster-to-standalone
The scp command constructed from the SSH command by replacing "ssh" with "scp" does not account for IPv6 addresses. When the controller host is an IPv6 address (e.g. 2620:cf:cf:aaaa::70), scp interprets the colons as the host:path separator, causing it to connect to a bogus IPv4 address derived from the first octet. Fix by splitting the SSH command into the scp options and the host, then wrapping the host in square brackets for the scp remote path. This is compatible with both IPv4 and IPv6 addresses since brackets around an IPv4 address are valid in scp. Update both the test role and the user-facing documentation. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 833b9f1 commit 9cac77c

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

docs_user/modules/proc_migrating-ovn-data.adoc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,14 @@ $CONTROLLER1_SSH sudo ovsdb-tool cluster-to-standalone /tmp/ovn_standalone_conve
5757
$CONTROLLER1_SSH sudo chmod 644 /tmp/ovn_standalone_conversion/ovn*.db
5858
5959
# Create local directory and copy converted databases
60+
# Note: brackets around the address are required so that IPv6 colons
61+
# are not confused with the scp host:path separator.
6062
mkdir -p /tmp/ovn_adoption_dbs
61-
CONTROLLER1_SCP=$(echo "$CONTROLLER1_SSH" | sed 's/^ssh/scp/')
62-
${CONTROLLER1_SCP}:/tmp/ovn_standalone_conversion/ovnnb_db.db /tmp/ovn_adoption_dbs/
63-
${CONTROLLER1_SCP}:/tmp/ovn_standalone_conversion/ovnsb_db.db /tmp/ovn_adoption_dbs/
63+
CONTROLLER1_SCP=$(echo "$CONTROLLER1_SSH" | sed -e 's/^ssh/scp/' -e 's/ [^ ]*$//')
64+
CONTROLLER1_USERHOST=$(echo "$CONTROLLER1_SSH" | awk '{print $NF}')
65+
CONTROLLER1_SCP_DEST=$(echo "$CONTROLLER1_USERHOST" | sed 's/@\(.*\)/@[\1]/')
66+
${CONTROLLER1_SCP} ${CONTROLLER1_SCP_DEST}:/tmp/ovn_standalone_conversion/ovnnb_db.db /tmp/ovn_adoption_dbs/
67+
${CONTROLLER1_SCP} ${CONTROLLER1_SCP_DEST}:/tmp/ovn_standalone_conversion/ovnsb_db.db /tmp/ovn_adoption_dbs/
6468
6569
# Cleanup on controller
6670
$CONTROLLER1_SSH sudo rm -rf /tmp/ovn_standalone_conversion

tests/roles/ovn_adoption/tasks/cluster_to_standalone.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,18 @@
2323
# Create local temp directory
2424
mkdir -p /tmp/ovn_adoption_dbs
2525
26-
# Use scp like other parts of the codebase
27-
CONTROLLER1_SCP=$(echo "$CONTROLLER1_SSH" | sed 's/^ssh/scp/')
26+
# Build scp command from ssh command, wrapping the address in brackets
27+
# so that IPv6 colons are not confused with the scp host:path separator.
28+
# The last token is user@host; insert brackets around the host part only.
29+
CONTROLLER1_SCP=$(echo "$CONTROLLER1_SSH" | sed -e 's/^ssh/scp/' -e 's/ [^ ]*$//')
30+
CONTROLLER1_USERHOST=$(echo "$CONTROLLER1_SSH" | awk '{print $NF}')
31+
CONTROLLER1_SCP_DEST=$(echo "$CONTROLLER1_USERHOST" | sed 's/@\(.*\)/@[\1]/')
2832
2933
echo "Copying NB database to ansible controller..."
30-
${CONTROLLER1_SCP}:/tmp/ovn_standalone_conversion/ovnnb_db.db /tmp/ovn_adoption_dbs/
34+
${CONTROLLER1_SCP} ${CONTROLLER1_SCP_DEST}:/tmp/ovn_standalone_conversion/ovnnb_db.db /tmp/ovn_adoption_dbs/
3135
3236
echo "Copying SB database to ansible controller..."
33-
${CONTROLLER1_SCP}:/tmp/ovn_standalone_conversion/ovnsb_db.db /tmp/ovn_adoption_dbs/
37+
${CONTROLLER1_SCP} ${CONTROLLER1_SCP_DEST}:/tmp/ovn_standalone_conversion/ovnsb_db.db /tmp/ovn_adoption_dbs/
3438
3539
# Cleanup on controller
3640
$CONTROLLER1_SSH sudo rm -rf /tmp/ovn_standalone_conversion

0 commit comments

Comments
 (0)