Skip to content

Commit 586c480

Browse files
committed
Polish the label key and value
1 parent 008f455 commit 586c480

2 files changed

Lines changed: 30 additions & 27 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
Copyright 2025 The llm-d Authors.
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
http://www.apache.org/licenses/LICENSE-2.0
7+
Unless required by applicable law or agreed to in writing, software
8+
distributed under the License is distributed on an "AS IS" BASIS,
9+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
See the License for the specific language governing permissions and
11+
limitations under the License.
12+
*/
13+
14+
package launcherpool
15+
16+
const (
17+
ComponentLabelKey = "app.kubernetes.io/component"
18+
LauncherComponentLabelValue = "launcher"
19+
20+
LauncherGeneratedByLabelKey = "dual-pods.llm-d.ai/generated-by"
21+
LauncherGeneratedByLabelValue = "launcher-pool"
22+
23+
LauncherConfigNameLabelKey = "dual-pods.llm-d.ai/launcher-config-name"
24+
)

pkg/controller/launcher-pool/populator.go

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@ import (
4545

4646
const ControllerName = "launcher-pool-populator"
4747

48-
const (
49-
LauncherComponentAnnotationKey = "dual-pods.llm-d.ai/component"
50-
LauncherComponentAnnotationValue = "launcher"
51-
)
52-
5348
type Controller interface {
5449
Start(context.Context) error
5550
}
@@ -76,17 +71,11 @@ func NewController(
7671
lcInformer: fmaInformerFactory.Fma().V1alpha1().LauncherConfigs().Informer(),
7772
lcLister: fmaInformerFactory.Fma().V1alpha1().LauncherConfigs().Lister(),
7873
}
79-
err := ctl.podInformer.AddIndexers(cache.Indexers{
80-
launcherPodIndexName: launcherIndexFunc,
81-
})
82-
if err != nil { //impossible
83-
return nil, err
84-
}
8574

8675
// Use a single worker thread to ensure sequential processing of LauncherPopulationPolicy updates
8776
// Prevents race conditions when multiple threads simultaneously modify the same node/configuration pairs
8877
ctl.QueueAndWorkers = genctlr.NewQueueAndWorkers(ControllerName, 1, ctl.process)
89-
_, err = ctl.podInformer.AddEventHandler(ctl)
78+
_, err := ctl.podInformer.AddEventHandler(ctl)
9079
if err != nil {
9180
panic(err)
9281
}
@@ -134,17 +123,6 @@ type lppItem struct {
134123
cache.ObjectName
135124
}
136125

137-
const launcherPodIndexName = "launcher"
138-
139-
func launcherIndexFunc(obj any) ([]string, error) {
140-
pod := obj.(*corev1.Pod)
141-
if pod.Annotations[LauncherComponentAnnotationKey] == LauncherComponentAnnotationValue {
142-
return []string{string(pod.UID)}, nil
143-
}
144-
145-
return []string{}, nil
146-
}
147-
148126
func (ctl *controller) OnAdd(obj any, isInInitialList bool) {
149127
switch typed := obj.(type) {
150128
case *fmav1alpha1.LauncherPopulationPolicy:
@@ -321,8 +299,8 @@ func (ctl *controller) reconcileLaunchersOnNode(ctx context.Context, key NodeLau
321299
// getCurrentLaunchersOnNode returns launcher pods for a specific config on a specific node
322300
func (ctl *controller) getCurrentLaunchersOnNode(ctx context.Context, key NodeLauncherKey) ([]corev1.Pod, error) {
323301
launcherLabels := map[string]string{
324-
LauncherComponentAnnotationKey: LauncherComponentAnnotationValue,
325-
"app.kubernetes.io/launcher-config-name": key.LauncherConfigName,
302+
ComponentLabelKey: LauncherComponentLabelValue,
303+
LauncherConfigNameLabelKey: key.LauncherConfigName,
326304
}
327305
// Use podLister's List method with label selector
328306
pods, err := ctl.podLister.List(labels.SelectorFromSet(launcherLabels))
@@ -399,8 +377,9 @@ func (ctl *controller) buildPodFromTemplate(template corev1.PodTemplateSpec, key
399377
if pod.Labels == nil {
400378
pod.Labels = make(map[string]string)
401379
}
402-
pod.Labels["app.kubernetes.io/component"] = "launcher"
403-
pod.Labels["app.kubernetes.io/launcher-config-name"] = key.LauncherConfigName
380+
pod.Labels[ComponentLabelKey] = LauncherComponentLabelValue
381+
pod.Labels[LauncherGeneratedByLabelKey] = LauncherGeneratedByLabelValue
382+
pod.Labels[LauncherConfigNameLabelKey] = key.LauncherConfigName
404383
// Assign to specific node
405384
pod.Spec.NodeName = key.NodeName
406385
return pod

0 commit comments

Comments
 (0)