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

use UnsetVersioningOverride field in ApplyWorkflowExecutionOptionsUpdatedEvent #7091

Merged
merged 6 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ require (
go.opentelemetry.io/otel/sdk v1.31.0
go.opentelemetry.io/otel/sdk/metric v1.31.0
go.opentelemetry.io/otel/trace v1.31.0
go.temporal.io/api v1.43.2-0.20250114194029-61f369a5f511
go.temporal.io/api v1.43.2-0.20250117235623-3d833601aeda
go.temporal.io/sdk v1.31.0
go.temporal.io/version v0.3.0
go.uber.org/automaxprocs v1.5.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ 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.2-0.20250114194029-61f369a5f511 h1:4YhvSVBPmEkNFE5wupUSXUx0+HotlAYjXyWqWfUCgqY=
go.temporal.io/api v1.43.2-0.20250114194029-61f369a5f511/go.mod h1:1WwYUMo6lao8yl0371xWUm13paHExN5ATYT/B7QtFis=
go.temporal.io/api v1.43.2-0.20250117235623-3d833601aeda h1:GYyPlo7nmDXW21cukrVsRCf/oe+2qVgFXuGLHiXD3Rg=
go.temporal.io/api v1.43.2-0.20250117235623-3d833601aeda/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/version v0.3.0 h1:dMrei9l9NyHt8nG6EB8vAwDLLTwx2SvRyucCSumAiig=
Expand Down
8 changes: 6 additions & 2 deletions service/history/api/updateworkflowoptions/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,11 @@ func Invoke(
}, nil
}

_, err = mutableState.AddWorkflowExecutionOptionsUpdatedEvent(mergedOpts.GetVersioningOverride())
unsetOverride := false
if mergedOpts.GetVersioningOverride() == nil {
unsetOverride = true
}
_, err = mutableState.AddWorkflowExecutionOptionsUpdatedEvent(mergedOpts.GetVersioningOverride(), unsetOverride)
if err != nil {
return nil, err
}
Expand All @@ -122,7 +126,7 @@ func Invoke(
func getOptionsFromMutableState(ms workflow.MutableState) *workflowpb.WorkflowExecutionOptions {
opts := &workflowpb.WorkflowExecutionOptions{}
if versioningInfo := ms.GetExecutionInfo().GetVersioningInfo(); versioningInfo != nil {
opts.VersioningOverride = versioningInfo.GetVersioningOverride()
opts.VersioningOverride = proto.Clone(versioningInfo.GetVersioningOverride()).(*workflowpb.VersioningOverride)
}
return opts
}
Expand Down
4 changes: 3 additions & 1 deletion service/history/historybuilder/event_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -395,11 +395,13 @@ func (b *EventFactory) CreateWorkflowExecutionTerminatedEvent(

func (b *EventFactory) CreateWorkflowExecutionOptionsUpdatedEvent(
versioningOverride *workflowpb.VersioningOverride,
unsetVersioningOverride bool,
) *historypb.HistoryEvent {
event := b.createHistoryEvent(enumspb.EVENT_TYPE_WORKFLOW_EXECUTION_OPTIONS_UPDATED, b.timeSource.Now())
event.Attributes = &historypb.HistoryEvent_WorkflowExecutionOptionsUpdatedEventAttributes{
WorkflowExecutionOptionsUpdatedEventAttributes: &historypb.WorkflowExecutionOptionsUpdatedEventAttributes{
VersioningOverride: versioningOverride,
VersioningOverride: versioningOverride,
UnsetVersioningOverride: unsetVersioningOverride,
},
}
event.WorkerMayIgnore = true
Expand Down
3 changes: 2 additions & 1 deletion service/history/historybuilder/history_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,9 @@ func (b *HistoryBuilder) AddWorkflowExecutionTerminatedEvent(

func (b *HistoryBuilder) AddWorkflowExecutionOptionsUpdatedEvent(
versioningOverride *workflowpb.VersioningOverride,
unsetVersioningOverride bool,
) *historypb.HistoryEvent {
event := b.EventFactory.CreateWorkflowExecutionOptionsUpdatedEvent(versioningOverride)
event := b.EventFactory.CreateWorkflowExecutionOptionsUpdatedEvent(versioningOverride, unsetVersioningOverride)
event, _ = b.EventStore.add(event)
return event
}
Expand Down
2 changes: 1 addition & 1 deletion service/history/workflow/mutable_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ type (
AddWorkflowExecutionStartedEvent(*commonpb.WorkflowExecution, *historyservice.StartWorkflowExecutionRequest) (*historypb.HistoryEvent, error)
AddWorkflowExecutionStartedEventWithOptions(*commonpb.WorkflowExecution, *historyservice.StartWorkflowExecutionRequest, *workflowpb.ResetPoints, string, string) (*historypb.HistoryEvent, error)
AddWorkflowExecutionTerminatedEvent(firstEventID int64, reason string, details *commonpb.Payloads, identity string, deleteAfterTerminate bool, links []*commonpb.Link) (*historypb.HistoryEvent, error)
AddWorkflowExecutionOptionsUpdatedEvent(versioningOverride *workflowpb.VersioningOverride) (*historypb.HistoryEvent, error)
AddWorkflowExecutionOptionsUpdatedEvent(versioningOverride *workflowpb.VersioningOverride, unsetVersioningOverride bool) (*historypb.HistoryEvent, error)
AddWorkflowExecutionUpdateAcceptedEvent(protocolInstanceID string, acceptedRequestMessageId string, acceptedRequestSequencingEventId int64, acceptedRequest *updatepb.Request) (*historypb.HistoryEvent, error)
AddWorkflowExecutionUpdateCompletedEvent(acceptedEventID int64, updResp *updatepb.Response) (*historypb.HistoryEvent, error)
RejectWorkflowExecutionUpdate(protocolInstanceID string, updRejection *updatepb.Rejection) error
Expand Down
12 changes: 10 additions & 2 deletions service/history/workflow/mutable_state_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4396,19 +4396,27 @@ func (ms *MutableStateImpl) RejectWorkflowExecutionUpdate(_ string, _ *updatepb.

func (ms *MutableStateImpl) AddWorkflowExecutionOptionsUpdatedEvent(
versioningOverride *workflowpb.VersioningOverride,
unsetVersioningOverride bool,
) (*historypb.HistoryEvent, error) {
if err := ms.checkMutability(tag.WorkflowActionWorkflowOptionsUpdated); err != nil {
return nil, err
}
event := ms.hBuilder.AddWorkflowExecutionOptionsUpdatedEvent(versioningOverride)
event := ms.hBuilder.AddWorkflowExecutionOptionsUpdatedEvent(versioningOverride, unsetVersioningOverride)
if err := ms.ApplyWorkflowExecutionOptionsUpdatedEvent(event); err != nil {
return nil, err
}
return event, nil
}

func (ms *MutableStateImpl) ApplyWorkflowExecutionOptionsUpdatedEvent(event *historypb.HistoryEvent) error {
override := event.GetWorkflowExecutionOptionsUpdatedEventAttributes().GetVersioningOverride()
attributes := event.GetWorkflowExecutionOptionsUpdatedEventAttributes()
override := attributes.GetVersioningOverride()
if attributes.GetUnsetVersioningOverride() {
override = nil
} else if override == nil {
return nil
}

previousEffectiveDeployment := ms.GetEffectiveDeployment()
previousEffectiveVersioningBehavior := ms.GetEffectiveVersioningBehavior()
if ms.GetExecutionInfo().GetVersioningInfo() == nil {
Expand Down
8 changes: 4 additions & 4 deletions service/history/workflow/mutable_state_mock.go

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