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

Unified Diff: appengine/logdog/coordinator/endpoints/services/registerStream.go

Issue 1971493003: LogDog: Project READ access for user endpoints. (Closed) Base URL: https://github.com/luci/luci-go@logdog-project-service-config
Patch Set: Updated patchset dependency 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 side-by-side diff with in-line comments
Download patch
Index: appengine/logdog/coordinator/endpoints/services/registerStream.go
diff --git a/appengine/logdog/coordinator/endpoints/services/registerStream.go b/appengine/logdog/coordinator/endpoints/services/registerStream.go
index 22af8949c791fc949d8066394e9b0fc88def7a4a..3c3bc808fdd74c973c85dc8adcba663bcde080f3 100644
--- a/appengine/logdog/coordinator/endpoints/services/registerStream.go
+++ b/appengine/logdog/coordinator/endpoints/services/registerStream.go
@@ -19,6 +19,7 @@ import (
"github.com/luci/luci-go/common/logdog/types"
log "github.com/luci/luci-go/common/logging"
"github.com/luci/luci-go/common/proto/logdog/logpb"
+ "github.com/luci/luci-go/common/proto/logdog/svcconfig"
"golang.org/x/net/context"
"google.golang.org/grpc/codes"
)
@@ -37,6 +38,16 @@ func buildLogStreamState(ls *coordinator.LogStream, lst *coordinator.LogStreamSt
return &st
}
+func resolveArchiveDelay(cfg *svcconfig.Coordinator, pcfg *svcconfig.ProjectConfig) (delay time.Duration) {
+ if d := cfg.ArchiveDelayMax.Duration(); d > 0 {
+ delay = d
+ }
+ if d := pcfg.MaxStreamAge.Duration(); d > 0 && d < delay {
nodir 2016/05/19 00:38:58 if it is not set in global config, but set in pro
dnj (Google) 2016/05/19 16:12:34 Good catch. Since I use this same method to constr
+ delay = d
+ }
+ return
+}
+
// RegisterStream is an idempotent stream state register operation.
//
// Successive operations will succeed if they have the correct secret for their
@@ -75,21 +86,22 @@ func (s *server) RegisterStream(c context.Context, req *logdog.RegisterStreamReq
}
prefix, _ := path.Split()
- // Load our config and archive expiration.
+ // Load our service and project configs.
cfg, err := coordinator.GetServices(c).Config(c)
if err != nil {
log.WithError(err).Errorf(c, "Failed to load configuration.")
return nil, grpcutil.Internal
}
- archiveDelayMax := cfg.Coordinator.ArchiveDelayMax.Duration()
- if archiveDelayMax < 0 {
- log.Fields{
- "archiveDelayMax": archiveDelayMax,
- }.Errorf(c, "Must have positive maximum archive delay.")
+ pcfg, err := coordinator.CurrentProjectConfig(c)
+ if err != nil {
+ log.WithError(err).Errorf(c, "Failed to load current project configuration.")
return nil, grpcutil.Internal
}
+ // Determine the archival expiration.
+ archiveDelayMax := resolveArchiveDelay(cfg.Coordinator, pcfg)
+
// Register our Prefix.
//
// This will also verify that our request secret matches the registered one,

Powered by Google App Engine
This is Rietveld 408576698