| OLD | NEW |
| 1 // Copyright 2016 The LUCI Authors. All rights reserved. | 1 // Copyright 2016 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 buildbot | 5 package buildbot |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "compress/gzip" | 9 "compress/gzip" |
| 10 "compress/zlib" | 10 "compress/zlib" |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 now := int(clock.Now(c).Unix()) | 297 now := int(clock.Now(c).Unix()) |
| 298 defer r.Body.Close() | 298 defer r.Body.Close() |
| 299 dec := json.NewDecoder(r.Body) | 299 dec := json.NewDecoder(r.Body) |
| 300 if err := dec.Decode(&msg); err != nil { | 300 if err := dec.Decode(&msg); err != nil { |
| 301 logging.WithError(err).Errorf( | 301 logging.WithError(err).Errorf( |
| 302 c, "Could not decode message. %s", err) | 302 c, "Could not decode message. %s", err) |
| 303 return http.StatusOK // This is a hard failure, we don't want Pu
bSub to retry. | 303 return http.StatusOK // This is a hard failure, we don't want Pu
bSub to retry. |
| 304 } | 304 } |
| 305 internal := true | 305 internal := true |
| 306 // Get the name of the subscription on luci-config | 306 // Get the name of the subscription on luci-config |
| 307 » settings, err := common.GetSettings(c) | 307 » settings := common.GetSettings(c) |
| 308 » if err != nil { | |
| 309 » » logging.WithError(err).Errorf(c, | |
| 310 » » » "Cannot load settings to check subscription name.") | |
| 311 » » // This is a configuration error. Tell PubSub to retry until we
fix our | |
| 312 » » // configs. | |
| 313 » » return http.StatusInternalServerError | |
| 314 » } | |
| 315 switch msg.Subscription { | 308 switch msg.Subscription { |
| 316 case settings.Buildbot.PublicSubscription: | 309 case settings.Buildbot.PublicSubscription: |
| 317 internal = false | 310 internal = false |
| 318 case settings.Buildbot.InternalSubscription: | 311 case settings.Buildbot.InternalSubscription: |
| 319 // internal = true, but that's already set. | 312 // internal = true, but that's already set. |
| 320 default: | 313 default: |
| 321 logging.Errorf( | 314 logging.Errorf( |
| 322 c, "Subscription name %s does not match %s or %s", | 315 c, "Subscription name %s does not match %s or %s", |
| 323 msg.Subscription, settings.Buildbot.PublicSubscription, | 316 msg.Subscription, settings.Buildbot.PublicSubscription, |
| 324 settings.Buildbot.InternalSubscription) | 317 settings.Buildbot.InternalSubscription) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 398 |
| 406 } | 399 } |
| 407 if master != nil { | 400 if master != nil { |
| 408 code := doMaster(c, master, internal) | 401 code := doMaster(c, master, internal) |
| 409 if code != 0 { | 402 if code != 0 { |
| 410 return code | 403 return code |
| 411 } | 404 } |
| 412 } | 405 } |
| 413 return http.StatusOK | 406 return http.StatusOK |
| 414 } | 407 } |
| OLD | NEW |