Add aws environments to the statistics
but only with the field usedRunners.
This commit is contained in:
@ -59,5 +59,13 @@ func (n *AbstractManager) Delete(id dto.EnvironmentID) (bool, error) {
|
||||
}
|
||||
|
||||
func (n *AbstractManager) Statistics() map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData {
|
||||
return map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData{}
|
||||
if n.runnerManager == nil {
|
||||
return map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData{}
|
||||
}
|
||||
|
||||
statistics := n.NextHandler().Statistics()
|
||||
for k, v := range n.runnerManager.EnvironmentStatistics() {
|
||||
statistics[k] = v
|
||||
}
|
||||
return statistics
|
||||
}
|
||||
|
@ -59,6 +59,11 @@ func (a *AWSEnvironment) Sample() (r runner.Runner, ok bool) {
|
||||
|
||||
// The following methods are not supported at this moment.
|
||||
|
||||
// IdleRunnerCount is not supported as we have no information about the AWS managed prewarming pool.
|
||||
func (a *AWSEnvironment) IdleRunnerCount() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
// PrewarmingPoolSize is neither supported nor required. It is handled transparently by AWS.
|
||||
func (a *AWSEnvironment) PrewarmingPoolSize() uint {
|
||||
return 0
|
||||
@ -111,7 +116,3 @@ func (a *AWSEnvironment) AddRunner(_ runner.Runner) {
|
||||
func (a *AWSEnvironment) DeleteRunner(_ string) {
|
||||
panic("not supported")
|
||||
}
|
||||
|
||||
func (a *AWSEnvironment) IdleRunnerCount() int {
|
||||
panic("not supported")
|
||||
}
|
||||
|
@ -67,7 +67,3 @@ func isAWSEnvironment(request dto.ExecutionEnvironmentRequest) bool {
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (a *AWSEnvironmentManager) Statistics() map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData {
|
||||
return a.NextHandler().Statistics()
|
||||
}
|
||||
|
@ -120,10 +120,6 @@ func (m *NomadEnvironmentManager) CreateOrUpdate(id dto.EnvironmentID, request d
|
||||
return !isExistingEnvironment, nil
|
||||
}
|
||||
|
||||
func (m *NomadEnvironmentManager) Statistics() map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData {
|
||||
return m.runnerManager.EnvironmentStatistics()
|
||||
}
|
||||
|
||||
func (m *NomadEnvironmentManager) Load() error {
|
||||
templateJobs, err := m.api.LoadEnvironmentJobs()
|
||||
if err != nil {
|
||||
|
@ -58,7 +58,17 @@ func (n *AbstractManager) DeleteEnvironment(id dto.EnvironmentID) {
|
||||
}
|
||||
|
||||
func (n *AbstractManager) EnvironmentStatistics() map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData {
|
||||
return map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData{}
|
||||
environments := make(map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData)
|
||||
for _, e := range n.environments.List() {
|
||||
environments[e.ID()] = &dto.StatisticalExecutionEnvironmentData{
|
||||
ID: int(e.ID()),
|
||||
PrewarmingPoolSize: e.PrewarmingPoolSize(),
|
||||
IdleRunners: uint(e.IdleRunnerCount()),
|
||||
UsedRunners: 0,
|
||||
}
|
||||
}
|
||||
|
||||
return environments
|
||||
}
|
||||
|
||||
func (n *AbstractManager) Claim(_ dto.EnvironmentID, _ int) (Runner, error) {
|
||||
|
@ -45,3 +45,22 @@ func (a AWSRunnerManager) Return(r Runner) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// EnvironmentStatistics returns only the used runner for each environment as the prewarming is handled
|
||||
// by AWS transparently.
|
||||
func (a AWSRunnerManager) EnvironmentStatistics() map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData {
|
||||
environments := a.AbstractManager.EnvironmentStatistics()
|
||||
|
||||
for _, r := range a.usedRunners.List() {
|
||||
workload, isAWSRunner := r.(*AWSFunctionWorkload)
|
||||
if !isAWSRunner {
|
||||
log.WithField("workload", workload).Error("Stored runners must be AWS runner")
|
||||
continue
|
||||
}
|
||||
|
||||
environmentID := workload.environment.ID()
|
||||
environments[environmentID].UsedRunners++
|
||||
}
|
||||
|
||||
return environments
|
||||
}
|
||||
|
@ -35,15 +35,7 @@ func NewNomadRunnerManager(apiClient nomad.ExecutorAPI, ctx context.Context) *No
|
||||
}
|
||||
|
||||
func (m *NomadRunnerManager) EnvironmentStatistics() map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData {
|
||||
environments := make(map[dto.EnvironmentID]*dto.StatisticalExecutionEnvironmentData)
|
||||
for _, e := range m.environments.List() {
|
||||
environments[e.ID()] = &dto.StatisticalExecutionEnvironmentData{
|
||||
ID: int(e.ID()),
|
||||
PrewarmingPoolSize: e.PrewarmingPoolSize(),
|
||||
IdleRunners: uint(e.IdleRunnerCount()),
|
||||
UsedRunners: 0,
|
||||
}
|
||||
}
|
||||
environments := m.AbstractManager.EnvironmentStatistics()
|
||||
|
||||
for _, r := range m.usedRunners.List() {
|
||||
id, err := nomad.EnvironmentIDFromRunnerID(r.ID())
|
||||
|
Reference in New Issue
Block a user