Skip to content

Commit

Permalink
Force recreation of ovs db cluster on first replica when protocol cha…
Browse files Browse the repository at this point in the history
…nges

Cannot remove final cluster member to change protocol, but can convert
to standalone schema. Cluster gets recreated with the correct address.
  • Loading branch information
olliewalsh committed Oct 10, 2024
1 parent 577feca commit f493261
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion templates/ovndbcluster/bin/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@ if ! [ -s $DB_FILE ]; then
cleanup_db_file
fi

# Must remove a cluster member to change protocol, replicas 1/2 will have
# left the cluster when terminating the pod, but cannot remove final member from
# a cluster (replica 0).
# Convert db to standalone mode on this member instead.
# Cluster then gets recreated by ovnctl run_*b_ovsdb using the new local address.
if [ "$(hostname)" == "{{ .SERVICE_NAME }}-0" ]; then
DB_LOCAL_ADDR={{ if .TLS }}ssl{{ else }}tcp{{ end }}:$(hostname).{{ .SERVICE_NAME }}.${NAMESPACE}.svc.cluster.local:${RAFT_PORT}
if [ -e ${DB_FILE} ] && \
ovsdb-tool db-is-clustered ${DB_FILE} && \
[ "$(ovsdb-tool db-local-address ${DB_FILE})" != "${DB_LOCAL_ADDR}" ] \
; \
then
mv -f ${DB_FILE} /tmp/ovn_db_tmp_standalone.db
ovsdb-tool cluster-to-standalone ${DB_FILE} /tmp/ovn_db_tmp_standalone.db
fi
fi

# Wait until the ovsdb-tool finishes.
trap wait_for_ovsdb_tool EXIT

Expand All @@ -106,8 +123,8 @@ if [[ "$(hostname)" == "{{ .SERVICE_NAME }}-0" ]]; then

{{- if .TLS }}
${CTLCMD} set-ssl {{.OVNDB_KEY_PATH}} {{.OVNDB_CERT_PATH}} {{.OVNDB_CACERT_PATH}}
${CTLCMD} set-connection ${DB_SCHEME}:${DB_PORT}:${DB_ADDR}
{{- end }}
${CTLCMD} set-connection ${DB_SCHEME}:${DB_PORT}:${DB_ADDR}

# OVN does not support setting inactivity-probe through --remote cli arg so
# we have to set it after database is up.
Expand Down

0 comments on commit f493261

Please sign in to comment.