@@ -25,6 +25,8 @@ import (
2525 "net/http"
2626 "net/url"
2727 "time"
28+
29+ "k8s.io/klog/v2"
2830)
2931
3032type LauncherClient struct {
@@ -50,25 +52,24 @@ func NewLauncherClient(baseURL string) (*LauncherClient, error) {
5052
5153// VllmConfig matches the launcher API schema.
5254type VllmConfig struct {
53- Options string `json:"options"`
54- GpuUUIDs []string `json:"gpu_uuids,omitempty"`
55- EnvVars map [string ]string `json:"env_vars,omitempty"`
55+ Options string `json:"options"`
56+ GpuUUIDs []string `json:"gpu_uuids,omitempty"`
57+ EnvVars map [string ]string `json:"env_vars,omitempty"`
58+ Annotations map [string ]string `json:"annotations,omitempty"`
5659}
5760
58- // InstanceStatus returned by status APIs.
59- type InstanceStatus struct {
60- InstanceID string `json:"instance_id"`
61- Status string `json:"status"`
62- Options string `json:"options"`
63- GpuUUIDs []string `json:"gpu_uuids,omitempty"`
64- EnvVars map [string ]string `json:"env_vars,omitempty"`
61+ // InstanceState returned by launcher API.
62+ type InstanceState struct {
63+ InstanceID string `json:"instance_id"`
64+ Status string `json:"status"`
65+ VllmConfig `json:",inline"`
6566}
6667
67- // AllInstancesStatus response.
68- type AllInstancesStatus struct {
69- TotalInstances int `json:"total_instances"`
70- RunningInstances int `json:"running_instances"`
71- Instances []InstanceStatus `json:"instances"`
68+ // AllInstancesState response.
69+ type AllInstancesState struct {
70+ TotalInstances int `json:"total_instances"`
71+ RunningInstances int `json:"running_instances"`
72+ Instances []InstanceState `json:"instances"`
7273}
7374
7475// Generic response for creation and deletion.
@@ -95,13 +96,13 @@ func (c *LauncherClient) CreateNamedInstance(
9596 return c .create (ctx , path , http .MethodPut , cfg )
9697}
9798
98- // GetInstanceStatus returns the status of a single instance.
99- func (c * LauncherClient ) GetInstanceStatus (
99+ // GetInstanceState returns the state of a single instance.
100+ func (c * LauncherClient ) GetInstanceState (
100101 ctx context.Context ,
101102 instanceID string ,
102- ) (* InstanceStatus , error ) {
103+ ) (* InstanceState , error ) {
103104 path := fmt .Sprintf ("/v2/vllm/instances/%s" , instanceID )
104- var out InstanceStatus
105+ var out InstanceState
105106 if err := c .do (ctx , http .MethodGet , path , nil , & out ); err != nil {
106107 return nil , err
107108 }
@@ -111,8 +112,8 @@ func (c *LauncherClient) GetInstanceStatus(
111112// ListInstances returns all instances with status.
112113func (c * LauncherClient ) ListInstances (
113114 ctx context.Context ,
114- ) (* AllInstancesStatus , error ) {
115- var out AllInstancesStatus
115+ ) (* AllInstancesState , error ) {
116+ var out AllInstancesState
116117 if err := c .do (ctx , http .MethodGet , "/v2/vllm/instances" , nil , & out ); err != nil {
117118 return nil , err
118119 }
@@ -216,8 +217,11 @@ func (c *LauncherClient) do(
216217 }
217218
218219 if out != nil {
219- return json .NewDecoder (resp .Body ).Decode (out )
220+ respBytes , _ := io .ReadAll (resp .Body )
221+ _ = resp .Body .Close ()
222+ err = json .NewDecoder (bytes .NewReader (respBytes )).Decode (out )
223+ klog .FromContext (ctx ).V (6 ).Info ("Decoded response body" , "body" , string (respBytes ), "decoded" , out , "err" , err )
220224 }
221225
222- return nil
226+ return err
223227}
0 commit comments