@@ -268,16 +268,33 @@ func extractPCLQNameFromPodName(podName string) string {
268268 return podName [:endIndex ]
269269}
270270
271- // podGangPredicate filters PodGang events to only trigger when Initialized=True
271+ // podGangPredicate filters PodGang events to trigger on initialization and spec updates
272272func podGangPredicate () predicate.Predicate {
273273 return predicate.Funcs {
274274 CreateFunc : func (_ event.CreateEvent ) bool { return false },
275275 DeleteFunc : func (_ event.DeleteEvent ) bool { return false },
276276 UpdateFunc : func (e event.UpdateEvent ) bool {
277- // Only trigger when PodGang transitions to Initialized=True
277+ oldPG , okOld := e .ObjectOld .(* groveschedulerv1alpha1.PodGang )
278+ newPG , okNew := e .ObjectNew .(* groveschedulerv1alpha1.PodGang )
279+ if ! okOld || ! okNew {
280+ return false
281+ }
282+
283+ // Trigger when PodGang transitions to Initialized=True
278284 oldInitialized := isPodGangInitialized (e .ObjectOld )
279285 newInitialized := isPodGangInitialized (e .ObjectNew )
280- return ! oldInitialized && newInitialized
286+ if ! oldInitialized && newInitialized {
287+ return true
288+ }
289+
290+ // Also trigger when PodGang spec changes (e.g., scale out/in adds/removes pod references)
291+ // This ensures scheduling gates are removed from newly added pods
292+ // Check if metadata.generation changed (Kubernetes increments this on spec changes)
293+ if newInitialized && oldPG .GetGeneration () != newPG .GetGeneration () {
294+ return true
295+ }
296+
297+ return false
281298 },
282299 GenericFunc : func (_ event.GenericEvent ) bool { return false },
283300 }
0 commit comments