@@ -47,8 +47,8 @@ func (ctrl *Controller) resolveEndpoint(trialRBG *v1alpha2.RoleBasedGroup) strin
4747 }
4848 return lifecycle .GetServiceEndpoint (trialRBG , & role , ctrl .namespace , port )
4949 }
50- // Last resort fallback: assume a default worker role at port 8000 .
51- return lifecycle .GetServiceEndpoint (trialRBG , & v1alpha2.RoleSpec {Name : "worker" }, ctrl .namespace , 8000 )
50+ // Last resort fallback: assume a default worker role at the engine's default port .
51+ return lifecycle .GetServiceEndpoint (trialRBG , & v1alpha2.RoleSpec {Name : "worker" }, ctrl .namespace , defaultEnginePort ( ctrl . cfg . Backend ) )
5252}
5353
5454// resolveRolePort extracts the inference port for a role.
@@ -94,20 +94,20 @@ func defaultEnginePort(backend string) int {
9494 }
9595}
9696
97- // extractServedModelName reads -- served-model-name from the base template's container args.
97+ // extractServedModelName reads the served-model-name flag from the base template's container args.
9898// Falls back to the RBG metadata name if the flag is not found.
99- func extractServedModelName (rbg * v1alpha2.RoleBasedGroup , backend string ) string {
100- flag := "--served-model-name"
101- if backend == "vllm" {
102- flag = "--served-model-name"
103- }
99+ func extractServedModelName (rbg * v1alpha2.RoleBasedGroup ) string {
100+ // Both vllm and sglang use --served-model-name.
101+ const flag = "--served-model-name"
104102 for _ , role := range rbg .Spec .Roles {
105103 podSpec := getRolePodSpec (& role )
106104 if podSpec == nil {
107105 continue
108106 }
109107 for _ , c := range podSpec .Containers {
110- allArgs := append (c .Command , c .Args ... )
108+ allArgs := make ([]string , 0 , len (c .Command )+ len (c .Args ))
109+ allArgs = append (allArgs , c .Command ... )
110+ allArgs = append (allArgs , c .Args ... )
111111 for i , arg := range allArgs {
112112 if arg == flag && i + 1 < len (allArgs ) {
113113 return allArgs [i + 1 ]
@@ -147,6 +147,9 @@ func (ctrl *Controller) waitRBGFullyReady(
147147 rbgReady := false
148148 httpClient := & http.Client {Timeout : 5 * time .Second }
149149
150+ // Resolve endpoint once — trialRBG is immutable for the duration of the wait.
151+ endpoint = ctrl .resolveEndpoint (trialRBG )
152+
150153 err = wait .PollUntilContextTimeout (ctx , 10 * time .Second , timeout , true , func (ctx context.Context ) (bool , error ) {
151154 if ! rbgReady {
152155 rbg , err := ctrl .manager .Get (ctx , trialName )
@@ -161,9 +164,12 @@ func (ctrl *Controller) waitRBGFullyReady(
161164 rbgReady = true
162165 }
163166
164- endpoint = ctrl .resolveEndpoint (trialRBG )
165167 healthURL := endpoint + "/health"
166- resp , err := httpClient .Get (healthURL )
168+ req , reqErr := http .NewRequestWithContext (ctx , http .MethodGet , healthURL , nil )
169+ if reqErr != nil {
170+ return false , nil
171+ }
172+ resp , err := httpClient .Do (req )
167173 if err != nil {
168174 logger .V (2 ).Info ("Endpoint not ready yet" , "error" , err .Error ())
169175 return false , nil // retry
@@ -200,7 +206,7 @@ func sanitizeLabelValue(name string) string {
200206 // Replace invalid characters with '-'
201207 invalidChars := regexp .MustCompile (`[^a-zA-Z0-9._-]` )
202208 name = invalidChars .ReplaceAllString (name , "-" )
203- name = strings .Trim (name , "-" )
209+ name = strings .Trim (name , "-._ " )
204210 if name == "" {
205211 name = "default"
206212 }
0 commit comments