Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ require (
github.com/fatih/color v1.17.0
github.com/google/uuid v1.6.0
github.com/mattn/go-isatty v0.0.20
github.com/nexus-rpc/sdk-go v0.1.0
github.com/nexus-rpc/sdk-go v0.1.1
github.com/olekukonko/tablewriter v0.0.5
github.com/spf13/cobra v1.8.1
github.com/spf13/pflag v1.0.5
github.com/stretchr/testify v1.10.0
github.com/temporalio/ui-server/v2 v2.32.0
go.temporal.io/api v1.43.0
go.temporal.io/api v1.43.3-0.20250130180025-c83bb3e83097
go.temporal.io/sdk v1.31.0
go.temporal.io/server v1.26.2
go.temporal.io/server v1.27.0-127.0.0.20250131044850-9fe70b4bdc01
google.golang.org/grpc v1.67.1
google.golang.org/protobuf v1.35.1
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -102,7 +102,7 @@ require (
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/sony/gobreaker v1.0.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/temporalio/ringpop-go v0.0.0-20241119001152-e505ebd8f887 // indirect
github.com/temporalio/ringpop-go v0.0.0-20250130211428-b97329e994f7 // indirect
github.com/temporalio/sqlparser v0.0.0-20231115171017-f4060bcfa6cb // indirect
github.com/temporalio/tchannel-go v1.22.1-0.20240528171429-1db37fdea938 // indirect
github.com/twmb/murmur3 v1.1.8 // indirect
Expand Down
16 changes: 8 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/ncruces/go-strftime v0.1.9 h1:bY0MQC28UADQmHmaF5dgpLmImcShSi2kHU9XLdhx/f4=
github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJmn9CehxcKcls=
github.com/nexus-rpc/sdk-go v0.1.0 h1:PUL/0vEY1//WnqyEHT5ao4LBRQ6MeNUihmnNGn0xMWY=
github.com/nexus-rpc/sdk-go v0.1.0/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
github.com/nexus-rpc/sdk-go v0.1.1 h1:S63hhn4CpmwyoCUn8nVLfuKV+6sA/7hR57ohIQajDP0=
github.com/nexus-rpc/sdk-go v0.1.1/go.mod h1:TpfkM2Cw0Rlk9drGkoiSMpFqflKTiQLWUNyKJjF8mKQ=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
Expand Down Expand Up @@ -302,8 +302,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
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/ringpop-go v0.0.0-20241119001152-e505ebd8f887 h1:08Y1jDl4UKVu+TiQHIVKcW6TKQaHl15vBKkcZ094/SA=
github.com/temporalio/ringpop-go v0.0.0-20241119001152-e505ebd8f887/go.mod h1:RE+CHmY+kOZQk47AQaVzwrGmxpflnLgTd6EOK0853j4=
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=
github.com/temporalio/sqlparser v0.0.0-20231115171017-f4060bcfa6cb/go.mod h1:143qKdh3G45IgV9p+gbAwp3ikRDI8mxsijFiXDfuxsw=
github.com/temporalio/tchannel-go v1.22.1-0.20220818200552-1be8d8cffa5b/go.mod h1:c+V9Z/ZgkzAdyGvHrvC5AsXgN+M9Qwey04cBdKYzV7U=
Expand Down Expand Up @@ -357,12 +357,12 @@ go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HY
go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A=
go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0=
go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8=
go.temporal.io/api v1.43.0 h1:lBhq+u5qFJqGMXwWsmg/i8qn1UA/3LCwVc88l2xUMHg=
go.temporal.io/api v1.43.0/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
go.temporal.io/api v1.43.3-0.20250130180025-c83bb3e83097 h1:C5X7/ScMCL8g64b/h2KY5BS7xua6AdKmIU+gUqzemkU=
go.temporal.io/api v1.43.3-0.20250130180025-c83bb3e83097/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
go.temporal.io/sdk v1.31.0 h1:CLYiP0R5Sdj0gq8LyYKDDz4ccGOdJPR8wNGJU0JGwj8=
go.temporal.io/sdk v1.31.0/go.mod h1:8U8H7rF9u4Hyb4Ry9yiEls5716DHPNvVITPNkgWUwE8=
go.temporal.io/server v1.26.2 h1:vDW11lxslYPlGDbQklWi/tqbkVZ2ExtRO1jNjvZmUUI=
go.temporal.io/server v1.26.2/go.mod h1:tgY+4z/PuIdqs6ouV1bT90RWSWfEioWkzmrNrLYLUrk=
go.temporal.io/server v1.27.0-127.0.0.20250131044850-9fe70b4bdc01 h1:Taf5yj5gSUV5hPDVuVYFi4z6REUmIvK9A1dwOI0h3IM=
go.temporal.io/server v1.27.0-127.0.0.20250131044850-9fe70b4bdc01/go.mod h1:h6wn6UEKORDV84T0sbNzWjG4Jq9fMpxIlERrVjYIYCI=
go.temporal.io/version v0.3.0 h1:dMrei9l9NyHt8nG6EB8vAwDLLTwx2SvRyucCSumAiig=
go.temporal.io/version v0.3.0/go.mod h1:UA9S8/1LaKYae6TyD9NaPMJTZb911JcbqghI2CBSP78=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
Expand Down
110 changes: 61 additions & 49 deletions temporalcli/commands.activity.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"time"

"github.com/google/uuid"
"github.com/temporalio/cli/temporalcli/internal/printer"
activitypb "go.temporal.io/api/activity/v1"
"go.temporal.io/api/common/v1"
Expand Down Expand Up @@ -156,18 +155,18 @@ func (c *TemporalActivityUpdateOptionsCommand) run(cctx *CommandContext, args []
updatePath = append(updatePath, "retry_policy.maximum_attempts")
}

result, err := cl.WorkflowService().UpdateActivityOptionsById(cctx, &workflowservice.UpdateActivityOptionsByIdRequest{
Namespace: c.Parent.Namespace,
WorkflowId: c.WorkflowId,
RunId: c.RunId,
ActivityId: c.ActivityId,
result, err := cl.WorkflowService().UpdateActivityOptions(cctx, &workflowservice.UpdateActivityOptionsRequest{
Namespace: c.Parent.Namespace,
Execution: &common.WorkflowExecution{
WorkflowId: c.WorkflowId,
RunId: c.RunId,
},
Activity: &workflowservice.UpdateActivityOptionsRequest_Id{Id: c.ActivityId},
ActivityOptions: activityOptions,
UpdateMask: &fieldmaskpb.FieldMask{
Paths: updatePath,
},

Identity: c.Identity,
RequestId: uuid.NewString(),
Identity: c.Identity,
})
if err != nil {
return fmt.Errorf("unable to update Activity options: %w", err)
Expand Down Expand Up @@ -199,16 +198,26 @@ func (c *TemporalActivityPauseCommand) run(cctx *CommandContext, args []string)
}
defer cl.Close()

_, err = cl.WorkflowService().PauseActivityById(cctx, &workflowservice.PauseActivityByIdRequest{
Namespace: c.Parent.Namespace,
WorkflowId: c.WorkflowId,
RunId: c.RunId,
ActivityId: c.ActivityId,
Identity: c.Identity,
RequestId: uuid.NewString(),
})
request := &workflowservice.PauseActivityRequest{
Namespace: c.Parent.Namespace,
Execution: &common.WorkflowExecution{
WorkflowId: c.WorkflowId,
RunId: c.RunId,
},
Identity: c.Identity,
}

if c.ActivityType != "" {
request.Activity = &workflowservice.PauseActivityRequest_Type{Type: c.ActivityType}
} else if c.ActivityId != "" {
request.Activity = &workflowservice.PauseActivityRequest_Id{Id: c.ActivityId}
} else {
return fmt.Errorf("either Activity Type or Activity Id must be provided")
}

_, err = cl.WorkflowService().PauseActivity(cctx, request)
if err != nil {
return fmt.Errorf("unable to update Activity options: %w", err)
return fmt.Errorf("unable to pause Activity: %w", err)
}

return nil
Expand All @@ -221,32 +230,26 @@ func (c *TemporalActivityUnpauseCommand) run(cctx *CommandContext, args []string
}
defer cl.Close()

request := &workflowservice.UnpauseActivityByIdRequest{
Namespace: c.Parent.Namespace,
WorkflowId: c.WorkflowId,
RunId: c.RunId,
ActivityId: c.ActivityId,
Identity: c.Identity,
request := &workflowservice.UnpauseActivityRequest{
Namespace: c.Parent.Namespace,
Execution: &common.WorkflowExecution{
WorkflowId: c.WorkflowId,
RunId: c.RunId,
},
ResetAttempts: c.ResetAttempts,
ResetHeartbeat: c.ResetHeartbeats,
Identity: c.Identity,
}
if c.Reset {
request.Operation = &workflowservice.UnpauseActivityByIdRequest_Reset_{
Reset_: &workflowservice.UnpauseActivityByIdRequest_ResetOperation{
NoWait: c.NoWait,
ResetHeartbeat: c.ResetHeartbeats,
},
}

if c.ActivityType != "" {
request.Activity = &workflowservice.UnpauseActivityRequest_Type{Type: c.ActivityType}
} else if c.ActivityId != "" {
request.Activity = &workflowservice.UnpauseActivityRequest_Id{Id: c.ActivityId}
} else {
if c.ResetHeartbeats {
return fmt.Errorf("reset-heartbeats flag can only be used with reset flag")
}
request.Operation = &workflowservice.UnpauseActivityByIdRequest_Resume{
Resume: &workflowservice.UnpauseActivityByIdRequest_ResumeOperation{
NoWait: c.NoWait,
},
}
return fmt.Errorf("either Activity Type or Activity Id must be provided")
}

_, err = cl.WorkflowService().UnpauseActivityById(cctx, request)
_, err = cl.WorkflowService().UnpauseActivity(cctx, request)
if err != nil {
return fmt.Errorf("unable to uppause an Activity: %w", err)
}
Expand All @@ -261,28 +264,37 @@ func (c *TemporalActivityResetCommand) run(cctx *CommandContext, args []string)
}
defer cl.Close()

request := &workflowservice.ResetActivityByIdRequest{
Namespace: c.Parent.Namespace,
WorkflowId: c.WorkflowId,
RunId: c.RunId,
ActivityId: c.ActivityId,
request := &workflowservice.ResetActivityRequest{
Namespace: c.Parent.Namespace,
Execution: &common.WorkflowExecution{
WorkflowId: c.WorkflowId,
RunId: c.RunId,
},
Identity: c.Identity,
NoWait: c.NoWait,
KeepPaused: c.KeepPaused,
ResetHeartbeat: c.ResetHeartbeats,
}

resp, err := cl.WorkflowService().ResetActivityById(cctx, request)
if c.ActivityType != "" {
request.Activity = &workflowservice.ResetActivityRequest_Type{Type: c.ActivityType}
} else if c.ActivityId != "" {
request.Activity = &workflowservice.ResetActivityRequest_Id{Id: c.ActivityId}
} else {
return fmt.Errorf("either Activity Type or Activity Id must be provided")
}

resp, err := cl.WorkflowService().ResetActivity(cctx, request)
if err != nil {
return fmt.Errorf("unable to reset an Activity: %w", err)
}

resetResponse := struct {
NoWait bool `json:"noWait"`
KeepPaused bool `json:"keepPaused"`
ResetHeartbeats bool `json:"resetHeartbeats"`
ServerResponse bool `json:"-"`
}{
ServerResponse: resp != nil,
NoWait: c.NoWait,
KeepPaused: c.KeepPaused,
ResetHeartbeats: c.ResetHeartbeats,
}

Expand Down
43 changes: 35 additions & 8 deletions temporalcli/commands.activity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,30 +206,58 @@ func (s *SharedServerSuite) TestActivityPauseUnpause() {
"--run-id", run.GetRunID(),
"--identity", identity,
"--address", s.Address(),
"--reset",
"--reset-attempts",
)

s.NoError(res.Err)
}

func (s *SharedServerSuite) TestActivityUnPause_Failed() {
func (s *SharedServerSuite) TestActivityPauseUnpauseByType() {
run := s.waitActivityStarted()
wid := run.GetID()
aid := "dev-activity-id"
at := "DevActivity"
identity := "MyIdentity"

// should fail because --reset-heartbeat is provided, but --reset flag is missing
res := s.Execute(
"activity", "pause",
"--activity-type", at,
"--workflow-id", wid,
"--run-id", run.GetRunID(),
"--identity", identity,
"--address", s.Address(),
)
s.NoError(res.Err)

res = s.Execute(
"activity", "unpause",
"--activity-id", aid,
"--activity-type", at,
"--workflow-id", wid,
"--run-id", run.GetRunID(),
"--identity", identity,
"--address", s.Address(),
"--reset-heartbeats",
"--reset-attempts",
)

s.Error(res.Err)
s.NoError(res.Err)
}

func (s *SharedServerSuite) TestActivityCommandFailed_NoActivityTpeOrid() {
run := s.waitActivityStarted()
wid := run.GetID()
identity := "MyIdentity"

commands := []string{"pause", "unpause", "reset"}
for _, command := range commands {
// should fail because both activity-id and activity-type are not provided
res := s.Execute(
"activity", command,
"--workflow-id", wid,
"--run-id", run.GetRunID(),
"--identity", identity,
"--address", s.Address(),
)
s.Error(res.Err)
}
}

func (s *SharedServerSuite) TestActivityReset() {
Expand All @@ -253,7 +281,6 @@ func (s *SharedServerSuite) TestActivityReset() {
s.ContainsOnSameLine(out, "ServerResponse", "true")

// reset should fail because activity is not found

res = s.Execute(
"activity", "reset",
"--activity-id", "fake_id",
Expand Down
Loading