Skip to content

Commit

Permalink
add sessions on hold to /getAISessionPoolsInfo data
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-astra-video committed Feb 18, 2025
1 parent 73f69fb commit 6d5f2ae
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions server/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,10 @@ type poolOrchestrator struct {

// aiPoolInfo contains information about an AI pool.
type aiPoolInfo struct {
Size int `json:"size"`
InUse int `json:"in_use"`
Orchestrators []poolOrchestrator `json:"orchestrators"`
Size int `json:"size"`
InUse int `json:"in_use"`
Orchestrators []poolOrchestrator `json:"orchestrators"`
OnHold map[string][]poolOrchestrator `json:"on_hold"`
}

// suspendedInfo contains information about suspended orchestrators.
Expand Down Expand Up @@ -342,8 +343,9 @@ func (s *LivepeerServer) getAIPoolsInfoHandler() http.Handler {
// Loop through selectors and get pools info.
for cap, pool := range s.AISessionManager.selectors {
warmPool := aiPoolInfo{
Size: pool.warmPool.Size(),
InUse: len(pool.warmPool.inUseSess),
Size: pool.warmPool.Size(),
InUse: len(pool.warmPool.inUseSess),
OnHold: make(map[string][]poolOrchestrator),

Check warning on line 348 in server/handlers.go

View check run for this annotation

Codecov / codecov/patch

server/handlers.go#L346-L348

Added lines #L346 - L348 were not covered by tests
}
for _, sess := range pool.warmPool.sessMap {
poolOrchestrator := poolOrchestrator{
Expand All @@ -353,6 +355,16 @@ func (s *LivepeerServer) getAIPoolsInfoHandler() http.Handler {
}
warmPool.Orchestrators = append(warmPool.Orchestrators, poolOrchestrator)
}
for id, sessions := range pool.warmPool.sessionsOnHold {
for _, sess := range sessions {
poolOrchestrator := poolOrchestrator{
Url: sess.Transcoder(),
LatencyScore: sess.LatencyScore,
InFlight: len(sess.SegsInFlight),
}
warmPool.OnHold[id] = append(warmPool.OnHold[id], poolOrchestrator)
}

Check warning on line 366 in server/handlers.go

View check run for this annotation

Codecov / codecov/patch

server/handlers.go#L358-L366

Added lines #L358 - L366 were not covered by tests
}

coldPool := aiPoolInfo{
Size: pool.coldPool.Size(),
Expand All @@ -365,7 +377,16 @@ func (s *LivepeerServer) getAIPoolsInfoHandler() http.Handler {
InFlight: len(sess.SegsInFlight),
})
}

for id, sessions := range pool.coldPool.sessionsOnHold {
for _, sess := range sessions {
poolOrchestrator := poolOrchestrator{
Url: sess.Transcoder(),
LatencyScore: sess.LatencyScore,
InFlight: len(sess.SegsInFlight),
}
coldPool.OnHold[id] = append(coldPool.OnHold[id], poolOrchestrator)
}

Check warning on line 388 in server/handlers.go

View check run for this annotation

Codecov / codecov/patch

server/handlers.go#L380-L388

Added lines #L380 - L388 were not covered by tests
}
aiPoolsInfoResp[cap] = aiOrchestratorPools{
Cold: coldPool,
Warm: warmPool,
Expand Down

0 comments on commit 6d5f2ae

Please sign in to comment.