Prevent Kuryr restart due to connection issue

In case the connection to Keystone is broken Kuryr controller is instantly
restarted. This may result in leftovers loadbalancers as a Kubernetes
service deletion can happen while the lbaas is still in PENDING_CREATE
and if the controller is restarted, the deletion event will be gone.
In this commit we give Kuryr a chance to retry the event before restarting.

Change-Id: Ie2cacc86e745bbd7da7254f7adfd9b41370936ab
Closes-bug: 1853460
This commit is contained in:
Maysa Macedo 2019-11-21 14:18:09 +00:00 committed by Maysa de Macedo Souza
parent ded5d4779d
commit 11ccc66118
1 changed files with 8 additions and 1 deletions

View File

@ -13,6 +13,10 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from requests import exceptions as requests_exc
from keystoneauth1 import exceptions as key_exc
from kuryr_kubernetes import exceptions from kuryr_kubernetes import exceptions
from kuryr_kubernetes.handlers import asynchronous as h_async from kuryr_kubernetes.handlers import asynchronous as h_async
from kuryr_kubernetes.handlers import dispatch as h_dis from kuryr_kubernetes.handlers import dispatch as h_dis
@ -55,7 +59,10 @@ class ControllerPipeline(h_dis.EventPipeline):
def _wrap_consumer(self, consumer): def _wrap_consumer(self, consumer):
# TODO(ivc): tune retry interval/timeout # TODO(ivc): tune retry interval/timeout
return h_log.LogExceptions(h_retry.Retry( return h_log.LogExceptions(h_retry.Retry(
consumer, exceptions=exceptions.ResourceNotReady)) consumer, exceptions=(
exceptions.ResourceNotReady,
key_exc.connection.ConnectFailure,
requests_exc.ConnectionError)))
def _wrap_dispatcher(self, dispatcher): def _wrap_dispatcher(self, dispatcher):
return h_log.LogExceptions(h_async.Async(dispatcher, self._tg, return h_log.LogExceptions(h_async.Async(dispatcher, self._tg,