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, |