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

Add some info and debug logging to commonly used funcs #1106

Merged
merged 1 commit into from
Oct 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/api/entries.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func signEntry(ctx context.Context, signer signature.Signer, entry models.LogEnt
func logEntryFromLeaf(ctx context.Context, signer signature.Signer, tc TrillianClient, leaf *trillian.LogLeaf,
signedLogRoot *trillian.SignedLogRoot, proof *trillian.Proof, tid int64, ranges sharding.LogRanges) (models.LogEntry, error) {

log.ContextLogger(ctx).Debugf("log entry from leaf %d", leaf.GetLeafIndex())
root := &ttypes.LogRootV1{}
if err := root.UnmarshalBinary(signedLogRoot.LogRoot); err != nil {
return nil, err
Expand Down Expand Up @@ -503,6 +504,8 @@ func SearchLogQueryHandler(params entries.SearchLogQueryParams) middleware.Respo
var ErrNotFound = errors.New("grpc returned 0 leaves with success code")

func retrieveLogEntryByIndex(ctx context.Context, logIndex int) (models.LogEntry, error) {
log.ContextLogger(ctx).Infof("Retrieving log entry by index %d", logIndex)

tid, resolvedIndex := api.logRanges.ResolveVirtualIndex(logIndex)
tc := NewTrillianClientFromTreeID(ctx, tid)
log.ContextLogger(ctx).Debugf("Retrieving resolved index %v from TreeID %v", resolvedIndex, tid)
Expand All @@ -529,6 +532,8 @@ func retrieveLogEntryByIndex(ctx context.Context, logIndex int) (models.LogEntry
// If a tree ID is specified, look in that tree
// Otherwise, look through all inactive and active shards
func retrieveLogEntry(ctx context.Context, entryUUID string) (models.LogEntry, error) {
log.ContextLogger(ctx).Debugf("Retrieving log entry %v", entryUUID)

uuid, err := sharding.GetUUIDFromIDString(entryUUID)
if err != nil {
return nil, sharding.ErrPlainUUID
Expand Down Expand Up @@ -559,6 +564,8 @@ func retrieveLogEntry(ctx context.Context, entryUUID string) (models.LogEntry, e
}

func retrieveUUIDFromTree(ctx context.Context, uuid string, tid int64) (models.LogEntry, error) {
log.ContextLogger(ctx).Debugf("Retrieving log entry %v from tree %d", uuid, tid)

hashValue, err := hex.DecodeString(uuid)
if err != nil {
return models.LogEntry{}, types.ValidationError(err)
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/public_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/go-openapi/swag"
"github.com/sigstore/rekor/pkg/generated/models"
"github.com/sigstore/rekor/pkg/generated/restapi/operations/pubkey"
"github.com/sigstore/rekor/pkg/log"
)

func GetPublicKeyHandler(params pubkey.GetPublicKeyParams) middleware.Responder {
Expand All @@ -33,6 +34,7 @@ func GetPublicKeyHandler(params pubkey.GetPublicKeyParams) middleware.Responder
if err != nil {
return handleRekorAPIError(params, http.StatusBadRequest, err, "")
}
log.ContextLogger(ctx).Info("returning public key")
return pubkey.NewGetPublicKeyOK().WithPayload(pk)
}

Expand Down