Add healthy check for InvalidateCollectionMetaCache (#20368) (#20378)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/20392/head
congqixia 2022-11-07 19:53:03 +08:00 committed by GitHub
parent 9523a778c1
commit 65a2b1c5a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 0 deletions

View File

@ -101,6 +101,10 @@ func (node *Proxy) GetStatisticsChannel(ctx context.Context) (*milvuspb.StringRe
// InvalidateCollectionMetaCache invalidate the meta cache of specific collection. // InvalidateCollectionMetaCache invalidate the meta cache of specific collection.
func (node *Proxy) InvalidateCollectionMetaCache(ctx context.Context, request *proxypb.InvalidateCollMetaCacheRequest) (*commonpb.Status, error) { func (node *Proxy) InvalidateCollectionMetaCache(ctx context.Context, request *proxypb.InvalidateCollMetaCacheRequest) (*commonpb.Status, error) {
if !node.checkHealthy() {
return unhealthyStatus(), nil
}
ctx = logutil.WithModule(ctx, moduleName) ctx = logutil.WithModule(ctx, moduleName)
logutil.Logger(ctx).Info("received request to invalidate collection meta cache", logutil.Logger(ctx).Info("received request to invalidate collection meta cache",
zap.String("role", typeutil.ProxyRole), zap.String("role", typeutil.ProxyRole),

View File

@ -26,6 +26,7 @@ func TestProxy_InvalidateCollectionMetaCache_remove_stream(t *testing.T) {
} }
node := &Proxy{chMgr: chMgr} node := &Proxy{chMgr: chMgr}
node.stateCode.Store(commonpb.StateCode_Healthy)
ctx := context.Background() ctx := context.Background()
req := &proxypb.InvalidateCollMetaCacheRequest{ req := &proxypb.InvalidateCollMetaCacheRequest{

View File

@ -2697,6 +2697,12 @@ func TestProxy(t *testing.T) {
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode) 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) testProxyRoleUnhealthy(ctx, t, proxy)
testProxyPrivilegeUnhealthy(ctx, t, proxy) testProxyPrivilegeUnhealthy(ctx, t, proxy)
testProxyRefreshPolicyInfoCacheUnhealthy(ctx, t, proxy) testProxyRefreshPolicyInfoCacheUnhealthy(ctx, t, proxy)