Browse Source

Avoid race between NP creation and pod annotation

This patch ensure that NPs are not applied to pods that have not
yet being annotated. This will avoid the race and the pods will
get their SG updated anyway when the annotation happens.

Closes-Bug: 1817318
Change-Id: Idee99993fcf5f84a1b25a6154a6a8ce487f2f3f1
Luis Tomas Bolivar 2 months ago
parent
commit
7aef10a0f7
1 changed files with 10 additions and 8 deletions
  1. 10
    8
      kuryr_kubernetes/controller/drivers/neutron_vif.py

+ 10
- 8
kuryr_kubernetes/controller/drivers/neutron_vif.py View File

@@ -95,14 +95,16 @@ class NeutronPodVIFDriver(base.PodVIFDriver):
95 95
     def update_vif_sgs(self, pod, security_groups):
96 96
         neutron = clients.get_neutron_client()
97 97
         pod_state = utils.get_pod_state(pod)
98
-        # NOTE(ltomasbo): It just updates the default_vif security group
99
-        port_id = pod_state.vifs[constants.DEFAULT_IFNAME].id
100
-        neutron.update_port(port_id,
101
-                            {
102
-                                "port": {
103
-                                    'security_groups': list(security_groups)
104
-                                }
105
-                            })
98
+        if pod_state:
99
+            # NOTE(ltomasbo): It just updates the default_vif security group
100
+            port_id = pod_state.vifs[constants.DEFAULT_IFNAME].id
101
+            neutron.update_port(port_id,
102
+                                {
103
+                                    "port": {
104
+                                        'security_groups': list(
105
+                                            security_groups)
106
+                                    }
107
+                                })
106 108
 
107 109
     def _get_port_request(self, pod, project_id, subnets, security_groups,
108 110
                           unbound=False):

Loading…
Cancel
Save