From a271940d66ed317b1955a5ebe480a5d7b4c72e30 Mon Sep 17 00:00:00 2001 From: SimFG Date: Wed, 31 May 2023 19:54:33 +0800 Subject: [PATCH] Return error response when an unimplemented request is received (#24546) Signed-off-by: SimFG --- internal/kv/mem/mem_kv.go | 4 ++-- internal/proxy/impl.go | 7 ++++++- internal/proxy/proxy_test.go | 6 ++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/internal/kv/mem/mem_kv.go b/internal/kv/mem/mem_kv.go index 91c094cc8..40dc1476e 100644 --- a/internal/kv/mem/mem_kv.go +++ b/internal/kv/mem/mem_kv.go @@ -17,11 +17,11 @@ package memkv import ( + "errors" "strings" "sync" "github.com/google/btree" - "github.com/milvus-io/milvus/internal/common" ) @@ -284,7 +284,7 @@ func (kv *MemoryKV) Close() { // MultiRemoveWithPrefix not implemented func (kv *MemoryKV) MultiRemoveWithPrefix(keys []string) error { - panic("not implement") + return errors.New("not implement") } // MultiSaveAndRemoveWithPrefix saves key-value pairs in @saves, & remove key with prefix in @removals in MemoryKV atomically. diff --git a/internal/proxy/impl.go b/internal/proxy/impl.go index 1e2e2d560..9fffb1312 100644 --- a/internal/proxy/impl.go +++ b/internal/proxy/impl.go @@ -3773,7 +3773,12 @@ func (node *Proxy) FlushAll(ctx context.Context, _ *milvuspb.FlushAllRequest) (* // GetDdChannel returns the used channel for dd operations. func (node *Proxy) GetDdChannel(ctx context.Context, request *internalpb.GetDdChannelRequest) (*milvuspb.StringResponse, error) { - panic("implement me") + return &milvuspb.StringResponse{ + Status: &commonpb.Status{ + ErrorCode: commonpb.ErrorCode_UnexpectedError, + Reason: "TODO: implement me", + }, + }, nil } // GetPersistentSegmentInfo get the information of sealed segment. diff --git a/internal/proxy/proxy_test.go b/internal/proxy/proxy_test.go index 66fc7b775..be8466ae6 100644 --- a/internal/proxy/proxy_test.go +++ b/internal/proxy/proxy_test.go @@ -1451,10 +1451,8 @@ func TestProxy(t *testing.T) { }) t.Run("get dd channel", func(t *testing.T) { - f := func() { - _, _ = proxy.GetDdChannel(ctx, &internalpb.GetDdChannelRequest{}) - } - assert.Panics(t, f) + resp, _ := proxy.GetDdChannel(ctx, &internalpb.GetDdChannelRequest{}) + assert.NotEqual(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode) }) wg.Add(1) -- GitLab