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

feat: query UI #1352

Merged
merged 6 commits into from
Apr 5, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion retrievalmarket/rtvllog/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ func (d *RetrievalLogDB) list(ctx context.Context, offset int, limit int, where

dealState.PayloadCID, err = cid.Parse(payloadCid.String)
if err != nil {
return nil, fmt.Errorf("parsing payload cid '%s': %w", payloadCid.String, err)
dealState.PayloadCID = cid.Undef
}

if pieceCid.Valid && pieceCid.String != "" {
Expand Down
24 changes: 24 additions & 0 deletions retrievalmarket/rtvllog/retrieval_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,30 @@ func (r *RetrievalLog) OnQueryEvent(evt retrievalmarket.ProviderQueryEvent) {
"status", evt.Response.Status,
"msg", evt.Response.Message,
"err", evt.Error)

// Log failures to DB
st := &RetrievalDealState{
UnsealPrice: evt.Response.UnsealPrice,
Message: evt.Response.Message,
}
if evt.Error != nil {
st.Status = evt.Error.Error()
} else {
Copy link
Contributor

Choose a reason for hiding this comment

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

In the case that evt.Error is not nil, let's

  • set st.Status to "Failed"
  • check if evt.Response.Message is set
    • if not, set st.Message to evt.Error.Error()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this will cause us to log all queries (even the successful ones as well). If evt.Error is not nil then response itself was successful but we might send "not available" or "error in query" responses along with "available" response. I would have no condition to decide when to log and when to skip.
From the code it looks like evt.Response.Message is always set for query event and evt.Error.Error() would be empty for successful responses when "not available" or "error in query" message is being sent. Overriding the message value will result in los of the real reason for failure.

if evt.Response.Status == retrievalmarket.QueryResponseUnavailable {
st.Status = "unavailable"
}
if evt.Response.Status == retrievalmarket.QueryResponseError {
st.Status = "errored"
}
}
if st.Status != "" {
r.dbUpdate(func() {
err := r.db.Insert(r.ctx, st)
if err != nil {
log.Errorw("failed to update retrieval deal logger db", "err", err)
}
})
}
}

// Called when there is a validation event.
Expand Down