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

Side by Side Diff: go/src/infra/monitoring/dispatcher/dispatcher.go

Issue 1996863003: alerts_dispatcher: Fix bad tree selection logic. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: 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 | no next file » | 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 Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Dispatcher usage: 5 // Dispatcher usage:
6 // go run infra/monitoring/dispatcher 6 // go run infra/monitoring/dispatcher
7 // Expects gatekeeper.json to be in the current directory. 7 // Expects gatekeeper.json to be in the current directory.
8 8
9 package main 9 package main
10 10
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 func (a bySeverity) Len() int { return len(a) } 149 func (a bySeverity) Len() int { return len(a) }
150 func (a bySeverity) Swap(i, j int) { a[i], a[j] = a[j], a[i] } 150 func (a bySeverity) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
151 func (a bySeverity) Less(i, j int) bool { 151 func (a bySeverity) Less(i, j int) bool {
152 return a[i].Severity < a[j].Severity 152 return a[i].Severity < a[j].Severity
153 } 153 }
154 154
155 func mainLoop(ctx context.Context, a *analyzer.Analyzer, trees map[string]bool, transport http.RoundTripper) error { 155 func mainLoop(ctx context.Context, a *analyzer.Analyzer, trees map[string]bool, transport http.RoundTripper) error {
156 done := make(chan interface{}) 156 done := make(chan interface{})
157 errs := make(chan error) 157 errs := make(chan error)
158 for treeName := range trees { 158 for treeName := range trees {
159 » » go func(tree string) { 159 » » tree := treeName
seanmccullough1 2016/05/20 18:40:29 ha!
160 » » go func() {
160 expvars.Add(fmt.Sprintf("Tree-%s", tree), 1) 161 expvars.Add(fmt.Sprintf("Tree-%s", tree), 1)
161 defer expvars.Add(fmt.Sprintf("Tree-%s", tree), -1) 162 defer expvars.Add(fmt.Sprintf("Tree-%s", tree), -1)
162 infoLog.Printf("Checking tree: %s", tree) 163 infoLog.Printf("Checking tree: %s", tree)
163 masters := []*messages.MasterLocation{} 164 masters := []*messages.MasterLocation{}
164 165
165 » » » for treeToUse, shouldUse := range trees { 166 » » » for _, t := range gkts[tree] {
166 » » » » if !shouldUse { 167 » » » » for _, url := range t.Masters {
167 » » » » » continue 168 » » » » » masters = append(masters, url)
168 » » » » }
169
170 » » » » for _, t := range gkts[treeToUse] {
171 » » » » » for _, url := range t.Masters {
172 » » » » » » masters = append(masters, url)
173 » » » » » }
174 } 169 }
175 } 170 }
176 171
177 // TODO(seanmccullough): Plumb ctx through the rest of t hese calls. 172 // TODO(seanmccullough): Plumb ctx through the rest of t hese calls.
178 bes := fetchBuildExtracts(ctx, a.Reader, masters) 173 bes := fetchBuildExtracts(ctx, a.Reader, masters)
179 infoLog.Printf("Build Extracts read: %d", len(bes)) 174 infoLog.Printf("Build Extracts read: %d", len(bes))
180 175
181 alerts := &messages.Alerts{ 176 alerts := &messages.Alerts{
182 RevisionSummaries: map[string]messages.RevisionS ummary{}, 177 RevisionSummaries: map[string]messages.RevisionS ummary{},
183 } 178 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 err := w.PostAlerts(alerts) 221 err := w.PostAlerts(alerts)
227 if err != nil { 222 if err != nil {
228 errLog.Printf("Couldn't post alerts: %v" , err) 223 errLog.Printf("Couldn't post alerts: %v" , err)
229 errs <- err 224 errs <- err
230 return 225 return
231 } 226 }
232 } 227 }
233 228
234 infoLog.Printf("Filtered failures: %v", filteredFailures ) 229 infoLog.Printf("Filtered failures: %v", filteredFailures )
235 done <- nil 230 done <- nil
236 » » }(treeName) 231 » » }()
237 } 232 }
238 233
239 for range trees { 234 for range trees {
240 select { 235 select {
241 case err := <-errs: 236 case err := <-errs:
242 return err 237 return err
243 case <-done: 238 case <-done:
244 } 239 }
245 } 240 }
246 241
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 ctx, cancel := context.WithTimeout(ctx, duration) 410 ctx, cancel := context.WithTimeout(ctx, duration)
416 defer cancel() 411 defer cancel()
417 412
418 loopResults := looper.Run(ctx, f, cycle, *maxErrs, clock.GetSystemClock( )) 413 loopResults := looper.Run(ctx, f, cycle, *maxErrs, clock.GetSystemClock( ))
419 414
420 if !loopResults.Success { 415 if !loopResults.Success {
421 errLog.Printf("Failed to run loop, %v errors", loopResults.Errs) 416 errLog.Printf("Failed to run loop, %v errors", loopResults.Errs)
422 os.Exit(1) 417 os.Exit(1)
423 } 418 }
424 } 419 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698