From af247582219d0fb1c58df6b4f41c09b2f664223b Mon Sep 17 00:00:00 2001 From: Lorenzo Bianconi Date: Mon, 2 Dec 2024 16:34:06 +0100 Subject: [PATCH] Remove "-1" suffix to central container name for standalone-db scenario Signed-off-by: Lorenzo Bianconi --- .ci/test_basic.sh | 4 +-- .github/workflows/ci.yml | 1 + ovn_cluster.sh | 60 ++++++++++++++++++++++++++-------------- setup_dev.sh | 2 +- 4 files changed, 44 insertions(+), 23 deletions(-) diff --git a/.ci/test_basic.sh b/.ci/test_basic.sh index 3c1676e..6da5c5b 100755 --- a/.ci/test_basic.sh +++ b/.ci/test_basic.sh @@ -3,8 +3,8 @@ PODMAN_BIN=${1:-podman} # Simple configuration sanity checks -$PODMAN_BIN exec -it ovn-central-az1-1 ovn-nbctl show > nb_show -$PODMAN_BIN exec -it ovn-central-az1-1 ovn-sbctl show > sb_show +$PODMAN_BIN exec -it ovn-central-az1 ovn-nbctl show > nb_show +$PODMAN_BIN exec -it ovn-central-az1 ovn-sbctl show > sb_show grep "(public1)" nb_show grep "(sw01)" nb_show diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d77eb6c..e52664f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,7 @@ jobs: XDG_RUNTIME_DIR: '' OS_IMAGE: ${{ matrix.image.url }} OS_BASE: ${{ matrix.image.base }} + CENTRAL_IC_ID: ovn-central-az1 runs-on: ubuntu-latest steps: - name: Download ovn-fake-multinode diff --git a/ovn_cluster.sh b/ovn_cluster.sh index 16bc59e..7cf4cb9 100755 --- a/ovn_cluster.sh +++ b/ovn_cluster.sh @@ -175,10 +175,12 @@ function stop() { ovs-vsctl --if-exists del-br $OVN_EXT_BR || exit 1 else for name in "${CENTRAL_NAMES[@]}"; do - del-ovs-container-ports ${name}-1 if [ "$OVN_DB_CLUSTER" = "yes" ]; then + del-ovs-container-ports ${name}-1 del-ovs-container-ports ${name}-2 del-ovs-container-ports ${name}-3 + else + del-ovs-container-ports ${name} fi done for name in "${RELAY_NAMES[@]}"; do @@ -240,7 +242,7 @@ function add-ovs-container-ports() { echo "$name ${REMOTE_PROT}:$ip1:6642,${REMOTE_PROT}:$ip2:6642,${REMOTE_PROT}:$ip3:6642" >> _ovn_remote else ip=$(./ip_gen.py $ip_range/$cidr $ip_start $ip_index) - ./ovs-runc add-port $br $eth ${name}-1 --ipaddress=${ip}/${cidr} + ./ovs-runc add-port $br $eth ${name} --ipaddress=${ip}/${cidr} echo "$name ${REMOTE_PROT}:$ip:6642" >> _ovn_remote (( ip_index += 1)) fi @@ -288,10 +290,12 @@ function add-ovs-container-ports() { if [ "$ovn_central" == "yes" ]; then for name in "${CENTRAL_NAMES[@]}"; do - ./ovs-runc add-port ${OVN_EXT_BR} eth2 ${name}-1 if [ "$OVN_DB_CLUSTER" = "yes" ]; then + ./ovs-runc add-port ${OVN_EXT_BR} eth2 ${name}-1 ./ovs-runc add-port ${OVN_EXT_BR} eth2 ${name}-2 ./ovs-runc add-port ${OVN_EXT_BR} eth2 ${name}-3 + else + ./ovs-runc add-port ${OVN_EXT_BR} eth2 ${name} fi done for name in "${RELAY_NAMES[@]}"; do @@ -401,10 +405,12 @@ function wait-containers() { local done="1" if [ "${ovn_central}" == "yes" ]; then for name in "${CENTRAL_NAMES[@]}"; do - [[ $(count-containers "${name}-1") == "0" ]] && continue if [ "$OVN_DB_CLUSTER" = "yes" ]; then + [[ $(count-containers "${name}-1") == "0" ]] && continue [[ $(count-containers "${name}-2") == "0" ]] && continue [[ $(count-containers "${name}-3") == "0" ]] && continue + else + [[ $(count-containers "${name}") == "0" ]] && continue fi done for name in "${GW_NAMES[@]}"; do @@ -429,10 +435,12 @@ function provision-db-file() { local src=$2 for name in "${CENTRAL_NAMES[@]}"; do - ${RUNC_CMD} cp ${src} ${name}-1:/etc/ovn/ovn${db}_db.db if [ "$OVN_DB_CLUSTER" = "yes" ]; then + ${RUNC_CMD} cp ${src} ${name}-1:/etc/ovn/ovn${db}_db.db ${RUNC_CMD} cp ${src} ${name}-2:/etc/ovn/ovn${db}_db.db ${RUNC_CMD} cp ${src} ${name}-3:/etc/ovn/ovn${db}_db.db + else + ${RUNC_CMD} cp ${src} ${name}:/etc/ovn/ovn${db}_db.db fi done } @@ -527,16 +535,20 @@ function start-ovn-ic() { fi for name in "${CENTRAL_NAMES[@]}"; do - ${RUNC_CMD} exec ${name}-1 ${OVNCTL_PATH} \ - --ovn-ic-nb-db=tcp:${CENTRAL_IC_IP}:6645 \ - --ovn-ic-sb-db=tcp:${CENTRAL_IC_IP}:6646 start_ic if [ "$OVN_DB_CLUSTER" = "yes" ]; then + ${RUNC_CMD} exec ${name}-1 ${OVNCTL_PATH} \ + --ovn-ic-nb-db=tcp:${CENTRAL_IC_IP}:6645 \ + --ovn-ic-sb-db=tcp:${CENTRAL_IC_IP}:6646 start_ic ${RUNC_CMD} exec ${name}-2 ${OVNCTL_PATH} \ --ovn-ic-nb-db=tcp:${CENTRAL_IC_IP}:6645 \ --ovn-ic-sb-db=tcp:${CENTRAL_IC_IP}:6646 start_ic ${RUNC_CMD} exec ${name}-3 ${OVNCTL_PATH} \ --ovn-ic-nb-db=tcp:${CENTRAL_IC_IP}:6645 \ --ovn-ic-sb-db=tcp:${CENTRAL_IC_IP}:6646 start_ic + else + ${RUNC_CMD} exec ${name} ${OVNCTL_PATH} \ + --ovn-ic-nb-db=tcp:${CENTRAL_IC_IP}:6645 \ + --ovn-ic-sb-db=tcp:${CENTRAL_IC_IP}:6646 start_ic fi done } @@ -612,10 +624,12 @@ function start() { # Create containers if [ "$ovn_central" == "yes" ]; then for name in "${CENTRAL_NAMES[@]}"; do - start-container "${CENTRAL_IMAGE}" "${name}-1" if [ "$OVN_DB_CLUSTER" = "yes" ]; then + start-container "${CENTRAL_IMAGE}" "${name}-1" start-container "${CENTRAL_IMAGE}" "${name}-2" start-container "${CENTRAL_IMAGE}" "${name}-3" + else + start-container "${CENTRAL_IMAGE}" "${name}" fi done @@ -652,9 +666,10 @@ function start() { fi for name in "${CENTRAL_NAMES[@]}"; do - central=${name}-1 + [ "$OVN_DB_CLUSTER" = "yes" ] && CENTRAL=${name}-1 || CENTRAL=${name} + if [ "$ENABLE_ETCD" == "yes" ]; then - central=${name} + CENTRAL=${name} echo "Starting ovsdb-etcd in ${name} container" ${RUNC_CMD} exec --detach ${name} bash -c "/run_ovsdb_etcd.sh" sleep 2 @@ -664,22 +679,22 @@ function start() { elif [ "$OVN_DB_CLUSTER" = "yes" ]; then start-db-cluster ${name} else - ${RUNC_CMD} exec ${name}-1 ${OVNCTL_PATH} start_northd + ${RUNC_CMD} exec ${CENTRAL} ${OVNCTL_PATH} start_northd sleep 2 fi if [ "$ENABLE_SSL" == "yes" ]; then - ${RUNC_CMD} exec ${central} ovn-nbctl set-ssl ${SSL_CERTS_PATH}/ovn-privkey.pem ${SSL_CERTS_PATH}/ovn-cert.pem ${SSL_CERTS_PATH}/pki/switchca/cacert.pem - ${RUNC_CMD} exec ${central} ovn-sbctl set-ssl ${SSL_CERTS_PATH}/ovn-privkey.pem ${SSL_CERTS_PATH}/ovn-cert.pem ${SSL_CERTS_PATH}/pki/switchca/cacert.pem + ${RUNC_CMD} exec ${CENTRAL} ovn-nbctl set-ssl ${SSL_CERTS_PATH}/ovn-privkey.pem ${SSL_CERTS_PATH}/ovn-cert.pem ${SSL_CERTS_PATH}/pki/switchca/cacert.pem + ${RUNC_CMD} exec ${CENTRAL} ovn-sbctl set-ssl ${SSL_CERTS_PATH}/ovn-privkey.pem ${SSL_CERTS_PATH}/ovn-cert.pem ${SSL_CERTS_PATH}/pki/switchca/cacert.pem fi - ${RUNC_CMD} exec ${central} ovn-nbctl set-connection p${REMOTE_PROT}:6641 - ${RUNC_CMD} exec ${central} ovn-nbctl set connection . inactivity_probe=180000 + ${RUNC_CMD} exec ${CENTRAL} ovn-nbctl set-connection p${REMOTE_PROT}:6641 + ${RUNC_CMD} exec ${CENTRAL} ovn-nbctl set connection . inactivity_probe=180000 - ${RUNC_CMD} exec ${central} ovn-nbctl set NB_Global . name=${central} \ + ${RUNC_CMD} exec ${CENTRAL} ovn-nbctl set NB_Global . name=${CENTRAL} \ options:ic-route-adv=true options:ic-route-learn=true - ${RUNC_CMD} exec ${central} ovn-sbctl set-connection p${REMOTE_PROT}:6642 - ${RUNC_CMD} exec ${central} ovn-sbctl set connection . inactivity_probe=180000 + ${RUNC_CMD} exec ${CENTRAL} ovn-sbctl set-connection p${REMOTE_PROT}:6642 + ${RUNC_CMD} exec ${CENTRAL} ovn-sbctl set connection . inactivity_probe=180000 done # start ovn-ic dbs @@ -827,7 +842,12 @@ EOF ${RUNC_CMD} exec ${CENTRAL_IC_ID} ovn-nbctl ls-list | grep -q ts1 && break done - ${RUNC_CMD} exec ${CENTRAL_PREFIX}${az}-1 bash /data/create_ovn_res.sh $az $ic + if [ "$OVN_DB_CLUSTER" = "yes" ]; then + ${RUNC_CMD} exec ${CENTRAL_PREFIX}${az}-1 bash /data/create_ovn_res.sh $az $ic + else + ${RUNC_CMD} exec ${CENTRAL_PREFIX}${az} bash /data/create_ovn_res.sh $az $ic + fi + cat << EOF > ${FAKENODE_MNT_DIR}/create_fake_vm.sh #!/bin/bash diff --git a/setup_dev.sh b/setup_dev.sh index bb4877a..9303c22 100755 --- a/setup_dev.sh +++ b/setup_dev.sh @@ -396,7 +396,7 @@ function start_traffic() # function configure_ovn() { - ! podman exec ovn-central-az1-1 ovn-nbctl acl-add sw01 to-lport 100 "ip4.src==10.128.2.2" allow-related + ! podman exec ovn-central-az1 ovn-nbctl acl-add sw01 to-lport 100 "ip4.src==10.128.2.2" allow-related podman exec ovn-chassis-1 ip netns exec sw01p1 ip link set dev sw01p1 mtu 1440 podman exec ovn-chassis-1 ip netns exec sw01p3 ip link set dev sw01p3 mtu 1440 podman exec ovn-chassis-2 ip netns exec sw01p4 ip link set dev sw01p4 mtu 1440