Skip to content

Commit 27c412b

Browse files
committed
Optimize the node filter
1 parent 7ebef00 commit 27c412b

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

pkg/controller/launcher-populator/interface.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,6 @@ const (
2424
LauncherGeneratedByLabelValue = "launcher-populator"
2525

2626
LauncherConfigNameLabelKey = "dual-pods.llm-d.ai/launcher-config-name"
27+
28+
NodeNameLabelKey = "node.kubernetes.io/node-name"
2729
)

pkg/controller/launcher-populator/populator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ func (ctl *controller) getCurrentLaunchersOnNode(ctx context.Context, key NodeLa
318318
launcherLabels := map[string]string{
319319
ComponentLabelKey: LauncherComponentLabelValue,
320320
LauncherConfigNameLabelKey: key.LauncherConfigName,
321+
NodeNameLabelKey: key.NodeName,
321322
}
322323
// Use podLister's List method with label selector
323324
pods, err := ctl.podLister.List(labels.SelectorFromSet(launcherLabels))
@@ -328,9 +329,7 @@ func (ctl *controller) getCurrentLaunchersOnNode(ctx context.Context, key NodeLa
328329
// Filter pods that are on the specified node
329330
var filteredPods []corev1.Pod
330331
for _, pod := range pods {
331-
if pod.Spec.NodeName == key.NodeName {
332-
filteredPods = append(filteredPods, *pod)
333-
}
332+
filteredPods = append(filteredPods, *pod)
334333
}
335334

336335
return filteredPods, nil
@@ -394,6 +393,7 @@ func (ctl *controller) buildPodFromTemplate(template corev1.PodTemplateSpec, key
394393
pod.Labels[ComponentLabelKey] = LauncherComponentLabelValue
395394
pod.Labels[LauncherGeneratedByLabelKey] = LauncherGeneratedByLabelValue
396395
pod.Labels[LauncherConfigNameLabelKey] = key.LauncherConfigName
396+
pod.Labels[NodeNameLabelKey] = key.NodeName
397397
// Assign to specific node
398398
pod.Spec.NodeName = key.NodeName
399399
return pod

0 commit comments

Comments
 (0)