From 55e504aa180b350dc5f66bc49d50b65e4e4a9cce Mon Sep 17 00:00:00 2001 From: CMGS Date: Tue, 31 Jan 2023 14:17:21 +0800 Subject: [PATCH] mark mock engine always up --- store/etcdv3/node.go | 5 ++++- store/redis/node.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/store/etcdv3/node.go b/store/etcdv3/node.go index e3a8875da..a92fc44fc 100644 --- a/store/etcdv3/node.go +++ b/store/etcdv3/node.go @@ -15,6 +15,7 @@ import ( "github.com/projecteru2/core/engine" enginefactory "github.com/projecteru2/core/engine/factory" "github.com/projecteru2/core/engine/fake" + "github.com/projecteru2/core/engine/mocks/fakeengine" "github.com/projecteru2/core/log" "github.com/projecteru2/core/types" "github.com/projecteru2/core/utils" @@ -319,7 +320,9 @@ func (m *Mercury) doGetNodes(ctx context.Context, kvs []*mvccpb.KeyValue, labels node := node _ = m.pool.Invoke(func() { defer wg.Done() - if _, err := m.GetNodeStatus(ctx, node.Name); err != nil && !errors.Is(err, types.ErrInvaildCount) { + if strings.HasPrefix(node.Endpoint, fakeengine.PrefixKey) { + node.Available = true + } else if _, err := m.GetNodeStatus(ctx, node.Name); err != nil && !errors.Is(err, types.ErrInvaildCount) { logger.Errorf(ctx, err, "failed to get node status of %+v", node.Name) } else { node.Available = err == nil diff --git a/store/redis/node.go b/store/redis/node.go index e1c8ddd39..36d42778c 100644 --- a/store/redis/node.go +++ b/store/redis/node.go @@ -12,6 +12,7 @@ import ( "github.com/projecteru2/core/engine" enginefactory "github.com/projecteru2/core/engine/factory" "github.com/projecteru2/core/engine/fake" + "github.com/projecteru2/core/engine/mocks/fakeengine" "github.com/projecteru2/core/log" "github.com/projecteru2/core/types" "github.com/projecteru2/core/utils" @@ -302,7 +303,9 @@ func (r *Rediaron) doGetNodes(ctx context.Context, kvs map[string]string, labels node := node _ = r.pool.Invoke(func() { defer wg.Done() - if _, err := r.GetNodeStatus(ctx, node.Name); err != nil && !errors.Is(err, types.ErrInvaildCount) { + if strings.HasPrefix(node.Endpoint, fakeengine.PrefixKey) { + node.Available = true + } else if _, err := r.GetNodeStatus(ctx, node.Name); err != nil && !errors.Is(err, types.ErrInvaildCount) { logger.Errorf(ctx, err, "failed to get node status of %+v", node.Name) } else { node.Available = err == nil