| OLD | NEW |
| 1 /* | 1 /* |
| 2 Provides roll-up statuses and alerting for Skia build/test/perf. | 2 Provides roll-up statuses and alerting for Skia build/test/perf. |
| 3 */ | 3 */ |
| 4 | 4 |
| 5 package main | 5 package main |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "encoding/json" | 8 "encoding/json" |
| 9 "flag" | 9 "flag" |
| 10 "fmt" | 10 "fmt" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return | 123 return |
| 124 } | 124 } |
| 125 // URLs take the form /alerts/<alertId>/<action> | 125 // URLs take the form /alerts/<alertId>/<action> |
| 126 split := strings.Split(r.URL.String(), "/") | 126 split := strings.Split(r.URL.String(), "/") |
| 127 if len(split) != 4 { | 127 if len(split) != 4 { |
| 128 util.ReportError(w, r, fmt.Errorf("Invalid URL %s", r.UR
L), "Requested URL is not valid.") | 128 util.ReportError(w, r, fmt.Errorf("Invalid URL %s", r.UR
L), "Requested URL is not valid.") |
| 129 return | 129 return |
| 130 } | 130 } |
| 131 alertId := split[2] | 131 alertId := split[2] |
| 132 if !alertManager.Contains(alertId) { | 132 if !alertManager.Contains(alertId) { |
| 133 » » » util.ReportError(w, r, fmt.Errorf("Invalid Alert ID %d",
alertId), "The requested resource does not exist.") | 133 » » » util.ReportError(w, r, fmt.Errorf("Invalid Alert ID %s",
alertId), "The requested resource does not exist.") |
| 134 return | 134 return |
| 135 } | 135 } |
| 136 action := split[3] | 136 action := split[3] |
| 137 if action == "dismiss" { | 137 if action == "dismiss" { |
| 138 glog.Infof("%s %s", action, alertId) | 138 glog.Infof("%s %s", action, alertId) |
| 139 alertManager.Dismiss(alertId, email) | 139 alertManager.Dismiss(alertId, email) |
| 140 return | 140 return |
| 141 } else if action == "snooze" { | 141 } else if action == "snooze" { |
| 142 d := json.NewDecoder(r.Body) | 142 d := json.NewDecoder(r.Body) |
| 143 body := struct { | 143 body := struct { |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 if err != nil { | 236 if err != nil { |
| 237 glog.Fatalf("Failed to parse -alertPollInterval: %s", *alertPoll
Interval) | 237 glog.Fatalf("Failed to parse -alertPollInterval: %s", *alertPoll
Interval) |
| 238 } | 238 } |
| 239 if *testing { | 239 if *testing { |
| 240 *useMetadata = false | 240 *useMetadata = false |
| 241 } | 241 } |
| 242 if *useMetadata { | 242 if *useMetadata { |
| 243 *influxDbName = metadata.MustGet(INFLUXDB_NAME_METADATA_KEY) | 243 *influxDbName = metadata.MustGet(INFLUXDB_NAME_METADATA_KEY) |
| 244 *influxDbPassword = metadata.MustGet(INFLUXDB_PASSWORD_METADATA_
KEY) | 244 *influxDbPassword = metadata.MustGet(INFLUXDB_PASSWORD_METADATA_
KEY) |
| 245 } | 245 } |
| 246 » dbClient, err := client.New(&client.ClientConfig{*influxDbHost, *influxD
bName, *influxDbPassword, *influxDbDatabase, nil, false, false}) | 246 » dbClient, err := client.New(&client.ClientConfig{ |
| 247 » » Host: *influxDbHost, |
| 248 » » Username: *influxDbName, |
| 249 » » Password: *influxDbPassword, |
| 250 » » Database: *influxDbDatabase, |
| 251 » » HttpClient: nil, |
| 252 » » IsSecure: false, |
| 253 » » IsUDP: false, |
| 254 » }) |
| 247 if err != nil { | 255 if err != nil { |
| 248 glog.Fatalf("Failed to initialize InfluxDB client: %s", err) | 256 glog.Fatalf("Failed to initialize InfluxDB client: %s", err) |
| 249 } | 257 } |
| 250 serverURL := "https://" + *host | 258 serverURL := "https://" + *host |
| 251 if *testing { | 259 if *testing { |
| 252 serverURL = "http://" + *host + *port | 260 serverURL = "http://" + *host + *port |
| 253 } | 261 } |
| 254 | 262 |
| 255 usr, err := user.Current() | 263 usr, err := user.Current() |
| 256 if err != nil { | 264 if err != nil { |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 if err != nil { | 303 if err != nil { |
| 296 glog.Fatalf("Failed to create AlertManager: %v", err) | 304 glog.Fatalf("Failed to create AlertManager: %v", err) |
| 297 } | 305 } |
| 298 | 306 |
| 299 gitInfo, err = gitinfo.CloneOrUpdate("https://skia.googlesource.com/skia
.git", *workdir, true) | 307 gitInfo, err = gitinfo.CloneOrUpdate("https://skia.googlesource.com/skia
.git", *workdir, true) |
| 300 if err != nil { | 308 if err != nil { |
| 301 glog.Fatalf("Failed to check out Skia: %v", err) | 309 glog.Fatalf("Failed to check out Skia: %v", err) |
| 302 } | 310 } |
| 303 runServer(serverURL) | 311 runServer(serverURL) |
| 304 } | 312 } |
| OLD | NEW |