-
Notifications
You must be signed in to change notification settings - Fork 164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use logRangesFlag in API, route reads based on TreeID #671
Conversation
TODO:
|
102a04b
to
b2032c6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
cmd/rekor-server/app/serve.go
Outdated
rangeMap := viper.GetString("trillian_log_server.log_id_ranges") | ||
if rangeMap != "" { | ||
if err := logRangeMap.Set(rangeMap); err != nil { | ||
log.Logger.Errorf("unable to set logRangeMap from flag: %v", err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we can't set the logRangeMap
should this error be fatal?
pkg/api/entries.go
Outdated
tc := NewTrillianClient(ctx) | ||
tid, resolvedIndex := api.logRanges.ResolveVirtualIndex(int(params.LogIndex)) | ||
tc := NewTrillianClientFromTreeID(ctx, int64(tid)) | ||
log.Logger.Debugf("Retrieving resolved index %v from TreeID %v", resolvedIndex, tid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log.Logger.Debugf("Retrieving resolved index %v from TreeID %v", resolvedIndex, tid) | |
log.RequestIDLogger(params.HTTPRequest).Debugf("Retrieving resolved index %v from TreeID %v", resolvedIndex, tid) |
pkg/api/entries.go
Outdated
tc := NewTrillianClientFromTreeID(params.HTTPRequest.Context(), tid) | ||
log.Logger.Debugf("Retrieving UUID %v from TreeID %v", entryUUID, tid) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tc := NewTrillianClientFromTreeID(params.HTTPRequest.Context(), tid) | |
log.Logger.Debugf("Retrieving UUID %v from TreeID %v", entryUUID, tid) | |
tc := NewTrillianClientFromTreeID(ctx, tid) | |
log.RequestIDLogger(params.HTTPRequest).Debugf("Retrieving UUID %v from TreeID %v", entryUUID, tid) |
pkg/sharding/sharding.go
Outdated
// Returns TreeID from an EntryID string | ||
// TODO: Add some tests | ||
func GetTreeIDFromEntryIDString(id string) (int64, error) { | ||
if len(id) == UUIDHexStringLen { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: rewrite this as a switch statement on len(id)
?
b2032c6
to
cb726c8
Compare
I made the requested changes but also ended up adding some testing for Also ended up changing the type of the ints in The handling of a Edit: Unless there are objections, I've made a |
- Adds a function to get a TreeID from an ID string - Adds testing for the above - Consolidates validation logic for UUID, TreeID, EntryID - Removes code that attempts to use ActiveIndex() in the sharding package, as this is not accessible due to import cycles - Other small cleanup and typo fixes Signed-off-by: Lily Sturmann <lsturman@redhat.com>
This is the type used by the trillian TreeID and saves from having to convert in multiple places. Signed-off-by: Lily Sturmann <lsturman@redhat.com>
cb726c8
to
9356473
Compare
WARNING: breaks loginfo cmd to current prod server Signed-off-by: Lily Sturmann <lsturman@redhat.com>
3d204bd
to
49cda5c
Compare
I added the Would it make more sense to return the |
Signed-off-by: Lily Sturmann <lsturman@redhat.com>
Signed-off-by: Lily Sturmann <lsturman@redhat.com>
49cda5c
to
3b9c3d4
Compare
Codecov Report
@@ Coverage Diff @@
## main #671 +/- ##
=======================================
Coverage ? 47.57%
=======================================
Files ? 65
Lines ? 5669
Branches ? 0
=======================================
Hits ? 2697
Misses ? 2682
Partials ? 290 Continue to review full report at Codecov.
|
@lukehinds @bobcallaway @dlorenc Is this okay to merge? |
Looks good to me. I will merge by 'lazy consensus' late Monday if nothing more from @bobcallaway / @dlorenc is posted before then. |
Lgtm! |
Summary
This PR hooks up the
logRangeMap
flag to be used in API construction. The map can then be accessed to do routing for uuid-based and log-index-based reads.I made the
logRangeMap
flag into a string because theSet()
method can be used for construction and it was easier than trying to cram the data into a struct from the flag. But if there's a clean way to do this that doesn't involve this change, I'm happy to do it.WIP because I still need to add some tests,
fix the e2e test, and do some cleanup, ex. maybe around the int types. And I need to think through 1) making sure this will not break old clients, 2) do we need to use this logic in the writes too before merging (I think this will actually be a change made to the pending PR that emits longer UUIDs upon artifact upload).Questions:
treeID
is zero, we use theapi.logID
insteadtlog_id
andlogRangeMap
are passed in, which takes precedence? ThelogRangeMap
'sActiveIndex()
should be thetlog_id
(currently usingActiveIndex()
).tlog_id
in the API on theActiveIndex
? Edit: no, I'm appending thetlog_id
to therangeMap
tlog_id
function as a flag for signaling the need for a new shard? This seems to be how it is used currently viacreateAndInitTree
. Edit: yes, still doing thisNote: Currently it looks like the
tlog_id
in the API is used in only one place inapi.go
, to check whether it is zero and determine if the program shouldcreateAndInitTree
.Edit: So I think my answer to the above is to add logic that will append any nonzero
tlog_id
passed in at server startup to the API'slogRange
, see code from this PR here. If this isn't the right way, let me know or I guess we will change it later.Ticket Link
Fixes #670
Fixes #632
Fixes #629