From 1baa8905d5a3d677b5298e76621b9e08e0ed0f13 Mon Sep 17 00:00:00 2001 From: yatinkarel <ykarel@redhat.com> Date: Fri, 6 May 2022 17:53:54 +0530 Subject: [PATCH] Wait for OVN dbs also along with sockets When OVN is setup from distro packages, the main service is ovn-central which when restarted, restarts ovn-northd, ovn nb and db services. And during the restart ovn dbs(ovnnb_db.db and ovnsb_db.db) are created, which may sometime takes time as seen with ubuntu jammy tests[1]. We already checking for socket's file to be available, let's also check for db files as without it ovn-*ctl operations succeed but changes are not persisted until db files are available and changes are lost with the restart. [1] https://review.opendev.org/c/openstack/devstack/+/839389 Change-Id: I178da7af8cba8bcc8a67174e439df7c0f2c7d4d5 --- lib/neutron_plugins/ovn_agent | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/neutron_plugins/ovn_agent b/lib/neutron_plugins/ovn_agent index 927896b70b..9022f2d382 100644 --- a/lib/neutron_plugins/ovn_agent +++ b/lib/neutron_plugins/ovn_agent @@ -169,6 +169,17 @@ Q_LOG_DRIVER_LOG_BASE=${Q_LOG_DRIVER_LOG_BASE:-acl_log_meter} # Utility Functions # ----------------- +function wait_for_db_file { + local count=0 + while [ ! -f $1 ]; do + sleep 1 + count=$((count+1)) + if [ "$count" -gt 5 ]; then + die $LINENO "DB File $1 not found" + fi + done +} + function wait_for_sock_file { local count=0 while [ ! -S $1 ]; do @@ -695,8 +706,11 @@ function start_ovn { fi # Wait for the service to be ready + # Check for socket and db files for both OVN NB and SB wait_for_sock_file $OVS_RUNDIR/ovnnb_db.sock wait_for_sock_file $OVS_RUNDIR/ovnsb_db.sock + wait_for_db_file $OVN_DATADIR/ovnnb_db.db + wait_for_db_file $OVN_DATADIR/ovnsb_db.db if is_service_enabled tls-proxy; then sudo ovn-nbctl --db=unix:$OVS_RUNDIR/ovnnb_db.sock set-ssl $INT_CA_DIR/private/$DEVSTACK_CERT_NAME.key $INT_CA_DIR/$DEVSTACK_CERT_NAME.crt $INT_CA_DIR/ca-chain.pem