Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 526 Project: addr.Project, | 526 Project: addr.Project, |
| 527 Path: addr.Path, | 527 Path: addr.Path, |
| 528 } | 528 } |
| 529 if err := as.Normalize(); err != nil { | 529 if err := as.Normalize(); err != nil { |
| 530 return nil, errors.Annotate(err).Reason("failed to normalize ann otation stream parameters").Err() | 530 return nil, errors.Annotate(err).Reason("failed to normalize ann otation stream parameters").Err() |
| 531 } | 531 } |
| 532 | 532 |
| 533 return &as, nil | 533 return &as, nil |
| 534 } | 534 } |
| 535 | 535 |
| 536 // failedToStart is called in the case where logdog-only mode is on but the | |
| 537 // stream doesn't exist and the swarming job is complete. It modifies the build | |
| 538 // to add information that would've otherwise been in the annotation stream. | |
| 539 func failedToStart(c context.Context, build *resp.MiloBuild, res *swarming.Swarm ingRpcsTaskResult, host string) error { | |
| 540 var err error | |
| 541 build.Summary.Status = resp.InfraFailure | |
| 542 build.Summary.Started, err = time.Parse(time.RFC3339Nano, res.StartedTs+ "Z") | |
|
nodir
2017/05/25 21:32:42
i think SwarmingTimeLayout should be used here
Ryan Tseng
2017/05/25 21:37:02
Done.
| |
| 543 if err != nil { | |
| 544 return err | |
| 545 } | |
| 546 build.Summary.Finished, err = time.Parse(time.RFC3339Nano, res.Completed Ts+"Z") | |
|
nodir
2017/05/25 21:32:42
here too
Ryan Tseng
2017/05/25 21:37:02
Done.
| |
| 547 if err != nil { | |
| 548 return err | |
| 549 } | |
| 550 build.Summary.Duration = build.Summary.Finished.Sub(build.Summary.Starte d) | |
| 551 infoComp := infoComponent(resp.InfraFailure, | |
| 552 "LogDog stream not found", "Job likely failed to start.") | |
| 553 infoComp.Started = build.Summary.Started | |
| 554 infoComp.Finished = build.Summary.Finished | |
| 555 infoComp.Duration = build.Summary.Duration | |
| 556 infoComp.Verbosity = resp.Interesting | |
| 557 build.Components = append(build.Components, infoComp) | |
| 558 return addTaskToBuild(c, host, res, build) | |
| 559 } | |
| 560 | |
| 536 func (bl *buildLoader) swarmingBuildImpl(c context.Context, svc swarmingService, linkBase, taskID string) (*resp.MiloBuild, error) { | 561 func (bl *buildLoader) swarmingBuildImpl(c context.Context, svc swarmingService, linkBase, taskID string) (*resp.MiloBuild, error) { |
| 537 // Fetch the data from Swarming | 562 // Fetch the data from Swarming |
| 538 var logDogStreamAddr *types.StreamAddr | 563 var logDogStreamAddr *types.StreamAddr |
| 539 | 564 |
| 540 fetchParams := swarmingFetchParams{ | 565 fetchParams := swarmingFetchParams{ |
| 541 fetchRes: true, | 566 fetchRes: true, |
| 542 fetchLog: true, | 567 fetchLog: true, |
| 543 | 568 |
| 544 // Cancel if LogDog annotation stream parameters are present in the tag set. | 569 // Cancel if LogDog annotation stream parameters are present in the tag set. |
| 545 taskResCallback: func(res *swarming.SwarmingRpcsTaskResult) (can celLogs bool) { | 570 taskResCallback: func(res *swarming.SwarmingRpcsTaskResult) (can celLogs bool) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 595 prefix, _ := logDogStreamAddr.Path.Split() | 620 prefix, _ := logDogStreamAddr.Path.Split() |
| 596 ub = &logdog.ViewerURLBuilder{ | 621 ub = &logdog.ViewerURLBuilder{ |
| 597 Host: logDogStreamAddr.Host, | 622 Host: logDogStreamAddr.Host, |
| 598 Prefix: prefix, | 623 Prefix: prefix, |
| 599 Project: logDogStreamAddr.Project, | 624 Project: logDogStreamAddr.Project, |
| 600 } | 625 } |
| 601 | 626 |
| 602 if s, err = as.Fetch(c); err != nil { | 627 if s, err = as.Fetch(c); err != nil { |
| 603 switch errors.Unwrap(err) { | 628 switch errors.Unwrap(err) { |
| 604 case coordinator.ErrNoSuchStream: | 629 case coordinator.ErrNoSuchStream: |
| 630 // The stream was not found. This could be due to one of two things: | |
| 631 // 1. The step just started and we're just waiti ng for the logs | |
| 632 // to propogage to logdog. | |
| 633 // 2. The bootsrap on the client failed, and nev er sent data to logdog. | |
| 634 // This would be evident because the swarming re sult would be a failure. | |
| 635 if fr.res.State == "COMPLETED" { | |
|
nodir
2017/05/25 21:32:42
use TaskCompleted const
Ryan Tseng
2017/05/25 21:37:02
Done.
| |
| 636 err = failedToStart(c, &build, fr.res, s vc.getHost()) | |
| 637 return &build, err | |
| 638 } | |
| 605 logging.WithError(err).Errorf(c, "User cannot ac cess stream.") | 639 logging.WithError(err).Errorf(c, "User cannot ac cess stream.") |
| 606 build.Components = append(build.Components, info Component(resp.Running, | 640 build.Components = append(build.Components, info Component(resp.Running, |
| 607 "Waiting...", "waiting for annotation st ream")) | 641 "Waiting...", "waiting for annotation st ream")) |
| 608 | 642 |
| 609 case coordinator.ErrNoAccess: | 643 case coordinator.ErrNoAccess: |
| 610 logging.WithError(err).Errorf(c, "User cannot ac cess stream.") | 644 logging.WithError(err).Errorf(c, "User cannot ac cess stream.") |
| 611 build.Components = append(build.Components, info Component(resp.Failure, | 645 build.Components = append(build.Components, info Component(resp.Failure, |
| 612 "No Access", "no access to annotation st ream")) | 646 "No Access", "no access to annotation st ream")) |
| 613 | 647 |
| 614 default: | 648 default: |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 753 for _, tag := range v { | 787 for _, tag := range v { |
| 754 var value string | 788 var value string |
| 755 parts := strings.SplitN(tag, ":", 2) | 789 parts := strings.SplitN(tag, ":", 2) |
| 756 if len(parts) == 2 { | 790 if len(parts) == 2 { |
| 757 value = parts[1] | 791 value = parts[1] |
| 758 } | 792 } |
| 759 res[parts[0]] = value | 793 res[parts[0]] = value |
| 760 } | 794 } |
| 761 return res | 795 return res |
| 762 } | 796 } |
| OLD | NEW |