Skip to content

Commit

Permalink
validate nbctl socket path in start-controller.sh (#1971)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzujian committed Oct 18, 2022
1 parent 3796a58 commit afe06d8
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions dist/images/start-controller.sh
Expand Up @@ -29,11 +29,29 @@ function gen_conn_str {
echo "$x"
}

if [[ "$ENABLE_SSL" == "false" ]]; then
export OVN_NB_DAEMON=$(ovn-nbctl --db="$(gen_conn_str 6641)" --pidfile --detach --overwrite-pidfile)
else
export OVN_NB_DAEMON=$(ovn-nbctl -p /var/run/tls/key -c /var/run/tls/cert -C /var/run/tls/cacert --db="$(gen_conn_str 6641)" --pidfile --detach --overwrite-pidfile)
nb_addr="$(gen_conn_str 6641)"
sb_addr="$(gen_conn_str 6642)"

for ((i=0; i<3; i++)); do
if [[ "$ENABLE_SSL" == "false" ]]; then
OVN_NB_DAEMON=$(ovn-nbctl --db="$nb_addr" --pidfile --detach --overwrite-pidfile)
else
OVN_NB_DAEMON=$(ovn-nbctl -p /var/run/tls/key -c /var/run/tls/cert -C /var/run/tls/cacert --db="$nb_addr" --pidfile --detach --overwrite-pidfile)
fi
if echo -n "${OVN_NB_DAEMON}" | grep -qE '^/var/run/ovn/ovn-nbctl\.[0-9]+\.ctl$'; then
export OVN_NB_DAEMON
break
fi
echo "invalid ovn-nbctl daemon socket: \"${OVN_NB_DAEMON}\""
unset OVN_NB_DAEMON
pkill -f ovn-nbctl
done

if [ -z "${OVN_NB_DAEMON}" ]; then
echo "failed to start ovn-nbctl daemon"
exit 1
fi
exec ./kube-ovn-controller --ovn-nb-addr="$(gen_conn_str 6641)" \
--ovn-sb-addr="$(gen_conn_str 6642)" \

exec ./kube-ovn-controller --ovn-nb-addr="$nb_addr" \
--ovn-sb-addr="$sb_addr" \
$@

0 comments on commit afe06d8

Please sign in to comment.