Skip to content

Commit

Permalink
support multiple containers in ServingRuntime (kubeflow#2321)
Browse files Browse the repository at this point in the history
Signed-off-by: Mark Winter <mark.winter@navercorp.com>
  • Loading branch information
markwinter authored Apr 1, 2023
1 parent cd30bfb commit 06fbfeb
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions pkg/controller/v1beta1/inferenceservice/components/predictor.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,19 @@ func (p *Predictor) Reconcile(isvc *v1beta1.InferenceService) (ctrl.Result, erro
})
return ctrl.Result{}, errors.New("no container configuration found in selected serving runtime")
}
// Assume only one container is specified in runtime spec.
container, err = isvcutils.MergeRuntimeContainers(&sRuntime.Containers[0], &isvc.Spec.Predictor.Model.Container)

kserveContainerIdx := -1
for i := range sRuntime.Containers {
if sRuntime.Containers[i].Name == constants.InferenceServiceContainerName {
kserveContainerIdx = i
break
}
}
if kserveContainerIdx == -1 {
return ctrl.Result{}, errors.New("failed to find kserve-container in ServingRuntime containers")
}

container, err = isvcutils.MergeRuntimeContainers(&sRuntime.Containers[kserveContainerIdx], &isvc.Spec.Predictor.Model.Container)
if err != nil {
isvc.Status.UpdateModelTransitionStatus(v1beta1.InvalidSpec, &v1beta1.FailureInfo{
Reason: v1beta1.InvalidPredictorSpec,
Expand All @@ -184,9 +195,6 @@ func (p *Predictor) Reconcile(isvc *v1beta1.InferenceService) (ctrl.Result, erro
return ctrl.Result{}, errors.Wrapf(err, "failed to consolidate serving runtime PodSpecs")
}

// Other dependencies rely on the container to be a specific name.
container.Name = constants.InferenceServiceContainerName

// Replace placeholders in runtime container by values from inferenceservice metadata
if err = isvcutils.ReplacePlaceholders(container, isvc.ObjectMeta); err != nil {
isvc.Status.UpdateModelTransitionStatus(v1beta1.InvalidSpec, &v1beta1.FailureInfo{
Expand All @@ -203,6 +211,8 @@ func (p *Predictor) Reconcile(isvc *v1beta1.InferenceService) (ctrl.Result, erro
podSpec.Containers = []v1.Container{
*container,
}
podSpec.Containers = append(podSpec.Containers, sRuntime.Containers[:kserveContainerIdx]...)
podSpec.Containers = append(podSpec.Containers, sRuntime.Containers[kserveContainerIdx+1:]...)

// Label filter will be handled in ksvc_reconciler
sRuntimeLabels = sRuntime.ServingRuntimePodSpec.Labels
Expand Down

0 comments on commit 06fbfeb

Please sign in to comment.