Skip to content

Commit 2df853a

Browse files
committed
historyserver: add serve applications endpoint
1 parent 3536abe commit 2df853a

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

historyserver/pkg/historyserver/router.go

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,14 +478,40 @@ func (s *ServerHandler) getDatasets(req *restful.Request, resp *restful.Response
478478
}
479479

480480
func (s *ServerHandler) getServeApplications(req *restful.Request, resp *restful.Response) {
481+
clusterName := req.Attribute(COOKIE_CLUSTER_NAME_KEY).(string)
482+
clusterNamespace := req.Attribute(COOKIE_CLUSTER_NAMESPACE_KEY).(string)
481483
sessionName := req.Attribute(COOKIE_SESSION_NAME_KEY).(string)
484+
482485
if sessionName == "live" {
483486
s.redirectRequest(req, resp)
484487
return
485488
}
486489

487-
// Return "not yet supported" for serve applications
488-
resp.WriteErrorString(http.StatusNotImplemented, "Serve applications not yet supported")
490+
// Dead (historical) cluster:
491+
// Collector has already periodically persisted the live Ray Dashboard
492+
// /api/serve/applications/ response into the meta directory under the
493+
// OssMetaFile_Applications key. Here we simply read that snapshot and
494+
// return it so that live and historical clusters share the same response
495+
// format.
496+
rayClusterNameID := fmt.Sprintf("%s_%s", clusterName, clusterNamespace)
497+
data := s.MetaKeyInfo(rayClusterNameID, utils.OssMetaFile_Applications)
498+
499+
// If no metadata has been persisted yet, return an empty applications
500+
// payload matching Ray's ServeDetails schema.
501+
if len(data) == 0 {
502+
empty := map[string]interface{}{
503+
"applications": map[string]interface{}{},
504+
}
505+
var err error
506+
data, err = json.Marshal(empty)
507+
if err != nil {
508+
logrus.Errorf("Failed to marshal empty serve applications response: %v", err)
509+
resp.WriteErrorString(http.StatusInternalServerError, err.Error())
510+
return
511+
}
512+
}
513+
514+
resp.Write(data)
489515
}
490516

491517
func (s *ServerHandler) getPlacementGroups(req *restful.Request, resp *restful.Response) {

historyserver/test/support/historyserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ const (
5959
// - /api/prometheus_health
6060
// - /api/data/datasets/{job_id}
6161
// - /api/jobs
62-
// - /api/serve/applications
6362
// - /api/v0/placement_groups
6463
var HistoryServerEndpoints = []string{
6564
"/nodes?view=summary",
65+
"/api/serve/applications",
6666
"/api/v0/tasks",
6767
"/api/v0/tasks/summarize",
6868
"/logical/actors",

0 commit comments

Comments
 (0)