Avoid race between pod creation retry and namespace deletion
This patch ensure that if a namespace gets deleted and there is
a pending pod creation retry, the later will not fail due to the
subnet being already deleted.
Closes-Bug:
# License for the specific language governing permissions and limitations
# under the License.
+from neutronclient.common import exceptions as n_exc
from oslo_cache import core as cache
from oslo_config import cfg as oslo_cfg
from oslo_log import log as logging
@@ -91,8 +92,16 @@ class VIFHandler(k8s_base.ResourceEventHandler):
project_id = self._drv_project.get_project(pod)
security_groups = self._drv_sg.get_security_groups(pod, project_id)
if not state:
+ try:
subnets = self._drv_subnets.get_subnets(pod, project_id)
-
+ except n_exc.NotFound:
+ LOG.warning("Subnet does not exists. If namespace driver is "
+ "used, probably the namespace for the pod is "
+ "already deleted. So this pod does not need to "
+ "get a port as it will be deleted too. If the "
+ "default subnet driver is used, then you must "
+ "select an existing subnet to be used by Kuryr.")
+ return
# Request the default interface of pod
main_vif = self._drv_vif_pool.request_vif(
pod, project_id, subnets, security_groups)
