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 DealStages to track and log Deal status updates #502

Merged
merged 23 commits into from
Mar 30, 2021
Merged

Conversation

nonsense
Copy link
Member

@nonsense nonsense commented Mar 4, 2021

Closes #501

@nonsense nonsense force-pushed the add-deal-stages branch 2 times, most recently from 68ce94b to 5ef2fe8 Compare March 4, 2021 11:45
@@ -141,3 +141,37 @@ var DealStates = map[StorageDealStatus]string{
StorageDealClientTransferRestart: "StorageDealClientTransferRestart",
StorageDealProviderTransferAwaitRestart: "StorageDealProviderTransferAwaitRestart",
}

// DealStatesDescriptions maps StorageDealStatus codes to string description for better UX
var DealStatesDescriptions = map[StorageDealStatus]string{
Copy link
Member

Choose a reason for hiding this comment

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

I'd merge this with the above map, making it a map[StorageDealStatus]struct{Name: string, Desc: string}

Copy link
Contributor

Choose a reason for hiding this comment

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

The DealStates map is already used in a lot of places across the code so if you unify the maps, may be a good idea to add an init() function that also recreates the DealStates map

Copy link
Member Author

Choose a reason for hiding this comment

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

The DealStates map is already used in a lot of places across the code

This was the main reason I created a new map.

I suggest we do that refactor as a next step, as I am sure we will want to adjust messages and descriptions very soon.

Copy link
Member

@raulk raulk left a comment

Choose a reason for hiding this comment

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

There is a Notifier primitive in go-statemachine/fsm that we could use if we want to move the user friendly messages away from the state machine and into Lotus. Just a thought that came up while discussing with @nonsense today.

https://pkg.go.dev/github.com/filecoin-project/go-statemachine/fsm#Notifier

@raulk raulk added the x/ignite Issues and PRs being tracked by Team Ignite at Protocol Labs label Mar 9, 2021
@codecov-io
Copy link

Codecov Report

Merging #502 (d96bb00) into master (d5b1990) will increase coverage by 0.42%.
The diff coverage is 85.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #502      +/-   ##
==========================================
+ Coverage   65.41%   65.83%   +0.42%     
==========================================
  Files          51       51              
  Lines        3431     3505      +74     
==========================================
+ Hits         2244     2307      +63     
- Misses        958      969      +11     
  Partials      229      229              
Impacted Files Coverage Δ
storagemarket/impl/client.go 20.08% <0.00%> (-0.07%) ⬇️
storagemarket/impl/clientstates/client_fsm.go 81.65% <79.17%> (-1.08%) ⬇️
storagemarket/types.go 86.21% <100.00%> (+86.21%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d5b1990...d96bb00. Read the comment docs.

Copy link
Contributor

@dirkmc dirkmc left a comment

Choose a reason for hiding this comment

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

Looking good, just some suggestions on re-wording the messages

storagemarket/impl/clientstates/client_fsm.go Outdated Show resolved Hide resolved
storagemarket/impl/clientstates/client_fsm.go Outdated Show resolved Hide resolved
storagemarket/impl/clientstates/client_fsm.go Outdated Show resolved Hide resolved
storagemarket/impl/clientstates/client_fsm.go Outdated Show resolved Hide resolved
storagemarket/impl/clientstates/client_fsm.go Outdated Show resolved Hide resolved
storagemarket/impl/clientstates/client_fsm.go Outdated Show resolved Hide resolved
storagemarket/impl/clientstates/client_fsm.go Outdated Show resolved Hide resolved
storagemarket/impl/clientstates/client_fsm.go Outdated Show resolved Hide resolved
storagemarket/impl/clientstates/client_fsm.go Outdated Show resolved Hide resolved
storagemarket/types.go Outdated Show resolved Hide resolved
@nonsense nonsense marked this pull request as ready for review March 19, 2021 11:42
From(storagemarket.StorageDealFailing).To(storagemarket.StorageDealError),
From(storagemarket.StorageDealFailing).To(storagemarket.StorageDealError).
Action(func(deal *storagemarket.ClientDeal) error {
deal.AddLog("")
Copy link
Member

Choose a reason for hiding this comment

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

Is this empty string intended?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, so that we add the given stage with a timestamp to the event log, even if we don't want to add any message.

storagemarket/types.go Show resolved Hide resolved
func TestDealStagesNil(t *testing.T) {
var ds *storagemarket.DealStages
ds.GetStage("none")
ds.AddStageLog("MyStage", "desc", "duration", "msg")
Copy link
Member

Choose a reason for hiding this comment

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

Anything that we want to assert on?

// EXPERIMENTAL; subject to change.
func (ds *DealStages) AddStageLog(stage, description, expectedDuration, msg string) {
if ds == nil {
return
Copy link
Member

Choose a reason for hiding this comment

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

We don't want to create a DealStages instance here? I guess it would allow us to display partial logs for deals that were in progress before this code got deployed?

if ds == nil {
    *ds = DealStages{}
}

Copy link
Member

Choose a reason for hiding this comment

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

Actually, this is not possible. We would need to return the new DealStages object, similar to how hashicorp/go-multierror.Append works: https://pkg.go.dev/github.com/hashicorp/go-multierror#Append

Copy link
Member Author

@nonsense nonsense Mar 29, 2021

Choose a reason for hiding this comment

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

This is done for backward compatibility with deals that are created with earlier versions - in these cases we just don't want to have to have DealStages.

@dirkmc dirkmc merged commit 39a8025 into master Mar 30, 2021
@dirkmc dirkmc deleted the add-deal-stages branch March 30, 2021 07:57
@dirkmc dirkmc mentioned this pull request Mar 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x/ignite Issues and PRs being tracked by Team Ignite at Protocol Labs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UX: Design for deal status updates
4 participants