Unverified Commit d8628cc4 authored by mohammedabdulwahhab's avatar mohammedabdulwahhab Committed by GitHub
Browse files

fix: fix cross selection issue amongst services in DGD (#6113)


Signed-off-by: default avatarmohammedabdulwahhab <furkhan324@berkeley.edu>
parent 4ad739dd
...@@ -1352,8 +1352,11 @@ func (r *DynamoComponentDeploymentReconciler) generateService(opt generateResour ...@@ -1352,8 +1352,11 @@ func (r *DynamoComponentDeploymentReconciler) generateService(opt generateResour
} }
selector := map[string]string{ selector := map[string]string{
commonconsts.KubeLabelDynamoComponentType: opt.dynamoComponentDeployment.Spec.ComponentType, commonconsts.KubeLabelDynamoComponentType: opt.dynamoComponentDeployment.Spec.ComponentType, // e.g. "worker"
commonconsts.KubeLabelDynamoNamespace: *opt.dynamoComponentDeployment.Spec.DynamoNamespace, commonconsts.KubeLabelDynamoNamespace: *opt.dynamoComponentDeployment.Spec.DynamoNamespace, // result of ComputeDynamoNamespace(k8sNamespace, dgdName)
// The original user provided component name (the service map key, e.g. "VllmDecodeWorker" in the DGD).
// Needed to disambiguate amongst distinct components with the same component type within a DGD (e.g prefill/decode workers).
commonconsts.KubeLabelDynamoComponent: opt.dynamoComponentDeployment.Spec.ServiceName,
} }
// // If using LeaderWorkerSet, modify selector to only target leaders // // If using LeaderWorkerSet, modify selector to only target leaders
if opt.dynamoComponentDeployment.IsMultinode() { if opt.dynamoComponentDeployment.IsMultinode() {
...@@ -1364,9 +1367,6 @@ func (r *DynamoComponentDeploymentReconciler) generateService(opt generateResour ...@@ -1364,9 +1367,6 @@ func (r *DynamoComponentDeploymentReconciler) generateService(opt generateResour
} }
if isK8sDiscovery { if isK8sDiscovery {
labels[commonconsts.KubeLabelDynamoDiscoveryBackend] = "kubernetes" labels[commonconsts.KubeLabelDynamoDiscoveryBackend] = "kubernetes"
}
// Discovery is enabled for non frontend components
if isK8sDiscovery && !opt.dynamoComponentDeployment.IsFrontendComponent() {
labels[commonconsts.KubeLabelDynamoDiscoveryEnabled] = commonconsts.KubeLabelValueTrue labels[commonconsts.KubeLabelDynamoDiscoveryEnabled] = commonconsts.KubeLabelValueTrue
} }
......
...@@ -550,7 +550,8 @@ func GenerateComponentService(ctx context.Context, dynamoDeployment *v1alpha1.Dy ...@@ -550,7 +550,8 @@ func GenerateComponentService(ctx context.Context, dynamoDeployment *v1alpha1.Dy
if component.DynamoNamespace == nil { if component.DynamoNamespace == nil {
return nil, fmt.Errorf("expected DynamoComponentDeployment %s to have a dynamoNamespace", componentName) return nil, fmt.Errorf("expected DynamoComponentDeployment %s to have a dynamoNamespace", componentName)
} }
componentName = GetDynamoComponentName(dynamoDeployment, componentName) // DNS-safe service resource name: "{dgd-name}-{lowercase(componentName)}"
kubeServiceName := GetDynamoComponentName(dynamoDeployment, componentName)
var servicePort corev1.ServicePort var servicePort corev1.ServicePort
switch component.ComponentType { switch component.ComponentType {
...@@ -593,14 +594,17 @@ func GenerateComponentService(ctx context.Context, dynamoDeployment *v1alpha1.Dy ...@@ -593,14 +594,17 @@ func GenerateComponentService(ctx context.Context, dynamoDeployment *v1alpha1.Dy
service := &corev1.Service{ service := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{ ObjectMeta: metav1.ObjectMeta{
Name: componentName, Name: kubeServiceName,
Namespace: dynamoDeployment.Namespace, Namespace: dynamoDeployment.Namespace,
Labels: labels, Labels: labels,
}, },
Spec: corev1.ServiceSpec{ Spec: corev1.ServiceSpec{
Selector: map[string]string{ Selector: map[string]string{
commonconsts.KubeLabelDynamoComponentType: component.ComponentType, commonconsts.KubeLabelDynamoComponentType: component.ComponentType, // e.g "worker"
commonconsts.KubeLabelDynamoNamespace: *component.DynamoNamespace, commonconsts.KubeLabelDynamoNamespace: *component.DynamoNamespace, // result of ComputeDynamoNamespace(k8sNamespace, dgdName)
// The original user provided component name (the service map key, e.g. "VllmDecodeWorker" in the DGD).
// Needed to disambiguate amongst distinct components with the same component type within a DGD (e.g prefill/decode workers).
commonconsts.KubeLabelDynamoComponent: componentName,
}, },
Ports: []corev1.ServicePort{servicePort}, Ports: []corev1.ServicePort{servicePort},
}, },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment