Show error messages when resources are stuck

If an Octavia loadbalancer is stuck in PENDING_UPDATE state or Neutron
port is DOWN despite being plugged there's not much Kuryr can do. For
such cases we need to clearly message the user that the error they're
seeing is caused by OpenStack service misbehaving and not Kuryr.

This commit does so by making sure in such cases we raise a distinct
version of ResourceNotReady exception.

Change-Id: I2dd1e8989caf004b3dee0cb51780a45ce8d9353c
Closes-Bug: 1918711
This commit is contained in:
Michał Dulko 2021-06-17 17:30:17 +02:00
parent 862deaa455
commit a17e5502c2
4 changed files with 20 additions and 3 deletions

View File

@ -835,7 +835,7 @@ class LBaaSv2Driver(base.LBaaSDriver):
{'status': status, 'lb': loadbalancer,
'rem': remaining})
raise k_exc.ResourceNotReady(loadbalancer)
raise k_exc.LoadBalancerNotReady(loadbalancer['id'], status)
def _wait_for_deletion(self, loadbalancer, timeout,
interval=_LB_STS_POLL_FAST_INTERVAL):

View File

@ -122,7 +122,7 @@ class NestedVlanPodVIFDriver(nested_vif.NestedPodVIFDriver):
def activate_vif(self, vif, pod=None, retry_info=None):
try:
super().activate_vif(vif)
except k_exc.ResourceNotReady:
except k_exc.PortNotReady:
if retry_info and retry_info.get('elapsed', 0) > ACTIVE_TIMEOUT:
parent_port = self._get_parent_port(pod)
trunk_id = self._get_trunk_id(parent_port)

View File

@ -105,7 +105,7 @@ class NeutronPodVIFDriver(base.PodVIFDriver):
raise k_exc.ResourceNotReady(vif)
if port['status'] != kl_const.PORT_STATUS_ACTIVE:
raise k_exc.ResourceNotReady(vif)
raise k_exc.PortNotReady(vif.id, port['status'])
vif.active = True

View File

@ -38,6 +38,23 @@ class ResourceNotReady(Exception):
super(ResourceNotReady, self).__init__("Resource not ready: %r" % msg)
class LoadBalancerNotReady(ResourceNotReady):
def __init__(self, loadbalancer_id, status):
super().__init__(
'Loadbalancer %s is stuck in %s status for several minutes. This '
'is unexpected and indicates problem with OpenStack Octavia. '
'Please contact your OpenStack administrator.' % (
loadbalancer_id, status))
class PortNotReady(ResourceNotReady):
def __init__(self, port_id, status):
super().__init__(
'Port %s is stuck in %s status for several minutes. This '
'is unexpected and indicates problem with OpenStack Neutron. '
'Please contact your OpenStack administrator.' % (port_id, status))
class K8sResourceNotFound(K8sClientException):
def __init__(self, resource):
super(K8sResourceNotFound, self).__init__("Resource not "