Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1136)

Unified Diff: milo/appengine/buildbot/builder.go

Issue 2931773004: Milo: Add machine pool info for buildbot builder view. (Closed)
Patch Set: Rebase Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: milo/appengine/buildbot/builder.go
diff --git a/milo/appengine/buildbot/builder.go b/milo/appengine/buildbot/builder.go
index d8971b1b58786d73accc4616d774eab83f4bb5a6..54d9058e61dbff445bbad575f47faa6a8252bd55 100644
--- a/milo/appengine/buildbot/builder.go
+++ b/milo/appengine/buildbot/builder.go
@@ -164,6 +164,46 @@ func (e errBuilderNotFound) Error() string {
e.builder, e.master, avail)
}
+func summarizeSlavePool(
+ host string, slaves []string, slaveMap map[string]*buildbotSlave) *resp.MachinePool {
+
+ total := len(slaves)
+ idle := 0
+ busy := 0
+ disconnected := 0
+ bots := make([]resp.Bot, 0, len(slaves))
nodir 2017/06/13 02:38:40 MachinePool struct has all these variables. Consid
Ryan Tseng 2017/06/13 23:10:33 Done.
+ for _, slaveName := range slaves {
+ slave, ok := slaveMap[slaveName]
+ bot := resp.Bot{
+ Name: &resp.Link{
+ Label: slaveName,
+ URL: fmt.Sprintf("https://%s/buildslaves/%s", host, slaveName),
+ },
+ }
+ switch {
+ case !ok:
+ // This shouldn't happen
+ case !slave.Connected:
+ bot.Status = resp.Disconnected
+ disconnected++
+ case len(slave.RunningbuildsMap) > 0:
+ bot.Status = resp.Busy
+ busy++
+ default:
+ bot.Status = resp.Idle
+ idle++
+ }
+ bots = append(bots, bot)
+ }
+ return &resp.MachinePool{
+ Total: total,
+ Disconnected: disconnected,
+ Idle: idle,
+ Busy: busy,
+ Bots: bots,
+ }
+}
+
// builderImpl is the implementation for getting a milo builder page from buildbot.
// This gets:
// * Current Builds from querying the master json from the datastore.
@@ -184,7 +224,7 @@ func builderImpl(
result := &resp.Builder{
Name: builderName,
}
- master, t, err := getMasterJSON(c, masterName)
+ master, internal, t, err := getMasterJSON(c, masterName)
if err != nil {
return nil, err
}
@@ -226,6 +266,12 @@ func builderImpl(
}
}
+ host := "build.chromium.org/p/"
nodir 2017/06/13 02:38:40 this is not a host. Host cannot have a path. cons
Ryan Tseng 2017/06/13 23:10:33 Done.
+ if internal {
+ host = "uberchromegw.corp.google.com/i/"
+ }
+ result.MachinePool = summarizeSlavePool(host+master.Name, p.Slaves, master.Slaves)
+
// This is CPU bound anyways, so there's no need to do this in parallel.
finishedBuilds, nextCursor, err := getBuilds(c, masterName, builderName, true, limit, thisCursor)
if err != nil {

Powered by Google App Engine
This is Rietveld 408576698