Skip to content

Commit

Permalink
Fixbug: filter by planID is not working
Browse files Browse the repository at this point in the history
Signed-off-by: zhenshan.cao <[email protected]>
  • Loading branch information
czs007 committed Jul 15, 2024
1 parent 1102594 commit cb442f8
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions states/etcd/show/compaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ package show
import (
"context"
"fmt"
"sort"
"strings"
"time"

"github.com/samber/lo"

"github.com/milvus-io/birdwatcher/framework"
"github.com/milvus-io/birdwatcher/models"
"github.com/milvus-io/birdwatcher/states/etcd/common"
Expand All @@ -20,7 +23,8 @@ type CompactionTaskParam struct {
CollectionID int64 `name:"collectionID" default:"0" desc:"collection id to filter"`
PartitionID int64 `name:"partitionID" default:"0" desc:"partitionID id to filter"`
TriggerID int64 `name:"triggerID" default:"0" desc:"TriggerID to filter"`
PlanID int64 ` name:"planID" default:"" desc:"PlanID to filter"`
PlanID int64 ` name:"planID" default:"0" desc:"PlanID to filter"`
SegmentID int64 ` name:"segmentID" default:"0" desc:"SegmentID to filter"`
Detail bool `name:"detail" default:"false" desc:"flags indicating whether printing input/result segmentIDs"`
}

Expand All @@ -45,8 +49,11 @@ func (c *ComponentShow) CompactionTaskCommand(ctx context.Context, p *Compaction
if p.TriggerID > 0 && task.GetTriggerID() != p.TriggerID {
return false
}
if p.PlanID > 0 && task.GetPlanID() != p.PlanID {
return false
}

if p.PlanID > 0 && task.GetPlanID() != p.TriggerID {
if p.SegmentID > 0 && !lo.Contains(task.GetInputSegments(), p.SegmentID) {
return false
}
if p.State != "" && !strings.EqualFold(p.State, task.GetState().String()) {
Expand All @@ -58,6 +65,9 @@ func (c *ComponentShow) CompactionTaskCommand(ctx context.Context, p *Compaction
if err != nil {
return nil, err
}
sort.Slice(compactionTasks, func(i, j int) bool {
return compactionTasks[i].GetPlanID() < compactionTasks[j].GetPlanID()
})
return &CompactionTasks{
tasks: compactionTasks,
total: total,
Expand Down

0 comments on commit cb442f8

Please sign in to comment.