Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New GetSystemInfo RPC #2297

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions client/frontend/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,20 @@ func (c *clientImpl) GetClusterInfo(
return client.GetClusterInfo(ctx, request, opts...)
}

func (c *clientImpl) GetSystemInfo(
ctx context.Context,
request *workflowservice.GetSystemInfoRequest,
opts ...grpc.CallOption,
) (*workflowservice.GetSystemInfoResponse, error) {
client, err := c.getRandomClient()
if err != nil {
return nil, err
}
ctx, cancel := c.createContext(ctx)
defer cancel()
return client.GetSystemInfo(ctx, request, opts...)
}

func (c *clientImpl) ListTaskQueuePartitions(
ctx context.Context,
request *workflowservice.ListTaskQueuePartitionsRequest,
Expand Down
17 changes: 17 additions & 0 deletions client/frontend/metricClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,23 @@ func (c *metricClient) GetClusterInfo(
return resp, err
}

func (c *metricClient) GetSystemInfo(
ctx context.Context,
request *workflowservice.GetSystemInfoRequest,
opts ...grpc.CallOption,
) (*workflowservice.GetSystemInfoResponse, error) {

c.metricsClient.IncCounter(metrics.FrontendClientGetSystemInfoScope, metrics.ClientRequests)
sw := c.metricsClient.StartTimer(metrics.FrontendClientGetSystemInfoScope, metrics.ClientLatency)
resp, err := c.client.GetSystemInfo(ctx, request, opts...)
sw.Stop()

if err != nil {
c.metricsClient.IncCounter(metrics.FrontendClientGetSystemInfoScope, metrics.ClientFailures)
}
return resp, err
}

func (c *metricClient) ListTaskQueuePartitions(
ctx context.Context,
request *workflowservice.ListTaskQueuePartitionsRequest,
Expand Down
15 changes: 15 additions & 0 deletions client/frontend/retryableClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,21 @@ func (c *retryableClient) GetClusterInfo(
return resp, err
}

func (c *retryableClient) GetSystemInfo(
ctx context.Context,
request *workflowservice.GetSystemInfoRequest,
opts ...grpc.CallOption,
) (*workflowservice.GetSystemInfoResponse, error) {
var resp *workflowservice.GetSystemInfoResponse
op := func() error {
var err error
resp, err = c.client.GetSystemInfo(ctx, request, opts...)
return err
}
err := backoff.Retry(op, c.policy, c.isRetryable)
return resp, err
}

func (c *retryableClient) ListTaskQueuePartitions(
ctx context.Context,
request *workflowservice.ListTaskQueuePartitionsRequest,
Expand Down
1 change: 1 addition & 0 deletions common/authorization/frontend_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var readOnlyNamespaceAPI = map[string]struct{}{
"QueryWorkflow": {},
"DescribeWorkflowExecution": {},
"DescribeTaskQueue": {},
"GetSystemInfo": {},
"ListTaskQueuePartitions": {},
}

Expand Down
6 changes: 6 additions & 0 deletions common/metrics/defs.go
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,8 @@ const (
FrontendClientReapplyEventsScope
// FrontendClientGetClusterInfoScope tracks RPC calls to frontend
FrontendClientGetClusterInfoScope
// FrontendClientGetSystemInfoScope tracks RPC calls to frontend
FrontendClientGetSystemInfoScope
// FrontendClientListTaskQueuePartitionsScope tracks RPC calls to frontend service
FrontendClientListTaskQueuePartitionsScope
// AdminClientAddSearchAttributesScope tracks RPC calls to admin service
Expand Down Expand Up @@ -867,6 +869,8 @@ const (
FrontendGetSearchAttributesScope
// FrontendGetClusterInfoScope is the metric scope for frontend.GetClusterInfo
FrontendGetClusterInfoScope
// FrontendGetSystemInfoScope is the metric scope for frontend.GetSystemInfo
FrontendGetSystemInfoScope

// VersionCheckScope is scope used by version checker
VersionCheckScope
Expand Down Expand Up @@ -1368,6 +1372,7 @@ var ScopeDefs = map[ServiceIdx]map[int]scopeDefinition{
FrontendClientGetDLQReplicationTasksScope: {operation: "FrontendClientGetDLQReplicationTasksScope", tags: map[string]string{ServiceRoleTagName: FrontendRoleTagValue}},
FrontendClientReapplyEventsScope: {operation: "FrontendClientReapplyEventsScope", tags: map[string]string{ServiceRoleTagName: FrontendRoleTagValue}},
FrontendClientGetClusterInfoScope: {operation: "FrontendClientGetClusterInfoScope", tags: map[string]string{ServiceRoleTagName: FrontendRoleTagValue}},
FrontendClientGetSystemInfoScope: {operation: "FrontendClientGetSystemInfoScope", tags: map[string]string{ServiceRoleTagName: FrontendRoleTagValue}},
FrontendClientListTaskQueuePartitionsScope: {operation: "FrontendClientListTaskQueuePartitions", tags: map[string]string{ServiceRoleTagName: FrontendRoleTagValue}},
AdminClientAddSearchAttributesScope: {operation: "AdminClientAddSearchAttributes", tags: map[string]string{ServiceRoleTagName: AdminRoleTagValue}},
AdminClientRemoveSearchAttributesScope: {operation: "AdminClientRemoveSearchAttributes", tags: map[string]string{ServiceRoleTagName: AdminRoleTagValue}},
Expand Down Expand Up @@ -1535,6 +1540,7 @@ var ScopeDefs = map[ServiceIdx]map[int]scopeDefinition{
FrontendResetStickyTaskQueueScope: {operation: "ResetStickyTaskQueue"},
FrontendGetSearchAttributesScope: {operation: "GetSearchAttributes"},
FrontendGetClusterInfoScope: {operation: "GetClusterInfo"},
FrontendGetSystemInfoScope: {operation: "GetSystemInfo"},
VersionCheckScope: {operation: "VersionCheck"},
AuthorizationScope: {operation: "Authorization"},
},
Expand Down
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,12 @@ require (
go.opentelemetry.io/otel/trace v1.1.0 // indirect
go.uber.org/dig v1.13.0 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 // indirect
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 // indirect
golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c // indirect
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1 // indirect
google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12 // indirect
google.golang.org/protobuf v1.27.1 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
)
Expand All @@ -126,3 +126,5 @@ require (
// at that tag it no longer provides github.com/cactus/go-statsd-client/statsd
// thereby removing the import.
replace github.com/cactus/go-statsd-client => github.com/cactus/go-statsd-client v3.2.1+incompatible

replace go.temporal.io/api => ../api-go
cretz marked this conversation as resolved.
Show resolved Hide resolved
17 changes: 6 additions & 11 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -468,9 +468,6 @@ go.opentelemetry.io/otel/trace v1.0.1/go.mod h1:5g4i4fKLaX2BQpSBsxw8YYcgKpMMSW3x
go.opentelemetry.io/otel/trace v1.1.0 h1:N25T9qCL0+7IpOT8RrRy0WYlL7y6U0WiUJzXcVdXY/o=
go.opentelemetry.io/otel/trace v1.1.0/go.mod h1:i47XtdcBQiktu5IsrPqOHe8w+sBmnLwwHt8wiUsWGTI=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
go.temporal.io/api v1.5.0/go.mod h1:BqKxEJJYdxb5dqf0ODfzfMxh8UEQ5L3zKS51FiIYYkA=
go.temporal.io/api v1.6.1-0.20211123053254-cae1d6470032 h1:NWqyrKZjNtZMWaisvqswD+wZ+cjACm42Z12c1Ns0978=
go.temporal.io/api v1.6.1-0.20211123053254-cae1d6470032/go.mod h1:Ip5fOBxBedzcDrqxa2RBbMVcUFkKUgUIhrrhokF8ocg=
go.temporal.io/sdk v1.11.0 h1:KMulQdR67ZL8M30m60LQVfGL0bUNd2TgjHplM/RUk5M=
go.temporal.io/sdk v1.11.0/go.mod h1:YPiw910FVnuF0/j4qHgqxGEB3kNCOD7ZQY3fOmZltnw=
go.temporal.io/version v0.0.0-20201015012359-4d3bb966d193 h1:jhIqHkAE74DnEXipymFTzmTxyboMYmv6iVkkCFC1pas=
Expand Down Expand Up @@ -592,9 +589,8 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b
golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210913180222-943fd674d43e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4 h1:DZshvxDdVoeKIbudAdFEKi+f70l51luSy/7b76ibTY0=
golang.org/x/net v0.0.0-20211118161319-6a13c67c3ce4/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c h1:WtYZ93XtWSO5KlOMgPZu7hXY9WhMZpprvlm5VwvAl8c=
golang.org/x/net v0.0.0-20211201190559-0a0e4e1bb54c/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand Down Expand Up @@ -682,12 +678,11 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210910150752-751e447fb3d0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1 h1:kwrAHlwJ0DUBZwQ238v+Uod/3eZ8B2K5rYsUHBQvzmI=
golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881 h1:TyHqChC80pFkXWraUUf6RuB5IqFdQieMLwwCJokV2pc=
golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down Expand Up @@ -878,8 +873,8 @@ google.golang.org/genproto v0.0.0-20210917145530-b395a37504d4/go.mod h1:eFjDcFEc
google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20211008145708-270636b82663/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20211016002631-37fc39342514/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1 h1:b9mVrqYfq3P4bCdaLg1qtBnPzUYgglsIdjZkL/fQVOE=
google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12 h1:DN5b3HU13J4sMd/QjDx34U6afpaexKTDdop+26pdjdk=
google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc=
google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.12.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
Expand Down
1 change: 1 addition & 0 deletions service/frontend/configs/quotas.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ var (

OtherAPIToPriority = map[string]int{
"GetClusterInfo": 0,
"GetSystemInfo": 0,
"GetSearchAttributes": 0,

"RegisterNamespace": 0,
Expand Down
1 change: 1 addition & 0 deletions service/frontend/configs/quotas_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ func (s *quotasSuite) TestVisibilityAPIs() {
func (s *quotasSuite) TestOtherAPIs() {
apis := map[string]struct{}{
"GetClusterInfo": {},
"GetSystemInfo": {},
"GetSearchAttributes": {},

"RegisterNamespace": {},
Expand Down
8 changes: 8 additions & 0 deletions service/frontend/dcRedirectionHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -1189,6 +1189,14 @@ func (handler *DCRedirectionHandlerImpl) GetClusterInfo(
return handler.frontendHandler.GetClusterInfo(ctx, request)
}

// GetSystemInfo API call
func (handler *DCRedirectionHandlerImpl) GetSystemInfo(
ctx context.Context,
request *workflowservice.GetSystemInfoRequest,
) (*workflowservice.GetSystemInfoResponse, error) {
return handler.frontendHandler.GetSystemInfo(ctx, request)
}

func (handler *DCRedirectionHandlerImpl) beforeCall(
scope int,
) (metrics.Scope, time.Time) {
Expand Down
15 changes: 15 additions & 0 deletions service/frontend/interface_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions service/frontend/workflowHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -2778,6 +2778,45 @@ func (wh *WorkflowHandler) GetClusterInfo(_ context.Context, _ *workflowservice.
}, nil
}

// GetSystemInfo returns information about the Temporal system.
func (wh *WorkflowHandler) GetSystemInfo(ctx context.Context, request *workflowservice.GetSystemInfoRequest) (_ *workflowservice.GetSystemInfoResponse, retError error) {
defer log.CapturePanic(wh.logger, &retError)

if wh.isStopped() {
return nil, errShuttingDown
}

if err := wh.versionChecker.ClientSupported(ctx, wh.config.EnableClientVersionCheck()); err != nil {
return nil, err
}

if request == nil {
return nil, errRequestNotSet
}

_, err := wh.namespaceRegistry.GetNamespaceID(namespace.Name(request.GetNamespace()))
if err != nil {
return nil, err
}

metadata, err := wh.clusterMetadataManager.GetCurrentClusterMetadata()
if err != nil {
return nil, err
}

return &workflowservice.GetSystemInfoResponse{
ServerVersion: headers.ServerVersion,
VersionInfo: metadata.VersionInfo,
// Capabilities should be added as needed. In many cases, capabilities are
// hardcoded boolean true values since older servers will respond with a
// form of this message without the field which is implied false.
Capabilities: &workflowservice.GetSystemInfoResponse_Capabilities{
SignalAndQueryHeader: true,
InternalErrorDifferentiation: true,
},
}, nil
}

// ListTaskQueuePartitions returns all the partition and host for a task queue.
func (wh *WorkflowHandler) ListTaskQueuePartitions(ctx context.Context, request *workflowservice.ListTaskQueuePartitionsRequest) (_ *workflowservice.ListTaskQueuePartitionsResponse, retError error) {
defer log.CapturePanic(wh.logger, &retError)
Expand Down
22 changes: 22 additions & 0 deletions service/frontend/workflowHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
replicationpb "go.temporal.io/api/replication/v1"
"go.temporal.io/api/serviceerror"
taskqueuepb "go.temporal.io/api/taskqueue/v1"
"go.temporal.io/api/version/v1"
"go.temporal.io/api/workflowservice/v1"

enumsspb "go.temporal.io/server/api/enums/v1"
Expand Down Expand Up @@ -1655,6 +1656,27 @@ func (s *workflowHandlerSuite) TestVerifyHistoryIsComplete() {
}
}

func (s *workflowHandlerSuite) TestGetSystemInfo() {
config := s.newConfig()
config.EnableReadVisibilityFromES = dc.GetBoolPropertyFnFilteredByNamespace(true)

wh := s.getWorkflowHandler(config)

s.mockNamespaceCache.EXPECT().GetNamespaceID(gomock.Any()).Return(s.testNamespaceID, nil).AnyTimes()
var clusterMetadataResp persistence.GetClusterMetadataResponse
clusterMetadataResp.VersionInfo = &version.VersionInfo{Current: &version.ReleaseInfo{Version: "1.2.3"}}
s.mockResource.ClusterMetadataMgr.EXPECT().GetCurrentClusterMetadata().Return(&clusterMetadataResp, nil).AnyTimes()

resp, err := wh.GetSystemInfo(context.Background(), &workflowservice.GetSystemInfoRequest{
Namespace: s.testNamespace.String(),
})
s.NoError(err)
s.Equal(headers.ServerVersion, resp.ServerVersion)
s.Equal("1.2.3", resp.VersionInfo.Current.Version)
s.True(resp.Capabilities.SignalAndQueryHeader)
s.True(resp.Capabilities.InternalErrorDifferentiation)
}

func (s *workflowHandlerSuite) newConfig() *Config {
return NewConfig(dc.NewCollection(dc.NewNoopClient(), s.mockResource.GetLogger()), numHistoryShards, "", false)
}
Expand Down