Wait after service restart

We need to make sure the service has actually started before
proceeding. Otherwise, in the case of nova-compute for example, we
might go on to boot a server, only for the service to restart in the
middle of the boot process. There is no straightforward and uniform
way to wait for a service to actually be running after a restart, so
we just sleep 5 seconds. This is an ugly hack and needs to be made
more robust in the future.

Story: 2006856
Task: 37449
Change-Id: I4fe8a14035148ed0a6b1c83cabb57e34ada756b2
This commit is contained in:
Artom Lifshitz 2019-11-11 08:03:56 -05:00
parent 1814491c5f
commit f7ca78cb30

View File

@ -13,6 +13,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import time
import contextlib
import pymysql
from six import StringIO
@ -134,7 +136,16 @@ class ServiceManager(SSHClient):
return self.execute(command, container_name=None, sudo=True)
def restart(self):
return self.execute(self.restart_command, sudo=True)
result = self.execute(self.restart_command, sudo=True)
# TODO(artom) We need to make sure the service has actually started
# before proceeding. Otherwise, in the case of nova-compute for
# example, we might go on to boot a server, only for the service to
# restart in the middle of the boot process. There is no
# straightforward and uniform way to wait for a service to actually be
# running after a restart, so we just sleep 5 seconds. This is ugly
# hax, and we need to find something better.
time.sleep(5)
return result
class NUMAClient(SSHClient):