Include more events for Pods
This commit includes more Kubernetes events to notify the user about the progress when handling a Pod event. Change-Id: I87abc65aee41036d6c69f1b65f061885851f4a14
This commit is contained in:
parent
1c4a1a5ead
commit
d930d50392
@ -99,13 +99,13 @@ class K8sCNIRegistryPlugin(base_cni.CNIPlugin):
|
|||||||
pod = k_utils.get_referenced_object(data, 'Pod')
|
pod = k_utils.get_referenced_object(data, 'Pod')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.k8s.add_event(pod, 'CNIWaitingForVIFs',
|
self.k8s.add_event(pod, 'CNIWaitingForActiveVIFs',
|
||||||
f'Waiting for Neutron ports of {kp_name} to '
|
f'Waiting for Neutron ports of {kp_name} to '
|
||||||
f'become ACTIVE after binding.',
|
f'become ACTIVE after binding.',
|
||||||
component='kuryr-daemon')
|
component='kuryr-daemon')
|
||||||
vifs = wait_for_active(kp_name)
|
vifs = wait_for_active(kp_name)
|
||||||
except retrying.RetryError:
|
except retrying.RetryError:
|
||||||
self.k8s.add_event(pod, 'CNITimedOutWaitingForVIFs',
|
self.k8s.add_event(pod, 'CNITimedOutWaitingForActiveVIFs',
|
||||||
f'Timed out waiting for Neutron ports of '
|
f'Timed out waiting for Neutron ports of '
|
||||||
f'{kp_name} to become ACTIVE after binding.',
|
f'{kp_name} to become ACTIVE after binding.',
|
||||||
'Warning', 'kuryr-daemon')
|
'Warning', 'kuryr-daemon')
|
||||||
|
@ -117,7 +117,11 @@ class KuryrPortHandler(k8s_base.ResourceEventHandler):
|
|||||||
project_id = self._drv_project.get_project(pod)
|
project_id = self._drv_project.get_project(pod)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
kp_name = kuryrport_crd['metadata']['name']
|
||||||
self._update_kuryrport_crd(kuryrport_crd, vifs)
|
self._update_kuryrport_crd(kuryrport_crd, vifs)
|
||||||
|
self.k8s.add_event(pod, 'KuryrPortUpdatedWithActiveVIFs',
|
||||||
|
f'KuryrPort CRD: {kp_name} updated with'
|
||||||
|
f' active VIFs')
|
||||||
except k_exc.K8sResourceNotFound as ex:
|
except k_exc.K8sResourceNotFound as ex:
|
||||||
LOG.exception("Failed to update KuryrPort CRD: %s", ex)
|
LOG.exception("Failed to update KuryrPort CRD: %s", ex)
|
||||||
security_groups = self._drv_sg.get_security_groups(
|
security_groups = self._drv_sg.get_security_groups(
|
||||||
@ -265,10 +269,13 @@ class KuryrPortHandler(k8s_base.ResourceEventHandler):
|
|||||||
LOG.warning("SG not found during VIF requesting. Retrying.")
|
LOG.warning("SG not found during VIF requesting. Retrying.")
|
||||||
raise k_exc.ResourceNotReady(pod['metadata']['name'])
|
raise k_exc.ResourceNotReady(pod['metadata']['name'])
|
||||||
|
|
||||||
|
pod_name = pod['metadata']['name']
|
||||||
if not main_vif:
|
if not main_vif:
|
||||||
pod_name = pod['metadata']['name']
|
|
||||||
LOG.warning("Ignoring event due to pod %s not being "
|
LOG.warning("Ignoring event due to pod %s not being "
|
||||||
"scheduled yet.", pod_name)
|
"scheduled yet.", pod_name)
|
||||||
|
self.k8s.add_event(pod, 'KuryrIgnoringPodEvent',
|
||||||
|
f'Ignoring event: Pod not scheduled '
|
||||||
|
f'{pod_name}')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
vifs = {constants.DEFAULT_IFNAME: {'default': True, 'vif': main_vif}}
|
vifs = {constants.DEFAULT_IFNAME: {'default': True, 'vif': main_vif}}
|
||||||
@ -285,6 +292,8 @@ class KuryrPortHandler(k8s_base.ResourceEventHandler):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self._update_kuryrport_crd(kuryrport_crd, vifs)
|
self._update_kuryrport_crd(kuryrport_crd, vifs)
|
||||||
|
self.k8s.add_event(pod, 'KuryrPortUpdatedWithVIFs',
|
||||||
|
f'KuryrPort CRD: {pod_name} updated with VIFs')
|
||||||
except k_exc.K8sClientException as ex:
|
except k_exc.K8sClientException as ex:
|
||||||
LOG.exception("Kubernetes Client Exception creating "
|
LOG.exception("Kubernetes Client Exception creating "
|
||||||
"KuryrPort CRD: %s", ex)
|
"KuryrPort CRD: %s", ex)
|
||||||
@ -335,7 +344,7 @@ class KuryrPortHandler(k8s_base.ResourceEventHandler):
|
|||||||
return self.k8s.get(f"{constants.K8S_API_NAMESPACES}"
|
return self.k8s.get(f"{constants.K8S_API_NAMESPACES}"
|
||||||
f"/{namespace}/pods/{name}")
|
f"/{namespace}/pods/{name}")
|
||||||
except k_exc.K8sResourceNotFound as ex:
|
except k_exc.K8sResourceNotFound as ex:
|
||||||
self.k8s.add_event(kuryrport_crd,
|
self.k8s.add_event(kuryrport_crd, 'KuryrFailedGettingPod'
|
||||||
f'Failed to get corresponding pod: {ex}',
|
f'Failed to get corresponding pod: {ex}',
|
||||||
'Warning')
|
'Warning')
|
||||||
LOG.exception("Failed to get pod: %s", ex)
|
LOG.exception("Failed to get pod: %s", ex)
|
||||||
|
@ -183,11 +183,10 @@ class VIFHandler(k8s_base.ResourceEventHandler):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def _add_kuryrport_crd(self, pod, vifs=None):
|
def _add_kuryrport_crd(self, pod):
|
||||||
LOG.debug('Adding CRD %s', pod["metadata"]["name"])
|
LOG.debug('Adding CRD %s', pod["metadata"]["name"])
|
||||||
|
|
||||||
if not vifs:
|
vifs = {}
|
||||||
vifs = {}
|
|
||||||
|
|
||||||
owner_reference = {'apiVersion': pod['apiVersion'],
|
owner_reference = {'apiVersion': pod['apiVersion'],
|
||||||
'kind': pod['kind'],
|
'kind': pod['kind'],
|
||||||
|
Loading…
Reference in New Issue
Block a user