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

Side by Side Diff: ct/go/master_scripts/create_pagesets_on_workers/main.go

Issue 1990873002: Use swarming in create_pagesets CT task (Closed) Base URL: https://skia.googlesource.com/buildbot@ct-3-swarming-timeouts
Patch Set: Address comment Created 4 years, 7 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 | « no previous file | ct/go/util/constants.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 // create_pagesets_on_workers is an application that creates pagesets on all CT 1 // create_pagesets_on_workers is an application that creates pagesets on all CT
2 // workers and uploads it to Google Storage. The requester is emailed when the t ask 2 // workers and uploads it to Google Storage. The requester is emailed when the t ask
3 // is done. 3 // is done.
4 package main 4 package main
5 5
6 import ( 6 import (
7 "flag" 7 "flag"
8 "fmt" 8 "fmt"
9 » "strings" 9 » "path/filepath"
10 "time" 10 "time"
11 11
12 "github.com/skia-dev/glog" 12 "github.com/skia-dev/glog"
13 "go.skia.org/infra/ct/go/ctfe/admin_tasks" 13 "go.skia.org/infra/ct/go/ctfe/admin_tasks"
14 "go.skia.org/infra/ct/go/frontend" 14 "go.skia.org/infra/ct/go/frontend"
15 "go.skia.org/infra/ct/go/master_scripts/master_common" 15 "go.skia.org/infra/ct/go/master_scripts/master_common"
16 "go.skia.org/infra/ct/go/util" 16 "go.skia.org/infra/ct/go/util"
17 "go.skia.org/infra/go/common" 17 "go.skia.org/infra/go/common"
18 "go.skia.org/infra/go/swarming"
18 skutil "go.skia.org/infra/go/util" 19 skutil "go.skia.org/infra/go/util"
19 ) 20 )
20 21
22 const (
23 MAX_PAGES_PER_SWARMING_BOT = 1000
24 )
25
21 var ( 26 var (
22 emails = flag.String("emails", "", "The comma separated email addre sses to notify when the task is picked up and completes.") 27 emails = flag.String("emails", "", "The comma separated email addre sses to notify when the task is picked up and completes.")
23 gaeTaskID = flag.Int64("gae_task_id", -1, "The key of the App Engine t ask. This task will be updated when the task is completed.") 28 gaeTaskID = flag.Int64("gae_task_id", -1, "The key of the App Engine t ask. This task will be updated when the task is completed.")
24 pagesetType = flag.String("pageset_type", "", "The type of pagesets to c reate from the Alexa CSV list. Eg: 10k, Mobile10k, All.") 29 pagesetType = flag.String("pageset_type", "", "The type of pagesets to c reate from the Alexa CSV list. Eg: 10k, Mobile10k, All.")
25 runID = flag.String("run_id", "", "The unique run id (typically re quester + timestamp).") 30 runID = flag.String("run_id", "", "The unique run id (typically re quester + timestamp).")
26 31
27 taskCompletedSuccessfully = new(bool) 32 taskCompletedSuccessfully = new(bool)
28 ) 33 )
29 34
30 func sendEmail(recipients []string) { 35 func sendEmail(recipients []string) {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 emailsArr = append(emailsArr, util.CtAdmins...) 69 emailsArr = append(emailsArr, util.CtAdmins...)
65 if len(emailsArr) == 0 { 70 if len(emailsArr) == 0 {
66 glog.Error("At least one email address must be specified") 71 glog.Error("At least one email address must be specified")
67 return 72 return
68 } 73 }
69 skutil.LogErr(frontend.UpdateWebappTaskSetStarted(&admin_tasks.RecreateP ageSetsUpdateVars{}, *gaeTaskID)) 74 skutil.LogErr(frontend.UpdateWebappTaskSetStarted(&admin_tasks.RecreateP ageSetsUpdateVars{}, *gaeTaskID))
70 skutil.LogErr(util.SendTaskStartEmail(emailsArr, "Creating pagesets", *r unID, "")) 75 skutil.LogErr(util.SendTaskStartEmail(emailsArr, "Creating pagesets", *r unID, ""))
71 // Ensure webapp is updated and completion email is sent even if task fa ils. 76 // Ensure webapp is updated and completion email is sent even if task fa ils.
72 defer updateWebappTask() 77 defer updateWebappTask()
73 defer sendEmail(emailsArr) 78 defer sendEmail(emailsArr)
74 if !*master_common.Local {
75 // Cleanup tmp files after the run.
76 defer util.CleanTmpDir()
77 }
78 // Finish with glog flush and how long the task took. 79 // Finish with glog flush and how long the task took.
79 defer util.TimeTrack(time.Now(), "Creating Pagesets on Workers") 80 defer util.TimeTrack(time.Now(), "Creating Pagesets on Workers")
80 defer glog.Flush() 81 defer glog.Flush()
81 82
82 if *pagesetType == "" { 83 if *pagesetType == "" {
83 glog.Error("Must specify --pageset_type") 84 glog.Error("Must specify --pageset_type")
84 return 85 return
85 } 86 }
86 87
87 » cmd := append(master_common.WorkerSetupCmds(), 88 » // Empty the remote dir before the workers upload to it.
88 » » // The main command that runs create_pagesets on all workers. 89 » gs, err := util.NewGsUtil(nil)
89 » » fmt.Sprintf(
90 » » » "create_pagesets --worker_num=%s --log_dir=%s --log_id=% s --pageset_type=%s --local=%t;",
91 » » » util.WORKER_NUM_KEYWORD, util.GLogDir, *runID, *pagesetT ype, *master_common.Local))
92
93 » _, err := util.SSH(strings.Join(cmd, " "), util.Slaves, util.CREATE_PAGE SETS_TIMEOUT)
94 if err != nil { 90 if err != nil {
95 » » glog.Errorf("Error while running cmd %s: %s", cmd, err) 91 » » glog.Error(err)
96 return 92 return
97 } 93 }
94 gsBaseDir := filepath.Join(util.SWARMING_DIR_NAME, util.PAGESETS_DIR_NAM E, *pagesetType)
95 skutil.LogErr(gs.DeleteRemoteDir(gsBaseDir))
96
97 // Archive, trigger and collect swarming tasks.
98 if err := util.TriggerSwarmingTask(*pagesetType, "create_pagesets", util .CREATE_PAGESETS_ISOLATE, swarming.RECOMMENDED_HARD_TIMEOUT, swarming.RECOMMENDE D_IO_TIMEOUT, MAX_PAGES_PER_SWARMING_BOT, map[string]string{}); err != nil {
99 glog.Errorf("Error encountered when swarming tasks: %s", err)
100 return
101 }
102
98 *taskCompletedSuccessfully = true 103 *taskCompletedSuccessfully = true
99 } 104 }
OLDNEW
« no previous file with comments | « no previous file | ct/go/util/constants.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698