Skip to content

Commit

Permalink
fix: Fix panicking in remove collection-drop when collection not ex…
Browse files Browse the repository at this point in the history
…ist (#250)

When collection with provided id not exist, birdwatcher will have NPE
panic

Also add log and return fast when list collection fails in same command

Signed-off-by: Congqi Xia <[email protected]>
  • Loading branch information
congqixia authored Mar 14, 2024
1 parent ca52082 commit cbb1da9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions states/etcd/remove/collection_dropping.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func CollectionDropCommand(cli clientv3.KV, basePath string) *cobra.Command {
collection, err := common.GetCollectionByIDVersion(context.Background(), cli, basePath, etcdversion.GetVersion(), collectionID)
if err != nil {
fmt.Printf("failed to get collection by id(%d): %s\n", collectionID, err.Error())
return
}
// skip healthy collection
if collection.State != models.CollectionStateCollectionDropping && collection.State != models.CollectionStateCollectionDropped {
Expand All @@ -45,6 +46,10 @@ func CollectionDropCommand(cli clientv3.KV, basePath string) *cobra.Command {
collections, err = common.ListCollectionsVersion(context.Background(), cli, basePath, etcdversion.GetVersion(), func(coll *models.Collection) bool {
return coll.State == models.CollectionStateCollectionDropping || coll.State == models.CollectionStateCollectionDropped
})
if err != nil {
fmt.Println("failed to list collection", err.Error())
return
}
}

for _, collection := range collections {
Expand Down

0 comments on commit cbb1da9

Please sign in to comment.