From 6cdc52107dbb66090e2bf1d468b8d0df09e5fd47 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Fri, 1 May 2026 10:12:32 -1000 Subject: [PATCH 1/2] add flag for --include-system-workers for ListWorker API --- internal/temporalcli/commands.gen.go | 10 ++++++---- internal/temporalcli/commands.worker.go | 7 ++++--- internal/temporalcli/commands.yaml | 3 +++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/internal/temporalcli/commands.gen.go b/internal/temporalcli/commands.gen.go index 08a68010e..ce365e161 100644 --- a/internal/temporalcli/commands.gen.go +++ b/internal/temporalcli/commands.gen.go @@ -3616,10 +3616,11 @@ func NewTemporalWorkerDescribeCommand(cctx *CommandContext, parent *TemporalWork } type TemporalWorkerListCommand struct { - Parent *TemporalWorkerCommand - Command cobra.Command - Query string - Limit int + Parent *TemporalWorkerCommand + Command cobra.Command + Query string + Limit int + IncludeSystemWorkers bool } func NewTemporalWorkerListCommand(cctx *CommandContext, parent *TemporalWorkerCommand) *TemporalWorkerListCommand { @@ -3636,6 +3637,7 @@ func NewTemporalWorkerListCommand(cctx *CommandContext, parent *TemporalWorkerCo s.Command.Args = cobra.NoArgs s.Command.Flags().StringVarP(&s.Query, "query", "q", "", "Content for an SQL-like `QUERY` List Filter.") s.Command.Flags().IntVar(&s.Limit, "limit", 0, "Maximum number of workers to display.") + s.Command.Flags().BoolVar(&s.IncludeSystemWorkers, "include-system-workers", false, "Include system workers that are created implicitly by the server. By default, system workers are excluded.") s.Command.Run = func(c *cobra.Command, args []string) { if err := s.run(cctx, args); err != nil { cctx.Options.Fail(err) diff --git a/internal/temporalcli/commands.worker.go b/internal/temporalcli/commands.worker.go index 2b8a74b7e..ce737da11 100644 --- a/internal/temporalcli/commands.worker.go +++ b/internal/temporalcli/commands.worker.go @@ -138,9 +138,10 @@ func (c *TemporalWorkerListCommand) run(cctx *CommandContext, args []string) err for { req := &workflowservice.ListWorkersRequest{ - Namespace: c.Parent.Namespace, - NextPageToken: token, - Query: c.Query, + Namespace: c.Parent.Namespace, + NextPageToken: token, + Query: c.Query, + IncludeSystemWorkers: c.IncludeSystemWorkers, } resp, err := svc.ListWorkers(cctx, req) diff --git a/internal/temporalcli/commands.yaml b/internal/temporalcli/commands.yaml index 32af0d955..f200dc305 100644 --- a/internal/temporalcli/commands.yaml +++ b/internal/temporalcli/commands.yaml @@ -1461,6 +1461,9 @@ commands: - name: limit type: int description: Maximum number of workers to display. + - name: include-system-workers + type: bool + description: Include system workers that are created implicitly by the server. By default, system workers are excluded. - name: temporal worker describe summary: Returns information about a specific worker (EXPERIMENTAL) From 5d30bff3955dbad1e476445a9b2f261af2b73b14 Mon Sep 17 00:00:00 2001 From: Andrew Yuan Date: Mon, 13 Jul 2026 09:48:40 -0400 Subject: [PATCH 2/2] add test --- internal/temporalcli/commands.worker_test.go | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/internal/temporalcli/commands.worker_test.go b/internal/temporalcli/commands.worker_test.go index 65505186f..3c52eb272 100644 --- a/internal/temporalcli/commands.worker_test.go +++ b/internal/temporalcli/commands.worker_test.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "sync" "time" "github.com/google/uuid" @@ -12,6 +13,7 @@ import ( enumspb "go.temporal.io/api/enums/v1" workerpb "go.temporal.io/api/worker/v1" "go.temporal.io/api/workflowservice/v1" + "google.golang.org/grpc" "google.golang.org/protobuf/types/known/durationpb" "google.golang.org/protobuf/types/known/timestamppb" ) @@ -62,6 +64,40 @@ func (s *SharedServerSuite) TestWorkerHeartbeat_List() { s.ContainsOnSameLine(res.Stdout.String(), heartbeat.WorkerInstanceKey, heartbeat.TaskQueue, heartbeat.WorkerIdentity) } +func (s *SharedServerSuite) TestWorkerHeartbeat_List_IncludeSystemWorkers() { + var lastRequestLock sync.Mutex + var listWorkersRequest *workflowservice.ListWorkersRequest + s.CommandHarness.Options.AdditionalClientGRPCDialOptions = append( + s.CommandHarness.Options.AdditionalClientGRPCDialOptions, + grpc.WithChainUnaryInterceptor(func( + ctx context.Context, + method string, req, reply any, + cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption, + ) error { + if r, ok := req.(*workflowservice.ListWorkersRequest); ok { + lastRequestLock.Lock() + listWorkersRequest = r + lastRequestLock.Unlock() + return nil + } + return invoker(ctx, method, req, reply, cc, opts...) + }), + ) + + res := s.Execute( + "worker", "list", + "--address", s.Address(), + "--include-system-workers", + ) + s.NoError(res.Err) + + lastRequestLock.Lock() + req := listWorkersRequest + lastRequestLock.Unlock() + s.NotNil(req) + s.True(req.GetIncludeSystemWorkers()) +} + func (s *SharedServerSuite) TestWorkerHeartbeat_Describe() { heartbeat, err := s.recordWorkerHeartbeat() s.NoError(err)