Skip to content

Commit

Permalink
Fix embedEtcdState command missing (#190)
Browse files Browse the repository at this point in the history
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
  • Loading branch information
congqixia committed Aug 18, 2023
1 parent 9f0d13b commit 4cbe675
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,14 @@ birdwatcher-build

# logs
audit.log
audit_*.log
bw_debug.log

# vim
*.sw[op]

# backup file
*.bak.gz
*.tar.gz
backups/

1 change: 1 addition & 0 deletions states/app_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (app *ApplicationState) Process(cmd string) (framework.State, error) {
for key, state := range app.states {
next := state.NextState()
if next != nil {
app.config.Log("[debug] set next", key, next.Label())
state.SetNext(nil)
app.states[key] = next
}
Expand Down
11 changes: 4 additions & 7 deletions states/backup_mock_connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ func (s *embedEtcdMockState) Close() {
// SetupCommands setups the command.
// also called after each command run to reset flag values.
func (s *embedEtcdMockState) SetupCommands() {
cmd := &cobra.Command{}
cmd := s.GetCmd()

rootPath := path.Join(s.instanceName, metaPath)

cmd.AddCommand(
s.MergeCobraCommands(cmd,
// show [subcommand] options...
etcd.ShowCommand(s.client, rootPath),

Expand All @@ -83,12 +83,9 @@ func (s *embedEtcdMockState) SetupCommands() {

getListMetricsNodeCmd(s),
)
cmd.AddCommand(etcd.RawCommands(s.client)...)
s.MergeCobraCommands(cmd, etcd.RawCommands(s.client)...)

s.MergeFunctionCommands(cmd, s)

s.CmdState.RootCmd = cmd
s.SetupFn = s.SetupCommands
s.UpdateState(cmd, s, s.SetupCommands)
}

func (s *embedEtcdMockState) SetInstance(instanceName string) {
Expand Down
8 changes: 7 additions & 1 deletion states/etcd/show/collection_loaded.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/milvus-io/birdwatcher/models"
"github.com/milvus-io/birdwatcher/states/etcd/common"
etcdversion "github.com/milvus-io/birdwatcher/states/etcd/version"
"github.com/samber/lo"
)

const (
Expand All @@ -18,7 +19,7 @@ const (

type CollectionLoadedParam struct {
framework.ParamBase `use:"show collection-loaded" desc:"display information of loaded collection from querycoord" alias:"collection-load"`
//CollectionID int64 `name:""`
CollectionID int64 `name:"collection" default:"0" desc:"collection id to check"`
}

// CollectionLoadedCommand return show collection-loaded command.
Expand All @@ -31,6 +32,11 @@ func (c *ComponentShow) CollectionLoadedCommand(ctx context.Context, p *Collecti
if err != nil {
return nil, errors.Wrap(err, "failed to list collection load info")
}
if p.CollectionID > 0 {
infos = lo.Filter(infos, func(info *models.CollectionLoaded, _ int) bool {
return info.CollectionID == p.CollectionID
})
}

return framework.NewListResult[CollectionsLoaded](infos), nil
}
Expand Down
5 changes: 4 additions & 1 deletion states/etcd/show/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

type IndexParam struct {
framework.ParamBase `use:"show index" desc:"" alias:"indexes"`
CollectionID int64 `name:"collection" default:"0" desc:"collection id to list index on"`
}

// IndexCommand returns show index command.
Expand All @@ -39,7 +40,9 @@ func (c *ComponentShow) IndexCommand(ctx context.Context, p *IndexParam) {
}

for _, index := range fieldIndexes {
printIndexV2(index)
if p.CollectionID == 0 || p.CollectionID == index.IndexInfo.GetCollectionID() {
printIndexV2(index)
}
}
}

Expand Down

0 comments on commit 4cbe675

Please sign in to comment.