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

Side by Side Diff: milo/appengine/swarming/build.go

Issue 2254993002: Milo: Add task expired as a failure status (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Use proto instead Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package swarming 5 package swarming
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "encoding/json" 9 "encoding/json"
10 "fmt" 10 "fmt"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 275
276 switch sr.State { 276 switch sr.State {
277 case TaskRunning: 277 case TaskRunning:
278 step.Status = miloProto.Status_RUNNING 278 step.Status = miloProto.Status_RUNNING
279 279
280 case TaskPending: 280 case TaskPending:
281 step.Status = miloProto.Status_PENDING 281 step.Status = miloProto.Status_PENDING
282 282
283 case TaskExpired, TaskTimedOut, TaskBotDied: 283 case TaskExpired, TaskTimedOut, TaskBotDied:
284 step.Status = miloProto.Status_FAILURE 284 step.Status = miloProto.Status_FAILURE
285 step.FailureDetails = &miloProto.FailureDetails{
286 Type: miloProto.FailureDetails_INFRA,
287 }
288 285
289 switch sr.State { 286 switch sr.State {
290 case TaskExpired: 287 case TaskExpired:
291 » » » step.FailureDetails.Text = "Task expired" 288 » » » step.FailureDetails = &miloProto.FailureDetails{
289 » » » » Type: miloProto.FailureDetails_EXPIRED,
290 » » » » Text: "Task expired",
291 » » » }
292 case TaskTimedOut: 292 case TaskTimedOut:
293 » » » step.FailureDetails.Text = "Task timed out" 293 » » » step.FailureDetails = &miloProto.FailureDetails{
294 » » » » Type: miloProto.FailureDetails_INFRA,
295 » » » » Text: "Task timed out",
296 » » » }
294 case TaskBotDied: 297 case TaskBotDied:
295 » » » step.FailureDetails.Text = "Bot died" 298 » » » step.FailureDetails = &miloProto.FailureDetails{
299 » » » » Type: miloProto.FailureDetails_INFRA,
300 » » » » Text: "Bot died",
301 » » » }
296 } 302 }
297 303
298 case TaskCanceled: 304 case TaskCanceled:
299 // Cancelled build is user action, so it is not an infra failure . 305 // Cancelled build is user action, so it is not an infra failure .
300 step.Status = miloProto.Status_FAILURE 306 step.Status = miloProto.Status_FAILURE
301 step.FailureDetails = &miloProto.FailureDetails{ 307 step.FailureDetails = &miloProto.FailureDetails{
302 Type: miloProto.FailureDetails_CANCELLED, 308 Type: miloProto.FailureDetails_CANCELLED,
303 Text: "Task cancelled by user", 309 Text: "Task cancelled by user",
304 } 310 }
305 311
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 if t == "allow_milo:1" { 415 if t == "allow_milo:1" {
410 allowMilo = true 416 allowMilo = true
411 break 417 break
412 } 418 }
413 } 419 }
414 if !allowMilo { 420 if !allowMilo {
415 return nil, fmt.Errorf("Not A Milo Job") 421 return nil, fmt.Errorf("Not A Milo Job")
416 } 422 }
417 423
418 var build resp.MiloBuild 424 var build resp.MiloBuild
425 var s *miloProto.Step
426 var lds *logdog.Streams
419 427
420 // Decode the data using annotee. The logdog stream returned here is ass umed 428 // Decode the data using annotee. The logdog stream returned here is ass umed
421 // to be consistent, which is why the following block of code are not 429 // to be consistent, which is why the following block of code are not
422 // expected to ever err out. 430 // expected to ever err out.
423 if body != "" { 431 if body != "" {
424 » » lds, err := streamsFromAnnotatedLog(c, body) 432 » » lds, err = streamsFromAnnotatedLog(c, body)
425 if err != nil { 433 if err != nil {
426 build.Components = []*resp.BuildComponent{{ 434 build.Components = []*resp.BuildComponent{{
427 Type: resp.Summary, 435 Type: resp.Summary,
428 Label: "Milo annotation parser", 436 Label: "Milo annotation parser",
429 Text: []string{err.Error()}, 437 Text: []string{err.Error()},
430 Status: resp.InfraFailure, 438 Status: resp.InfraFailure,
431 SubLink: []*resp.Link{{ 439 SubLink: []*resp.Link{{
432 Label: "swarming task", 440 Label: "swarming task",
433 URL: taskPageURL(server, taskID), 441 URL: taskPageURL(server, taskID),
434 }}, 442 }},
435 }} 443 }}
436 } else {
437 if lds.MainStream == nil || lds.MainStream.Data == nil {
438 panic("no main build step stream")
439 }
440
441 if err := addTaskToMiloStep(c, server, sr, lds.MainStrea m.Data); err != nil {
442 return nil, err
443 }
444 logdog.AddLogDogToBuild(c, swarmingURLBuilder(linkBase), lds, &build)
445 } 444 }
446 } 445 }
447 446
447 if lds != nil && lds.MainStream != nil && lds.MainStream.Data != nil {
448 s = lds.MainStream.Data
449 } else {
450 s = &miloProto.Step{}
451 }
452
453 if err := addTaskToMiloStep(c, server, sr, s); err != nil {
454 return nil, err
455 }
456 logdog.AddLogDogToBuild(c, swarmingURLBuilder(linkBase), s, &build)
457
448 if err := addTaskToBuild(c, server, sr, &build); err != nil { 458 if err := addTaskToBuild(c, server, sr, &build); err != nil {
449 return nil, err 459 return nil, err
450 } 460 }
451 461
452 return &build, nil 462 return &build, nil
453 } 463 }
454 464
455 // taskPageURL returns a URL to a human-consumable page of a swarming task. 465 // taskPageURL returns a URL to a human-consumable page of a swarming task.
456 // Supports server aliases. 466 // Supports server aliases.
457 func taskPageURL(swarmingHostname, taskID string) string { 467 func taskPageURL(swarmingHostname, taskID string) string {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 case *miloProto.Link_Url: 508 case *miloProto.Link_Url:
499 return &resp.Link{ 509 return &resp.Link{
500 Label: l.Label, 510 Label: l.Label,
501 URL: t.Url, 511 URL: t.Url,
502 } 512 }
503 513
504 default: 514 default:
505 return nil 515 return nil
506 } 516 }
507 } 517 }
OLDNEW
« no previous file with comments | « milo/appengine/logdog/logDogBuild.go ('k') | milo/appengine/swarming/expectations/build-expired.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698