Skip to content

Commit

Permalink
split erred states from the rest
Browse files Browse the repository at this point in the history
  • Loading branch information
nonsense committed Apr 6, 2022
1 parent 64b1979 commit 0f47b46
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 17 deletions.
47 changes: 33 additions & 14 deletions gql/resolver_sealingpipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,36 +75,55 @@ func (r *resolver) SealingPipeline(ctx context.Context) (*sealingPipelineState,
}
}

// TODO: put states in order
var order int32
sectorStates := []*sectorState{}
for k, v := range summary {
if v == 0 {
for order, state := range allSectorStates {
count, ok := summary[api.SectorState(state)]
if !ok {
continue
}
if count == 0 {
continue
}
order++

if _, ok := normalSectors[string(k)]; ok {
if _, ok := normalSectors[state]; ok {
sectorStates = append(sectorStates, &sectorState{
Key: string(k),
Value: int32(v),
Key: state,
Value: int32(count),
Type: "Regular",
Order: order,
Order: int32(order),
})
continue
}

if _, ok := snapdealsSectors[string(k)]; ok {
if _, ok := normalErredSectors[state]; ok {
sectorStates = append(sectorStates, &sectorState{
Key: string(k),
Value: int32(v),
Key: state,
Value: int32(count),
Type: "Regular / Erred",
Order: int32(order),
})
continue
}

if _, ok := snapdealsSectors[state]; ok {
sectorStates = append(sectorStates, &sectorState{
Key: state,
Value: int32(count),
Type: "Snap Deals",
Order: order,
Order: int32(order),
})
continue
}

log.Errorw("unknown sector in resolver", "name", string(k), "count", v)
if _, ok := snapdealsSectors[state]; ok {
sectorStates = append(sectorStates, &sectorState{
Key: state,
Value: int32(count),
Type: "Snap Deals / Erred",
Order: int32(order),
})
continue
}
}

return &sealingPipelineState{
Expand Down
27 changes: 24 additions & 3 deletions gql/sector_states.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
package gql

var (
normalSectors map[string]struct{}
snapdealsSectors map[string]struct{}
normalSectors map[string]struct{}
normalErredSectors map[string]struct{}
snapdealsSectors map[string]struct{}
snapdealsErredSectors map[string]struct{}

allSectorStates []string

// ordered
normalSectorsList = []string{
"WaitDeals",
"AddPiece",
Expand All @@ -25,8 +30,9 @@ var (
"CommitAggregateWait",
"FinalizeSector",
"Proving",
}

// error modes
normalErredSectorsList = []string{
"FailedUnrecoverable",
"AddPieceFailed",
"SealPreCommit1Failed",
Expand Down Expand Up @@ -63,7 +69,9 @@ var (
"FinalizeReplicaUpdate",
"UpdateActivating",
"ReleaseSectorKey",
}

snapdealsErredSectorsList = []string{
// snap deals error modes
"SnapDealsAddPieceFailed",
"SnapDealsDealsExpired",
Expand All @@ -76,13 +84,26 @@ var (
)

func init() {
allSectorStates = append(allSectorStates, normalSectorsList...)
allSectorStates = append(allSectorStates, normalErredSectorsList...)
allSectorStates = append(allSectorStates, snapdealsSectorsList...)
allSectorStates = append(allSectorStates, snapdealsErredSectorsList...)

normalSectors = make(map[string]struct{})
normalErredSectors = make(map[string]struct{})
snapdealsSectors = make(map[string]struct{})
snapdealsErredSectors = make(map[string]struct{})

for _, s := range normalSectorsList {
normalSectors[s] = struct{}{}
}
for _, s := range normalErredSectorsList {
normalErredSectors[s] = struct{}{}
}
for _, s := range snapdealsSectorsList {
snapdealsSectors[s] = struct{}{}
}
for _, s := range snapdealsErredSectorsList {
snapdealsErredSectors[s] = struct{}{}
}
}

0 comments on commit 0f47b46

Please sign in to comment.