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

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

Issue 2963503003: [errors] Greatly simplify common/errors package. (Closed)
Patch Set: fix nits Created 3 years, 5 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
« no previous file with comments | « milo/build_source/raw_presentation/html.go ('k') | milo/build_source/swarming/buildinfo.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "fmt" 9 "fmt"
10 "net/http" 10 "net/http"
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 499
500 func (bl *buildLoader) newEmptyAnnotationStream(c context.Context, addr *types.S treamAddr) ( 500 func (bl *buildLoader) newEmptyAnnotationStream(c context.Context, addr *types.S treamAddr) (
501 *raw_presentation.AnnotationStream, error) { 501 *raw_presentation.AnnotationStream, error) {
502 502
503 fn := bl.logDogClientFunc 503 fn := bl.logDogClientFunc
504 if fn == nil { 504 if fn == nil {
505 fn = raw_presentation.NewClient 505 fn = raw_presentation.NewClient
506 } 506 }
507 client, err := fn(c, addr.Host) 507 client, err := fn(c, addr.Host)
508 if err != nil { 508 if err != nil {
509 » » return nil, errors.Annotate(err).Reason("failed to create LogDog client").Err() 509 » » return nil, errors.Annotate(err, "failed to create LogDog client ").Err()
510 } 510 }
511 511
512 as := raw_presentation.AnnotationStream{ 512 as := raw_presentation.AnnotationStream{
513 Client: client, 513 Client: client,
514 Project: addr.Project, 514 Project: addr.Project,
515 Path: addr.Path, 515 Path: addr.Path,
516 } 516 }
517 if err := as.Normalize(); err != nil { 517 if err := as.Normalize(); err != nil {
518 » » return nil, errors.Annotate(err).Reason("failed to normalize ann otation stream parameters").Err() 518 » » return nil, errors.Annotate(err, "failed to normalize annotation stream parameters").Err()
519 } 519 }
520 520
521 return &as, nil 521 return &as, nil
522 } 522 }
523 523
524 // failedToStart is called in the case where logdog-only mode is on but the 524 // failedToStart is called in the case where logdog-only mode is on but the
525 // stream doesn't exist and the swarming job is complete. It modifies the build 525 // stream doesn't exist and the swarming job is complete. It modifies the build
526 // to add information that would've otherwise been in the annotation stream. 526 // to add information that would've otherwise been in the annotation stream.
527 func failedToStart(c context.Context, build *resp.MiloBuild, res *swarming.Swarm ingRpcsTaskResult, host string) error { 527 func failedToStart(c context.Context, build *resp.MiloBuild, res *swarming.Swarm ingRpcsTaskResult, host string) error {
528 var err error 528 var err error
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 // If the Swarming task explicitly specifies its log location, we prefer that. 595 // If the Swarming task explicitly specifies its log location, we prefer that.
596 // As a fallback, we will try and parse the Swarming task's output for 596 // As a fallback, we will try and parse the Swarming task's output for
597 // annotations. 597 // annotations.
598 switch { 598 switch {
599 case logDogStreamAddr != nil: 599 case logDogStreamAddr != nil:
600 logging.Infof(c, "Loading build from LogDog stream at: %s", logD ogStreamAddr) 600 logging.Infof(c, "Loading build from LogDog stream at: %s", logD ogStreamAddr)
601 601
602 // If the LogDog stream is available, load the step from that. 602 // If the LogDog stream is available, load the step from that.
603 as, err := bl.newEmptyAnnotationStream(c, logDogStreamAddr) 603 as, err := bl.newEmptyAnnotationStream(c, logDogStreamAddr)
604 if err != nil { 604 if err != nil {
605 » » » return nil, errors.Annotate(err).Reason("failed to creat e LogDog annotation stream").Err() 605 » » » return nil, errors.Annotate(err, "failed to create LogDo g annotation stream").Err()
606 } 606 }
607 607
608 prefix, _ := logDogStreamAddr.Path.Split() 608 prefix, _ := logDogStreamAddr.Path.Split()
609 ub = &raw_presentation.ViewerURLBuilder{ 609 ub = &raw_presentation.ViewerURLBuilder{
610 Host: logDogStreamAddr.Host, 610 Host: logDogStreamAddr.Host,
611 Prefix: prefix, 611 Prefix: prefix,
612 Project: logDogStreamAddr.Project, 612 Project: logDogStreamAddr.Project,
613 } 613 }
614 614
615 if s, err = as.Fetch(c); err != nil { 615 if s, err = as.Fetch(c); err != nil {
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 for _, tag := range v { 768 for _, tag := range v {
769 var value string 769 var value string
770 parts := strings.SplitN(tag, ":", 2) 770 parts := strings.SplitN(tag, ":", 2)
771 if len(parts) == 2 { 771 if len(parts) == 2 {
772 value = parts[1] 772 value = parts[1]
773 } 773 }
774 res[parts[0]] = value 774 res[parts[0]] = value
775 } 775 }
776 return res 776 return res
777 } 777 }
OLDNEW
« no previous file with comments | « milo/build_source/raw_presentation/html.go ('k') | milo/build_source/swarming/buildinfo.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698