mirror of
https://github.com/kemko/nomad.git
synced 2026-01-10 12:25:42 +03:00
Changed signature of Allocation Stats Reporter
This commit is contained in:
@@ -31,7 +31,6 @@ type AllocStateUpdater func(alloc *structs.Allocation)
|
||||
// AllocStatsReporter exposes stats related APIs of an allocation runner
|
||||
type AllocStatsReporter interface {
|
||||
AllocStats() map[string]TaskStatsReporter
|
||||
TaskStats(task string) (TaskStatsReporter, error)
|
||||
}
|
||||
|
||||
// AllocRunner is used to wrap an allocation and provide the execution context.
|
||||
|
||||
@@ -37,7 +37,12 @@ const (
|
||||
|
||||
// TaskStatsReporter exposes APIs to query resource usage of a Task
|
||||
type TaskStatsReporter interface {
|
||||
// ResourceUsage returns the latest resource usage data point collected for
|
||||
// the task
|
||||
ResourceUsage() *cstructs.TaskResourceUsage
|
||||
|
||||
// ResourceUsageTS returns all the resource usage data points since a given
|
||||
// time
|
||||
ResourceUsageTS(since time.Time) []*cstructs.TaskResourceUsage
|
||||
}
|
||||
|
||||
|
||||
@@ -76,8 +76,8 @@ func (s *HTTPServer) ClientAllocRequest(resp http.ResponseWriter, req *http.Requ
|
||||
}
|
||||
|
||||
if task := req.URL.Query().Get("task"); task != "" {
|
||||
taskStats, err := allocStats.TaskStats(task)
|
||||
if err != nil {
|
||||
taskStats, ok := allocStats.AllocStats()[task]
|
||||
if !ok {
|
||||
return nil, CodedError(404, "task not present in allocation")
|
||||
}
|
||||
return taskStats.ResourceUsage(), nil
|
||||
|
||||
Reference in New Issue
Block a user