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

Unified Diff: milo/appengine/swarming/build.go

Issue 2669473002: Milo: Remove swarming tags from build properties (Closed)
Patch Set: Created 3 years, 11 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/swarming/build.go
diff --git a/milo/appengine/swarming/build.go b/milo/appengine/swarming/build.go
index be8b356f72ba9ab267cf81f2e6bbac006b725c3d..402f41c90d548b9e6437105c33703c8601381ccc 100644
--- a/milo/appengine/swarming/build.go
+++ b/milo/appengine/swarming/build.go
@@ -170,50 +170,32 @@ func taskProperties(sr *swarming.SwarmingRpcsTaskResult) *resp.PropertyGroup {
return props
}
-func tagsToProperties(tags []string) *resp.PropertyGroup {
- props := &resp.PropertyGroup{GroupName: "Swarming Tags"}
+func tagsToMap(tags []string) map[string]string {
+ result := map[string]string{}
for _, t := range tags {
if t == "" {
continue
}
parts := strings.SplitN(t, ":", 2)
- p := &resp.Property{
- Key: parts[0],
- }
if len(parts) == 2 {
- p.Value = parts[1]
- }
- props.Property = append(props.Property, p)
- }
- return props
-}
-
-// tagValue returns a value of the first tag matching the tag key. If not found
-// returns "".
-func tagValue(tags []string, key string) string {
- prefix := key + ":"
- for _, t := range tags {
- if strings.HasPrefix(t, prefix) {
- return strings.TrimPrefix(t, prefix)
+ result[parts[0]] = parts[1]
nodir 2017/02/07 21:56:29 are you sure tag keys are unique? add a func comme
hinoka 2017/02/24 00:56:22 Tags keys are supposed to be unique. If a second
}
}
- return ""
+ return result
}
// addBuilderLink adds a link to the buildbucket builder view.
-func addBuilderLink(c context.Context, build *resp.MiloBuild, swarmingHostname string, sr *swarming.SwarmingRpcsTaskResult) {
- bbHost := tagValue(sr.Tags, "buildbucket_hostname")
- bucket := tagValue(sr.Tags, "buildbucket_bucket")
- builder := tagValue(sr.Tags, "builder")
+func addBuilderLink(c context.Context, build *resp.MiloBuild, selfURL string, props map[string]string) {
nodir 2017/02/07 21:56:30 it is not obvious what "self" means here. Task? Co
nodir 2017/02/07 21:56:30 s/props/tags/ in swarming land, properties mean s
hinoka 2017/02/24 00:56:22 Actually I just removed this entirely. No need to
hinoka 2017/02/24 00:56:22 Done.
+ bbHost := props["buildbucket_hostname"]
+ bucket := props["buildbucket_bucket"]
+ builder := props["builder"]
if bucket == "" {
logging.Errorf(
- c, "Could not extract buidlbucket bucket from task %s",
- taskPageURL(swarmingHostname, sr.TaskId))
+ c, "Could not extract buidlbucket bucket from task %s", selfURL)
}
if builder == "" {
logging.Errorf(
- c, "Could not extract builder name from task %s",
- taskPageURL(swarmingHostname, sr.TaskId))
+ c, "Could not extract builder name from task %s", selfURL)
}
if bucket != "" && builder != "" {
build.Summary.ParentLabel = &resp.Link{
@@ -224,20 +206,13 @@ func addBuilderLink(c context.Context, build *resp.MiloBuild, swarmingHostname s
}
// addBanner adds an OS banner derived from "os" swarming tag, if present.
-func addBanner(build *resp.MiloBuild, sr *swarming.SwarmingRpcsTaskResult) {
- var os, ver string
- for _, t := range sr.Tags {
- value := strings.TrimPrefix(t, "os:")
- if value == t {
- // t does not have the prefix
- continue
- }
- parts := strings.SplitN(value, "-", 2)
- if len(parts) == 2 {
- os = parts[0]
- ver = parts[1]
- break
- }
+func addBanner(build *resp.MiloBuild, props map[string]string) {
nodir 2017/02/07 21:56:29 s/props/tags/
hinoka 2017/02/24 00:56:22 Done.
+ os := props["os"]
+ var ver string
+ parts := strings.SplitN(os, "-", 2)
+ if len(parts) == 2 {
+ os = parts[0]
+ ver = parts[1]
}
var base resp.LogoBase
@@ -348,24 +323,66 @@ func addTaskToMiloStep(c context.Context, server string, sr *swarming.SwarmingRp
return nil
}
+func addBuildsetInfo(build *resp.MiloBuild, props map[string]string) {
nodir 2017/02/07 21:56:29 s/props/tags/
hinoka 2017/02/24 00:56:22 Done.
+ buildset := props["buildset"]
+ if strings.HasPrefix(buildset, "patch/") {
+ if build.SourceStamp == nil {
nodir 2017/02/07 21:56:29 ah, this is why an empty SourceStamp section appea
hinoka 2017/02/24 00:56:22 Done.
+ build.SourceStamp = &resp.SourceStamp{}
+ }
+ patchset := strings.TrimLeft(buildset, "patch/")
+ if strings.HasPrefix(patchset, "gerrit/") {
+ gerritset := strings.TrimLeft(patchset, "gerrit/")
nodir 2017/02/07 21:56:30 gerritPatchset?
hinoka 2017/02/24 00:56:22 Done.
+ parts := strings.Split(gerritset, "/")
+ if len(parts) == 3 {
+ build.SourceStamp.Changelist = &resp.Link{
+ Label: "Gerrit CL",
+ URL: fmt.Sprintf("https://%s/r/%s/%s", parts[0], parts[1], parts[2]),
nodir 2017/02/07 21:56:30 never saw /r/ before. did you mean c?
hinoka 2017/02/24 00:56:22 Oops fixed.
+ }
+ }
+ }
+ }
+}
+
+func addRecipeLink(build *resp.MiloBuild, props map[string]string) {
nodir 2017/02/07 21:56:30 tags
hinoka 2017/02/24 00:56:22 Done.
+ name := props["recipe_name"]
+ repo := props["recipe_repository"]
+ revision := props["recipe_revision"]
+ if name != "" && repo != "" {
+ subpath := "/+/"
nodir 2017/02/07 21:56:30 move /+/ to the format string
hinoka 2017/03/01 22:53:10 Done.
+ if revision != "" {
+ subpath += revision + "/"
+ } else {
+ subpath += "master/"
+ }
+ if repo == "https://chromium.googlesource.com/chromium/tools/build" {
+ subpath += "scripts/slave/recipes/"
nodir 2017/02/07 21:56:29 this isn't right we should fetch recipes.cfg (htt
hinoka 2017/03/01 22:53:10 That won't work, removing sutpath alltogether
+ }
nodir 2017/02/07 21:56:30 this will not work for any other repos? for https
hinoka 2017/03/01 22:53:10 Acknowledged.
+ build.Summary.Recipe = &resp.Link{
+ Label: name,
+ URL: fmt.Sprintf("%s%s%s.py", repo, subpath, name),
+ }
+ }
+}
+
func addTaskToBuild(c context.Context, server string, sr *swarming.SwarmingRpcsTaskResult, build *resp.MiloBuild) error {
+ selfURL := taskPageURL(server, sr.TaskId)
build.Summary.Label = sr.TaskId
build.Summary.Type = resp.Recipe
build.Summary.Source = &resp.Link{
Label: "Task " + sr.TaskId,
- URL: taskPageURL(server, sr.TaskId),
+ URL: selfURL,
}
// Extract more swarming specific information into the properties.
if props := taskProperties(sr); len(props.Property) > 0 {
build.PropertyGroup = append(build.PropertyGroup, props)
}
- if props := tagsToProperties(sr.Tags); len(props.Property) > 0 {
- build.PropertyGroup = append(build.PropertyGroup, props)
- }
+ props := tagsToMap(sr.Tags)
nodir 2017/02/07 21:56:30 tags
hinoka 2017/03/01 22:53:10 Done.
- addBuilderLink(c, build, server, sr)
- addBanner(build, sr)
+ addBuildsetInfo(build, props)
+ addBanner(build, props)
+ addBuilderLink(c, build, selfURL, props)
+ addRecipeLink(build, props)
// Add a link to the bot.
if sr.BotId != "" {

Powered by Google App Engine
This is Rietveld 408576698