Skip to content

Commit

Permalink
Fix potential stats panic (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
anjmao authored Jan 29, 2025
1 parent 1fd2e9f commit c468e37
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions cmd/agent/daemon/state/stats_pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,16 @@ func getPSIStatsDiff(prev, curr *castaipb.PSIStats) *castaipb.PSIStats {
if prev == nil || curr == nil {
return nil
}
return &castaipb.PSIStats{
Some: &castaipb.PSIData{
res := &castaipb.PSIStats{}
if curr.Some != nil && prev.Some != nil {
res.Some = &castaipb.PSIData{
Total: curr.Some.Total - prev.Some.Total,
},
Full: &castaipb.PSIData{
}
}
if curr.Full != nil && prev.Full != nil {
res.Full = &castaipb.PSIData{
Total: curr.Full.Total - prev.Full.Total,
},
}
}
return res
}

0 comments on commit c468e37

Please sign in to comment.