Skip to content

Commit 779effd

Browse files
committed
Remove the default values
1 parent dffec9f commit 779effd

2 files changed

Lines changed: 11 additions & 53 deletions

File tree

pkg/controller/launcher-populator/interface.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,4 @@ const (
2626
LauncherConfigNameLabelKey = "dual-pods.llm-d.ai/launcher-config-name"
2727

2828
NodeNameLabelKey = "dual-pods.llm-d.ai/node-name"
29-
30-
PortDiscoveryAnnotationKey = "inference.networking.x-k8s.io/port-discovery"
31-
32-
PortDiscoveryAnnotationEmptyValue = "[]"
3329
)

pkg/controller/launcher-populator/populator.go

Lines changed: 11 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"encoding/base64"
2323
"encoding/json"
2424
"fmt"
25-
"os"
2625

2726
"github.com/llm-d-incubation/llm-d-fast-model-actuation/pkg/api"
2827
dualpods "github.com/llm-d-incubation/llm-d-fast-model-actuation/pkg/controller/dual-pods"
@@ -357,7 +356,10 @@ func (ctl *controller) createLaunchers(ctx context.Context, node corev1.Node, ke
357356

358357
// Create the specified number of launcher pods
359358
for i := 0; i < count; i++ {
360-
pod := ctl.buildPodFromTemplate(launcherConfig.Spec.PodTemplate, key)
359+
pod, err := ctl.buildPodFromTemplate(launcherConfig.Spec.PodTemplate, key)
360+
if err != nil {
361+
return fmt.Errorf("failed to build launcher pod: %w", err)
362+
}
361363
pod.GenerateName = fmt.Sprintf("launcher-%s-", launcherConfig.Name)
362364
// Set owner reference pointing to LauncherConfig
363365
ownerRef := *metav1.NewControllerRef(launcherConfig, fmav1alpha1.SchemeGroupVersion.WithKind("LauncherConfig"))
@@ -389,7 +391,7 @@ func (ctl *controller) deleteExcessLaunchers(ctx context.Context, launchers []co
389391
}
390392

391393
// buildPodFromTemplate creates a pod from a template and assigns it to a node
392-
func (ctl *controller) buildPodFromTemplate(template corev1.PodTemplateSpec, key NodeLauncherKey) *corev1.Pod {
394+
func (ctl *controller) buildPodFromTemplate(template corev1.PodTemplateSpec, key NodeLauncherKey) (*corev1.Pod, error) {
393395
pod := &corev1.Pod{
394396
ObjectMeta: template.ObjectMeta,
395397
Spec: *utils.DeIndividualize(template.Spec.DeepCopy()),
@@ -421,33 +423,11 @@ func (ctl *controller) buildPodFromTemplate(template corev1.PodTemplateSpec, key
421423
}
422424
pod.Annotations = dualpods.MapSet(pod.Annotations, genctlr.NominalHashAnnotationKey, nominalHash)
423425

424-
pod.Annotations[PortDiscoveryAnnotationKey] = PortDiscoveryAnnotationEmptyValue
425-
426-
pod.Spec.RestartPolicy = corev1.RestartPolicyNever
427-
428-
// Process container list, keep only one container and apply fixed configuration
429-
if len(pod.Spec.Containers) == 0 {
430-
// If there are no containers in the template, create a default container
431-
pod.Spec.Containers = []corev1.Container{
432-
{
433-
Name: api.InferenceServerContainerName,
434-
},
435-
}
436-
} else {
437-
// If there are multiple containers in the template, keep only the first one and rename it to inference-server
438-
container := &pod.Spec.Containers[0]
439-
container.Name = api.InferenceServerContainerName
440-
}
441-
442-
container := &pod.Spec.Containers[0]
443-
// @TODO Should set to specified Launcher image, replacing the default image
444-
launcherImage := os.Getenv("LAUNCHER_IMAGE")
445-
if launcherImage != "" {
446-
container.Image = launcherImage
426+
cIdx, serverPort, err := utils.GetInferenceServerPort(pod)
427+
if err != nil {
428+
return nil, err
447429
}
448-
449-
// Ensure port configuration includes port 8001
450-
ensurePortExists(container, 8001, "health", corev1.ProtocolTCP)
430+
container := &pod.Spec.Containers[cIdx]
451431

452432
// Configure required environment variables
453433
configureRequiredEnvVars(container)
@@ -457,7 +437,7 @@ func (ctl *controller) buildPodFromTemplate(template corev1.PodTemplateSpec, key
457437
ProbeHandler: corev1.ProbeHandler{
458438
HTTPGet: &corev1.HTTPGetAction{
459439
Path: "/health",
460-
Port: intstr.FromInt(8001),
440+
Port: intstr.FromInt(int(serverPort)),
461441
Scheme: corev1.URISchemeHTTP,
462442
},
463443
},
@@ -478,25 +458,7 @@ func (ctl *controller) buildPodFromTemplate(template corev1.PodTemplateSpec, key
478458

479459
// Assign to specific node
480460
pod.Spec.NodeName = key.NodeName
481-
return pod
482-
}
483-
484-
// ensurePortExists adds the specified port if it doesn't already exist
485-
func ensurePortExists(container *corev1.Container, port int32, name string, protocol corev1.Protocol) {
486-
portExists := false
487-
for _, existingPort := range container.Ports {
488-
if existingPort.ContainerPort == port {
489-
portExists = true
490-
break
491-
}
492-
}
493-
if !portExists {
494-
container.Ports = append(container.Ports, corev1.ContainerPort{
495-
Name: name,
496-
ContainerPort: port,
497-
Protocol: protocol,
498-
})
499-
}
461+
return pod, nil
500462
}
501463

502464
// configureRequiredEnvVars adds or updates required environment variables

0 commit comments

Comments
 (0)