Browse Source

Adapt selfLink calculation for KuryrLoadBalancer CRD objects.

Implements: blueprint selflink
Change-Id: I1654572b4653df939d61e0a9875b42c32a26f748
changes/31/768331/9
Roman Dobosz 2 months ago
parent
commit
3bd82fe69f
4 changed files with 31 additions and 29 deletions
  1. +1
    -1
      kuryr_kubernetes/controller/drivers/lbaasv2.py
  2. +3
    -3
      kuryr_kubernetes/controller/handlers/lbaas.py
  3. +25
    -25
      kuryr_kubernetes/controller/handlers/loadbalancer.py
  4. +2
    -0
      kuryr_kubernetes/tests/unit/controller/handlers/test_loadbalancer.py

+ 1
- 1
kuryr_kubernetes/controller/drivers/lbaasv2.py View File

@ -857,7 +857,7 @@ class LBaaSv2Driver(base.LBaaSDriver):
lb = klb['status']['loadbalancer']
try:
k8s.patch_crd('status/loadbalancer', klb['metadata']['selfLink'],
k8s.patch_crd('status/loadbalancer', utils.get_res_link(klb),
{'security_groups': sgs})
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadBalancer CRD not found %s', lbaas_name)


+ 3
- 3
kuryr_kubernetes/controller/handlers/lbaas.py View File

@ -174,8 +174,8 @@ class ServiceHandler(k8s_base.ResourceEventHandler):
spec = self._build_kuryrloadbalancer_spec(service)
LOG.debug('Patching KuryrLoadBalancer CRD %s', loadbalancer_crd)
try:
kubernetes.patch_crd('spec', loadbalancer_crd['metadata'][
'selfLink'], spec)
kubernetes.patch_crd('spec', utils.get_res_link(loadbalancer_crd),
spec)
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadBalancer CRD not found %s', loadbalancer_crd)
except k_exc.K8sConflict:
@ -374,7 +374,7 @@ class EndpointsHandler(k8s_base.ResourceEventHandler):
try:
kubernetes.patch_crd(
'spec',
loadbalancer_crd['metadata']['selfLink'],
utils.get_res_link(loadbalancer_crd),
spec)
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadbalancer CRD not found %s', loadbalancer_crd)


+ 25
- 25
kuryr_kubernetes/controller/handlers/loadbalancer.py View File

@ -98,9 +98,8 @@ class KuryrLoadBalancerHandler(k8s_base.ResourceEventHandler):
self._update_lb_status(loadbalancer_crd)
kubernetes = clients.get_kubernetes_client()
try:
kubernetes.patch_crd('status', loadbalancer_crd[
'metadata']['selfLink'], loadbalancer_crd[
'status'])
kubernetes.patch_crd('status', utils.get_res_link(
loadbalancer_crd), loadbalancer_crd['status'])
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadbalancer CRD not found %s',
loadbalancer_crd)
@ -202,8 +201,7 @@ class KuryrLoadBalancerHandler(k8s_base.ResourceEventHandler):
lb['security_groups'] = lb_sgs
try:
k8s.patch_crd('status/loadbalancer',
klb_crd['metadata']['selfLink'],
k8s.patch_crd('status/loadbalancer', utils.get_res_link(klb_crd),
{'security_groups': lb_sgs})
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadBalancer %s not found', svc_name)
@ -327,9 +325,8 @@ class KuryrLoadBalancerHandler(k8s_base.ResourceEventHandler):
member)
kubernetes = clients.get_kubernetes_client()
try:
kubernetes.patch_crd('status', loadbalancer_crd[
'metadata']['selfLink'], loadbalancer_crd[
'status'])
kubernetes.patch_crd('status', utils.get_res_link(
loadbalancer_crd), loadbalancer_crd['status'])
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadbalancer CRD not found %s',
loadbalancer_crd)
@ -440,9 +437,9 @@ class KuryrLoadBalancerHandler(k8s_base.ResourceEventHandler):
kubernetes = clients.get_kubernetes_client()
try:
kubernetes.patch_crd('status', loadbalancer_crd[
'metadata']['selfLink'], loadbalancer_crd[
'status'])
kubernetes.patch_crd('status',
utils.get_res_link(loadbalancer_crd),
loadbalancer_crd['status'])
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadbalancer CRD not found %s',
loadbalancer_crd)
@ -489,8 +486,9 @@ class KuryrLoadBalancerHandler(k8s_base.ResourceEventHandler):
pool)
kubernetes = clients.get_kubernetes_client()
try:
kubernetes.patch_crd('status', loadbalancer_crd['metadata'][
'selfLink'], loadbalancer_crd['status'])
kubernetes.patch_crd('status',
utils.get_res_link(loadbalancer_crd),
loadbalancer_crd['status'])
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadbalancer CRD not found %s',
loadbalancer_crd)
@ -535,9 +533,9 @@ class KuryrLoadBalancerHandler(k8s_base.ResourceEventHandler):
kubernetes = clients.get_kubernetes_client()
try:
kubernetes.patch_crd('status', loadbalancer_crd[
'metadata']['selfLink'], loadbalancer_crd[
'status'])
kubernetes.patch_crd('status',
utils.get_res_link(loadbalancer_crd),
loadbalancer_crd['status'])
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadbalancer CRD not found %s',
loadbalancer_crd)
@ -611,8 +609,9 @@ class KuryrLoadBalancerHandler(k8s_base.ResourceEventHandler):
kubernetes = clients.get_kubernetes_client()
try:
kubernetes.patch_crd('status', loadbalancer_crd[
'metadata']['selfLink'], loadbalancer_crd['status'])
kubernetes.patch_crd('status',
utils.get_res_link(loadbalancer_crd),
loadbalancer_crd['status'])
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadbalancer CRD not found %s',
loadbalancer_crd)
@ -641,9 +640,9 @@ class KuryrLoadBalancerHandler(k8s_base.ResourceEventHandler):
kubernetes = clients.get_kubernetes_client()
try:
kubernetes.patch_crd('status', loadbalancer_crd[
'metadata']['selfLink'], loadbalancer_crd[
'status'])
kubernetes.patch_crd('status',
utils.get_res_link(loadbalancer_crd),
loadbalancer_crd['status'])
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadbalancer CRD not found %s',
loadbalancer_crd)
@ -715,8 +714,9 @@ class KuryrLoadBalancerHandler(k8s_base.ResourceEventHandler):
kubernetes = clients.get_kubernetes_client()
try:
kubernetes.patch_crd('status', loadbalancer_crd['metadata'][
'selfLink'], loadbalancer_crd['status'])
kubernetes.patch_crd('status',
utils.get_res_link(loadbalancer_crd),
loadbalancer_crd['status'])
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadbalancer CRD not found %s',
loadbalancer_crd)
@ -757,8 +757,8 @@ class KuryrLoadBalancerHandler(k8s_base.ResourceEventHandler):
loadbalancer_crd['status'] = {}
k8s = clients.get_kubernetes_client()
try:
k8s.patch_crd('status', loadbalancer_crd['metadata'][
'selfLink'], loadbalancer_crd['status'])
k8s.patch_crd('status', utils.get_res_link(loadbalancer_crd),
loadbalancer_crd['status'])
except k_exc.K8sResourceNotFound:
LOG.debug('KuryrLoadbalancer CRD not found %s',
loadbalancer_crd)


+ 2
- 0
kuryr_kubernetes/tests/unit/controller/handlers/test_loadbalancer.py View File

@ -30,6 +30,8 @@ _SUPPORTED_LISTENER_PROT = ('HTTP', 'HTTPS', 'TCP')
def get_lb_crd():
return {
'apiVersion': 'openstack.org/v1',
'kind': 'KuryrLoadBalancer',
"metadata": {
"creationTimestamp": "2020-07-28T13:13:30Z",
"finalizers": [


Loading…
Cancel
Save