Fix race at shutdown

Currently we first stop the zk connection and afterwards the
providers. This leads to a race condition where the providers may
still want to communicate with zk while the connection is already
dead. Instead stop the zk connection after stopping the providers.

This also fixes some occational and misleading zk connection
exception logs at the end of test cases.

Change-Id: Ibb13f74a1130190403dd79922ccd6c2b75daffc9
This commit is contained in:
Tobias Henkel 2018-07-06 08:43:06 +02:00
parent eb52394c8c
commit e8ee29c570
No known key found for this signature in database
GPG Key ID: 03750DEC158E5FA2

View File

@ -1270,9 +1270,10 @@ class NodePoolBuilder(object):
for worker in (workers):
worker.join()
self.log.debug('Stopping providers')
provider_manager.ProviderManager.stopProviders(self._config)
self.log.debug('Terminating ZooKeeper connection')
self.zk.disconnect()
self.log.debug('Stopping providers')
provider_manager.ProviderManager.stopProviders(self._config)
self.log.debug('Finished stopping')