Chromium Code Reviews| Index: milo/appengine/buildbot/pubsub.go |
| diff --git a/milo/appengine/buildbot/pubsub.go b/milo/appengine/buildbot/pubsub.go |
| index 62e64d4f07f2d936dd26727bc4390ae3b66c6326..9adfbc5a5f8f356a758409fe6896c09c7398cd33 100644 |
| --- a/milo/appengine/buildbot/pubsub.go |
| +++ b/milo/appengine/buildbot/pubsub.go |
| @@ -19,6 +19,7 @@ import ( |
| "github.com/luci/luci-go/common/clock" |
| "github.com/luci/luci-go/common/iotools" |
| "github.com/luci/luci-go/common/logging" |
| + "github.com/luci/luci-go/milo/appengine/common" |
| "github.com/luci/luci-go/server/router" |
| "golang.org/x/net/context" |
| @@ -28,11 +29,6 @@ import ( |
| ) |
| var ( |
| - // publicSubName is the name of the pubsub subscription that milo is expecting. |
| - // TODO(hinoka): This should be read from luci-config. |
| - publicSubName = "projects/luci-milo/subscriptions/buildbot-public" |
| - internalSubName = "projects/luci-milo/subscriptions/buildbot-private" |
| - |
| // Metrics |
| buildCounter = metric.NewCounter( |
| "luci/milo/buildbot_pubsub/builds", |
| @@ -307,17 +303,28 @@ func pubSubHandlerImpl(c context.Context, r *http.Request) int { |
| return 200 // This is a hard failure, we don't want PubSub to retry. |
| } |
| internal := true |
| + // Get the name of the subscription on luci-config |
| + settings, err := common.GetSettings(c) |
| + if err != nil { |
| + logging.WithError(err).Errorf(c, |
| + "Cannot load settings to check subscription name.") |
| + // This is a configuration error. Tell PubSub to retry until we fix our |
| + // configs. |
| + return 500 |
|
nodir
2017/03/24 08:41:15
please use http.Status* contants
In unchanged code
hinoka
2017/03/28 17:47:20
Done.
|
| + } |
| switch msg.Subscription { |
| - // TODO(hinoka): Move these names to luci-config |
| - case publicSubName, publicSubName + "-dev": |
| + case settings.Buildbot.PublicTopic: |
| internal = false |
| - case internalSubName, internalSubName + "-dev": |
| + case settings.Buildbot.InternalTopic: |
| // internal = true, but that's already set. |
| default: |
| logging.Errorf( |
| c, "Subscription name %s does not match %s or %s", |
| - msg.Subscription, publicSubName, internalSubName) |
| - return 200 |
| + msg.Subscription, settings.Buildbot.PublicTopic, |
| + settings.Buildbot.InternalTopic) |
| + // This is a configuration error. Tell PubSub to retry until we fix our |
| + // configs. |
| + return 500 |
| } |
| logging.Infof( |
| c, "Message ID \"%s\" from subscription %s is %d bytes long", |