Skip to content
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

Create EntryID for new artifacts and return EntryID to user #623

Merged
merged 1 commit into from
Apr 12, 2022

Conversation

lkatalin
Copy link
Contributor

@lkatalin lkatalin commented Jan 26, 2022

Summary

This will complete the UUID parsing component of the sharding work. It creates and returns a longer UUID (EntryID) to the user, so this change should go into a new release.

Edit:
As far as I understand, we should wait to merge this PR until we're ready for a new Rekor release - are there other changes that would go into that release? Do we have a timeline?

Ticket Link

Fixes #487

Release Note

    TODO

@lkatalin lkatalin force-pushed the uuidpr3 branch 3 times, most recently from 4613650 to 565128a Compare January 27, 2022 18:38
@lkatalin lkatalin marked this pull request as ready for review January 27, 2022 18:54
Comment on lines 190 to 191
err := fmt.Errorf("error creating EntryID from active treeID and uuid %v: %v", hexEncodedHash, err)
return nil, handleRekorAPIError(params, http.StatusBadRequest, err, fmt.Sprintf(validationError, err))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
err := fmt.Errorf("error creating EntryID from active treeID and uuid %v: %v", hexEncodedHash, err)
return nil, handleRekorAPIError(params, http.StatusBadRequest, err, fmt.Sprintf(validationError, err))
err := fmt.Errorf("error creating EntryID from active treeID and uuid %v: %w", hexEncodedHash, err)
return nil, handleRekorAPIError(params, http.StatusInternalServerError, err, fmt.Sprintf(validationError, err))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at this point we've already committed the change to the log... so while I expect this code path to never actually get executed, the burden wouldn't be on the client to resolve anything so we should return a 500 error.

@dlorenc
Copy link
Member

dlorenc commented Feb 1, 2022

Edit: As far as I understand, we should wait to merge this PR until we're ready for a new Rekor release - are there other changes that would go into that release? Do we have a timeline?

This is correct! We should release a version of the client that supports longer versions ASAP - then release this some time later.

@cpanato any idea if we can kick off another Rekor CLI release?

@dlorenc
Copy link
Member

dlorenc commented Feb 1, 2022

Just to confirm my understanding:

  • If you build rekor-cli from HEAD, it should work with rekor-server running this change AND before this change
  • The currently released rekor-cli will not work with this change

@cpanato
Copy link
Member

cpanato commented Feb 1, 2022

Edit: As far as I understand, we should wait to merge this PR until we're ready for a new Rekor release - are there other changes that would go into that release? Do we have a timeline?

This is correct! We should release a version of the client that supports longer versions ASAP - then release this some time later.

@cpanato any idea if we can kick off another Rekor CLI release?

we can cut a v0.5.0 release, I don't think we are ready for a v1.0.0

I will check the changelog and maybe we can cut that today

@dlorenc
Copy link
Member

dlorenc commented Feb 1, 2022

+1 to v0.5!

@lkatalin
Copy link
Contributor Author

lkatalin commented Feb 1, 2022

Just to confirm my understanding:

* If you build rekor-cli from HEAD, it should work with rekor-server running this change AND before this change

* The currently released rekor-cli will not work with this change

@dlorenc This is also my understanding. There is an e2e test right now that includes a rekor-cli GET command for the new EntryID here.

@cpanato
Copy link
Member

cpanato commented Feb 4, 2022

Copy link
Member

@lukehinds lukehinds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code looks good to me, once the cli is up to speed.

Copy link
Member

@bobcallaway bobcallaway left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm other than minor error wrapping nit

hexEncodedHash := hex.EncodeToString(queuedLeaf.GetMerkleLeafHash())
entryID, err := sharding.CreateEntryIDWithActiveTreeID(hexEncodedHash)
if err != nil {
err := fmt.Errorf("error creating EntryID from active treeID and uuid %v: %v", hexEncodedHash, err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit if you end up re-spinning this:

Suggested change
err := fmt.Errorf("error creating EntryID from active treeID and uuid %v: %v", hexEncodedHash, err)
err := fmt.Errorf("error creating EntryID from active treeID and uuid %v: %w", hexEncodedHash, err)

@lkatalin
Copy link
Contributor Author

Note to self: after #671 is merged, we will have to use CreateEntryIDFromParts(api.logRanges.ActiveIndex(), uuid) instead of CreateEntryIDWithActiveTreeID(uuid). This moves some logic out of the sharding package.

@lkatalin lkatalin requested a review from a team as a code owner March 1, 2022 02:10
@lkatalin
Copy link
Contributor Author

lkatalin commented Mar 1, 2022

I think this will require #671 to be merged first to pass CI.

priyawadhwa added a commit to priyawadhwa/rekor that referenced this pull request Mar 4, 2022
@dlorenc
Copy link
Member

dlorenc commented Mar 26, 2022

What's the plan for merging and rolling this out?

@lkatalin
Copy link
Contributor Author

What's the plan for merging and rolling this out?

@dlorenc Once we merge #727 , that should take care of the last known bug. @priyawadhwa and I are double checking on anything else that needs to happen from the roadmap before merging this, but I think most/all of the outstanding work should be optional.

Copy link
Contributor

@priyawadhwa priyawadhwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nits around naming, otherwise LGTM!

@@ -223,7 +223,10 @@ func TestGet(t *testing.T) {
out := runCli(t, "upload", "--artifact", artifactPath, "--signature", sigPath, "--public-key", pubPath)
outputContains(t, out, "Created entry at")

uuid := getUUIDFromUploadOutput(t, out)
uuid, err := sharding.GetUUIDFromIDString(getUUIDFromUploadOutput(t, out))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should getUUIDFromUploadOutput be renamed to getEntryIDFromUploadOutput?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, though this is a larger problem all throughout the code. #625 is tracking this. Pulling on that thread will definitely create enough changes for another PR.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can save it for later then!

@@ -187,7 +187,14 @@ func createLogEntry(params entries.CreateLogEntryParams) (models.LogEntry, middl
metricNewEntries.Inc()

queuedLeaf := resp.getAddResult.QueuedLeaf.Leaf
uuid := hex.EncodeToString(queuedLeaf.GetMerkleLeafHash())

hexEncodedHash := hex.EncodeToString(queuedLeaf.GetMerkleLeafHash())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hexEncodedHash is the same as uuid right? might be clearer to keep the name as uuid since entry id = tree id + uuid

@lkatalin lkatalin force-pushed the uuidpr3 branch 3 times, most recently from 39b4607 to aff3f76 Compare April 11, 2022 18:22
@lkatalin lkatalin force-pushed the uuidpr3 branch 3 times, most recently from 91f36ee to 6bac6ad Compare April 11, 2022 19:39
Signed-off-by: Lily Sturmann <lsturman@redhat.com>
Copy link
Contributor

@priyawadhwa priyawadhwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support UUID --> shard ID parsing
6 participants