From 21f6dd46692985f01fe9f68eb6b4e2f8416a3275 Mon Sep 17 00:00:00 2001 From: Quanzheng Long Date: Tue, 5 Jun 2018 10:15:01 -0700 Subject: [PATCH] Fix bug in adiminCLI: convert domain name to donmainID using domainCache --- service/frontend/adminHandler.go | 15 ++++++++++++--- service/frontend/service.go | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/service/frontend/adminHandler.go b/service/frontend/adminHandler.go index fcdb186b191..26007ba15de 100644 --- a/service/frontend/adminHandler.go +++ b/service/frontend/adminHandler.go @@ -31,7 +31,9 @@ import ( gen "github.com/uber/cadence/.gen/go/shared" "github.com/uber/cadence/client/history" "github.com/uber/cadence/common" + "github.com/uber/cadence/common/cache" "github.com/uber/cadence/common/logging" + "github.com/uber/cadence/common/persistence" "github.com/uber/cadence/common/service" ) @@ -42,16 +44,18 @@ type ( AdminHandler struct { numberOfHistoryShards int service.Service - history history.Client + history history.Client + domainCache cache.DomainCache } ) // NewAdminHandler creates a thrift handler for the cadence admin service func NewAdminHandler( - sVice service.Service, numberOfHistoryShards int) *AdminHandler { + sVice service.Service, numberOfHistoryShards int, metadataMgr persistence.MetadataManager) *AdminHandler { handler := &AdminHandler{ numberOfHistoryShards: numberOfHistoryShards, Service: sVice, + domainCache: cache.NewDomainCache(metadataMgr, sVice.GetClusterMetadata(), sVice.GetLogger()), } return handler } @@ -92,11 +96,16 @@ func (adh *AdminHandler) DescribeWorkflowExecution(ctx context.Context, request return nil, adh.error(err) } + domainID, err := adh.domainCache.GetDomainID(request.GetDomain()) + historyAddr := historyHost.GetAddress() resp, err := adh.history.DescribeMutableState(ctx, &hist.DescribeMutableStateRequest{ - DomainUUID: request.Domain, + DomainUUID: &domainID, Execution: request.Execution, }) + if err != nil { + return &admin.DescribeWorkflowExecutionResponse{}, err + } return &admin.DescribeWorkflowExecutionResponse{ ShardId: common.StringPtr(shardIDForOutput), HistoryAddr: common.StringPtr(historyAddr), diff --git a/service/frontend/service.go b/service/frontend/service.go index fcb3d29890c..840c3360fc7 100644 --- a/service/frontend/service.go +++ b/service/frontend/service.go @@ -130,7 +130,7 @@ func (s *Service) Start() { wfHandler := NewWorkflowHandler(base, s.config, metadata, history, visibility, kafkaProducer) wfHandler.Start() - adminHandler := NewAdminHandler(base, p.CassandraConfig.NumHistoryShards) + adminHandler := NewAdminHandler(base, p.CassandraConfig.NumHistoryShards, metadata) adminHandler.Start() log.Infof("%v started", common.FrontendServiceName)