@@ -215,8 +215,15 @@ func (c *Controller) enqueueAddPod(obj interface{}) {
215
215
return
216
216
}
217
217
218
- klog .V (3 ).Infof ("enqueue add pod %s" , key )
219
- c .addOrUpdatePodQueue .Add (key )
218
+ exist , err := c .podNeedSync (p )
219
+ if err != nil {
220
+ klog .Errorf ("invalid pod net: %v" , err )
221
+ return
222
+ }
223
+ if exist {
224
+ klog .Infof ("enqueue add pod %s" , key )
225
+ c .addOrUpdatePodQueue .Add (key )
226
+ }
220
227
}
221
228
222
229
func (c * Controller ) enqueueDeletePod (obj interface {}) {
@@ -239,7 +246,7 @@ func (c *Controller) enqueueDeletePod(obj interface{}) {
239
246
return
240
247
}
241
248
242
- klog .V ( 3 ). Infof ("enqueue delete pod %s" , key )
249
+ klog .Infof ("enqueue delete pod %s" , key )
243
250
c .deletingPodObjMap .Store (key , p )
244
251
c .deletePodQueue .Add (key )
245
252
}
@@ -337,7 +344,7 @@ func (c *Controller) enqueueUpdatePod(oldObj, newObj interface{}) {
337
344
}()
338
345
return
339
346
}
340
-
347
+ klog . Infof ( "enqueue update pod %s" , key )
341
348
c .addOrUpdatePodQueue .Add (key )
342
349
343
350
// security policy changed
@@ -1210,6 +1217,28 @@ func needAllocateSubnets(pod *v1.Pod, nets []*kubeovnNet) []*kubeovnNet {
1210
1217
return result
1211
1218
}
1212
1219
1220
+ func (c * Controller ) podNeedSync (pod * v1.Pod ) (bool , error ) {
1221
+ // 1. check annotations
1222
+ if pod .Annotations == nil {
1223
+ return true , nil
1224
+ }
1225
+ // 2. check annotation ovn subnet
1226
+ if pod .Annotations [util .RoutedAnnotation ] != "true" {
1227
+ return true , nil
1228
+ }
1229
+ // 3. check multus subnet
1230
+ attachmentNets , err := c .getPodAttachmentNet (pod )
1231
+ if err != nil {
1232
+ return false , err
1233
+ }
1234
+ for _ , n := range attachmentNets {
1235
+ if pod .Annotations [fmt .Sprintf (util .RoutedAnnotationTemplate , n .ProviderName )] != "true" {
1236
+ return true , nil
1237
+ }
1238
+ }
1239
+ return false , nil
1240
+ }
1241
+
1213
1242
func needRouteSubnets (pod * v1.Pod , nets []* kubeovnNet ) []* kubeovnNet {
1214
1243
if ! isPodAlive (pod ) {
1215
1244
return nil
0 commit comments