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

Side by Side Diff: appengine/logdog/coordinator/endpoints/services/registerStream.go

Issue 1972753002: LogDog: Implement prefix expiration. (Closed) Base URL: https://github.com/luci/luci-go@logdog-butler-register-coordinator-impl
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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package services 5 package services
6 6
7 import ( 7 import (
8 "crypto/subtle" 8 "crypto/subtle"
9 "time" 9 "time"
10 10
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 log.ErrorKey: err, 112 log.ErrorKey: err,
113 "id": pfx.ID, 113 "id": pfx.ID,
114 "prefix": prefix, 114 "prefix": prefix,
115 }.Errorf(c, "Failed to load log stream prefix.") 115 }.Errorf(c, "Failed to load log stream prefix.")
116 if err == ds.ErrNoSuchEntity { 116 if err == ds.ErrNoSuchEntity {
117 return nil, grpcutil.Errf(codes.FailedPrecondition, "pre fix is not registered") 117 return nil, grpcutil.Errf(codes.FailedPrecondition, "pre fix is not registered")
118 } 118 }
119 return nil, grpcutil.Internal 119 return nil, grpcutil.Internal
120 } 120 }
121 121
122 » // The prefix secret must match the request secret. If it does, we know this 122 » // If we're past prefix's expiration, reject this stream.
123 » if now := clock.Now(c); !now.Before(pfx.Expiration) {
nodir 2016/05/19 00:54:00 I am not sure how you do the migration (CL descrip
dnj (Google) 2016/05/19 02:06:19 Hmm good question. I have an idea: Since we're def
nodir 2016/05/19 03:06:33 Yeah, how you gonna fetch new configs without depl
dnj (Google) 2016/05/19 03:20:06 Oh that part's easy. I'll upload the new version,
124 » » log.Fields{
125 » » » "prefix": pfx.Prefix,
126 » » » "expiration": pfx.Expiration,
127 » » }.Errorf(c, "The log stream Prefix has expired.")
128 » » return nil, grpcutil.Errf(codes.FailedPrecondition, "prefix has expired")
129 » }
130
131 » // The prefix secret much match the request secret. If it does, we know this
nodir 2016/05/19 00:54:00 must
123 // is a legitimate registration attempt. 132 // is a legitimate registration attempt.
124 if subtle.ConstantTimeCompare(pfx.Secret, req.Secret) != 1 { 133 if subtle.ConstantTimeCompare(pfx.Secret, req.Secret) != 1 {
125 log.Errorf(c, "Request secret does not match prefix secret.") 134 log.Errorf(c, "Request secret does not match prefix secret.")
126 return nil, grpcutil.Errf(codes.InvalidArgument, "invalid secret ") 135 return nil, grpcutil.Errf(codes.InvalidArgument, "invalid secret ")
127 } 136 }
128 137
129 // Check for registration, and that the prefix did not expire 138 // Check for registration, and that the prefix did not expire
130 // (non-transactional). 139 // (non-transactional).
131 ls := &coordinator.LogStream{ID: coordinator.LogStreamID(path)} 140 ls := &coordinator.LogStream{ID: coordinator.LogStreamID(path)}
132 lst := ls.State(di) 141 lst := ls.State(di)
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 return nil, grpcutil.Internal 255 return nil, grpcutil.Internal
247 } 256 }
248 } 257 }
249 258
250 return nil, nil 259 return nil, nil
251 } 260 }
252 261
253 func (m *registerStreamMutation) Root(c context.Context) *ds.Key { 262 func (m *registerStreamMutation) Root(c context.Context) *ds.Key {
254 return ds.Get(c).KeyForObj(m.ls) 263 return ds.Get(c).KeyForObj(m.ls)
255 } 264 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698