diff --git a/go.mod b/go.mod index 35f9334bdb..1652fbd3c1 100644 --- a/go.mod +++ b/go.mod @@ -173,3 +173,5 @@ require ( modernc.org/mathutil v1.7.1 // indirect modernc.org/memory v1.11.0 // indirect ) + +replace go.temporal.io/api => github.com/temporalio/api-go v1.62.2-0.20260227174043-ceb60095c536 diff --git a/go.sum b/go.sum index 2cd1258aaf..14c7ebab5f 100644 --- a/go.sum +++ b/go.sum @@ -310,6 +310,8 @@ github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXl github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/temporalio/api-go v1.62.2-0.20260227174043-ceb60095c536 h1:iktVjeCCgbQDFBlnijGjTgAJleju0Pv9fZ9oXwwhUyw= +github.com/temporalio/api-go v1.62.2-0.20260227174043-ceb60095c536/go.mod h1:QbZqFsleQjNX6bmuUUba1vc5qSi2Fp5OkS6fh8hHMQI= github.com/temporalio/ringpop-go v0.0.0-20250130211428-b97329e994f7 h1:lEebX/hZss+TSH3EBwhztnBavJVj7pWGJOH8UgKHS0w= github.com/temporalio/ringpop-go v0.0.0-20250130211428-b97329e994f7/go.mod h1:RE+CHmY+kOZQk47AQaVzwrGmxpflnLgTd6EOK0853j4= github.com/temporalio/sqlparser v0.0.0-20231115171017-f4060bcfa6cb h1:YzHH/U/dN7vMP+glybzcXRTczTrgfdRisNTzAj7La04= @@ -375,8 +377,6 @@ go.opentelemetry.io/otel/trace v1.34.0 h1:+ouXS2V8Rd4hp4580a8q23bg0azF2nI8cqLYnC go.opentelemetry.io/otel/trace v1.34.0/go.mod h1:Svm7lSjQD7kG7KJ/MUHPVXSDGz2OX4h0M2jHBhmSfRE= go.opentelemetry.io/proto/otlp v1.5.0 h1:xJvq7gMzB31/d406fB8U5CBdyQGw4P399D1aQWU/3i4= go.opentelemetry.io/proto/otlp v1.5.0/go.mod h1:keN8WnHxOy8PG0rQZjJJ5A2ebUoafqWp0eVQ4yIXvJ4= -go.temporal.io/api v1.62.2 h1:jFhIzlqNyJsJZTiCRQmTIMv6OTQ5BZ57z8gbgLGMaoo= -go.temporal.io/api v1.62.2/go.mod h1:iaxoP/9OXMJcQkETTECfwYq4cw/bj4nwov8b3ZLVnXM= go.temporal.io/sdk v1.38.0 h1:4Bok5LEdED7YKpsSjIa3dDqram5VOq+ydBf4pyx0Wo4= go.temporal.io/sdk v1.38.0/go.mod h1:a+R2Ej28ObvHoILbHaxMyind7M6D+W0L7edt5UJF4SE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= diff --git a/service/frontend/workflow_handler.go b/service/frontend/workflow_handler.go index c6afbbcafa..b2e67149a8 100644 --- a/service/frontend/workflow_handler.go +++ b/service/frontend/workflow_handler.go @@ -6757,12 +6757,40 @@ func (wh *WorkflowHandler) ListWorkers( return nil, err } + workers := make([]*workerpb.WorkerListInfo, 0, len(resp.GetWorkersInfo())) + for _, info := range resp.GetWorkersInfo() { + workers = append(workers, workerHeartbeatToListInfo(info.GetWorkerHeartbeat())) + } + return &workflowservice.ListWorkersResponse{ WorkersInfo: resp.GetWorkersInfo(), + Workers: workers, NextPageToken: resp.GetNextPageToken(), }, nil } +func workerHeartbeatToListInfo(hb *workerpb.WorkerHeartbeat) *workerpb.WorkerListInfo { + if hb == nil { + return nil + } + hostInfo := hb.GetHostInfo() + return &workerpb.WorkerListInfo{ + WorkerInstanceKey: hb.GetWorkerInstanceKey(), + WorkerIdentity: hb.GetWorkerIdentity(), + TaskQueue: hb.GetTaskQueue(), + DeploymentVersion: hb.GetDeploymentVersion(), + SdkName: hb.GetSdkName(), + SdkVersion: hb.GetSdkVersion(), + Status: hb.GetStatus(), + StartTime: hb.GetStartTime(), + HostName: hostInfo.GetHostName(), + WorkerGroupingKey: hostInfo.GetWorkerGroupingKey(), + ProcessId: hostInfo.GetProcessId(), + Plugins: hb.GetPlugins(), + Drivers: hb.GetDrivers(), + } +} + func (wh *WorkflowHandler) UpdateTaskQueueConfig( ctx context.Context, request *workflowservice.UpdateTaskQueueConfigRequest, ) (*workflowservice.UpdateTaskQueueConfigResponse, error) { diff --git a/tests/worker_registry_test.go b/tests/worker_registry_test.go index 4427229951..d5959840db 100644 --- a/tests/worker_registry_test.go +++ b/tests/worker_registry_test.go @@ -154,10 +154,17 @@ func (s *WorkerRegistryTestSuite) TestWorkerRegistry_ListWorkers() { s.NotNil(resp) s.Len(resp.GetWorkersInfo(), 1) + // Verify deprecated WorkersInfo field (backward compatibility) workerHeartbeat := resp.GetWorkersInfo()[0].GetWorkerHeartbeat() s.Equal(worker1Key, workerHeartbeat.WorkerInstanceKey) s.Equal(sharedTaskQueue, workerHeartbeat.TaskQueue) s.Equal(int32(1), workerHeartbeat.TotalStickyCacheHit) + + // Verify new Workers field (WorkerListInfo) + s.Len(resp.GetWorkers(), 1) + workerListInfo := resp.GetWorkers()[0] + s.Equal(worker1Key, workerListInfo.GetWorkerInstanceKey()) + s.Equal(sharedTaskQueue, workerListInfo.GetTaskQueue()) } { resp, err := s.FrontendClient().ListWorkers(ctx, &workflowservice.ListWorkersRequest{ @@ -167,28 +174,40 @@ func (s *WorkerRegistryTestSuite) TestWorkerRegistry_ListWorkers() { s.NoError(err) s.NotNil(resp) + // Verify deprecated WorkersInfo field workers := resp.GetWorkersInfo() - // Collect workers by their instance key workersByKey := make(map[string]*workerpb.WorkerHeartbeat) for _, workerInfo := range workers { heartbeat := workerInfo.GetWorkerHeartbeat() workersByKey[heartbeat.WorkerInstanceKey] = heartbeat } - - // Verify we have exactly the workers we expect s.Len(workersByKey, 2) - // Verify worker1 worker1, exists := workersByKey[worker1Key] s.True(exists, "worker1 should exist") s.Equal(sharedTaskQueue, worker1.TaskQueue) s.Equal(int32(1), worker1.TotalStickyCacheHit) - // Verify worker2 worker2, exists := workersByKey[worker2Key] s.True(exists, "worker2 should exist") s.Equal(sharedTaskQueue, worker2.TaskQueue) s.Equal(int32(2), worker2.TotalStickyCacheHit) + + // Verify new Workers field (WorkerListInfo) + listInfos := resp.GetWorkers() + s.Len(listInfos, 2) + listInfoByKey := make(map[string]*workerpb.WorkerListInfo) + for _, info := range listInfos { + listInfoByKey[info.GetWorkerInstanceKey()] = info + } + + listInfo1, exists := listInfoByKey[worker1Key] + s.True(exists, "worker1 list info should exist") + s.Equal(sharedTaskQueue, listInfo1.GetTaskQueue()) + + listInfo2, exists := listInfoByKey[worker2Key] + s.True(exists, "worker2 list info should exist") + s.Equal(sharedTaskQueue, listInfo2.GetTaskQueue()) } { nonExistentWorkerKey := s.tv.WorkerIdentity() + "_nonexistent" @@ -198,7 +217,8 @@ func (s *WorkerRegistryTestSuite) TestWorkerRegistry_ListWorkers() { }) s.NoError(err) s.NotNil(resp) - s.Len(resp.GetWorkersInfo(), 0) + s.Empty(resp.GetWorkersInfo()) + s.Empty(resp.GetWorkers()) } }