From 14c1182418d27507845863de7fd63ec2360fc0e8 Mon Sep 17 00:00:00 2001 From: congqixia Date: Mon, 7 Nov 2022 16:55:01 +0800 Subject: [PATCH] Add healthy check for InvalidateCollectionMetaCache (#20368) Signed-off-by: Congqi Xia Signed-off-by: Congqi Xia --- internal/proxy/impl.go | 4 ++++ internal/proxy/impl_test.go | 1 + internal/proxy/proxy_test.go | 6 ++++++ 3 files changed, 11 insertions(+) diff --git a/internal/proxy/impl.go b/internal/proxy/impl.go index 3db570f62..556ab88b5 100644 --- a/internal/proxy/impl.go +++ b/internal/proxy/impl.go @@ -102,6 +102,10 @@ func (node *Proxy) GetStatisticsChannel(ctx context.Context) (*milvuspb.StringRe // InvalidateCollectionMetaCache invalidate the meta cache of specific collection. func (node *Proxy) InvalidateCollectionMetaCache(ctx context.Context, request *proxypb.InvalidateCollMetaCacheRequest) (*commonpb.Status, error) { + if !node.checkHealthy() { + return unhealthyStatus(), nil + } + ctx = logutil.WithModule(ctx, moduleName) logutil.Logger(ctx).Info("received request to invalidate collection meta cache", zap.String("role", typeutil.ProxyRole), diff --git a/internal/proxy/impl_test.go b/internal/proxy/impl_test.go index d602d88ef..d22765f72 100644 --- a/internal/proxy/impl_test.go +++ b/internal/proxy/impl_test.go @@ -28,6 +28,7 @@ func TestProxy_InvalidateCollectionMetaCache_remove_stream(t *testing.T) { } node := &Proxy{chMgr: chMgr} + node.stateCode.Store(commonpb.StateCode_Healthy) ctx := context.Background() req := &proxypb.InvalidateCollMetaCacheRequest{ diff --git a/internal/proxy/proxy_test.go b/internal/proxy/proxy_test.go index cf1d476cf..d835b3fa4 100644 --- a/internal/proxy/proxy_test.go +++ b/internal/proxy/proxy_test.go @@ -2680,6 +2680,12 @@ func TestProxy(t *testing.T) { assert.NotEqual(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode) }) + t.Run("InvalidateCollectionMetaCache failed", func(t *testing.T) { + resp, err := proxy.InvalidateCollectionMetaCache(ctx, &proxypb.InvalidateCollMetaCacheRequest{}) + assert.NoError(t, err) + assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetErrorCode()) + }) + testProxyRoleUnhealthy(ctx, t, proxy) testProxyPrivilegeUnhealthy(ctx, t, proxy) testProxyRefreshPolicyInfoCacheUnhealthy(ctx, t, proxy) -- GitLab