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 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
13 changes: 11 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,12 @@ func Invoke(
func getOptionsFromMutableState(ms workflow.MutableState) *workflowpb.WorkflowExecutionOptions {
opts := &workflowpb.WorkflowExecutionOptions{}
if versioningInfo := ms.GetExecutionInfo().GetVersioningInfo(); versioningInfo != nil {
opts.VersioningOverride = versioningInfo.GetVersioningOverride()
if override := versioningInfo.GetVersioningOverride(); override != nil {
opts.VersioningOverride = &workflowpb.VersioningOverride{
Behavior: override.Behavior,
Deployment: override.Deployment,
}
}
carlydf marked this conversation as resolved.
Show resolved Hide resolved
}
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) 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,

Check failure on line 404 in service/history/historybuilder/event_factory.go

View workflow job for this annotation

GitHub Actions / golangci

unknown field UnsetVersioningOverride in struct literal of type "go.temporal.io/api/history/v1".WorkflowExecutionOptionsUpdatedEventAttributes (typecheck)

Check failure on line 404 in service/history/historybuilder/event_factory.go

View workflow job for this annotation

GitHub Actions / Pre-build for cache

unknown field UnsetVersioningOverride in struct literal of type "go.temporal.io/api/history/v1".WorkflowExecutionOptionsUpdatedEventAttributes
},
}
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
6 changes: 5 additions & 1 deletion service/history/workflow/mutable_state_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -4396,11 +4396,12 @@ 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
}
Expand All @@ -4409,6 +4410,9 @@ func (ms *MutableStateImpl) AddWorkflowExecutionOptionsUpdatedEvent(

func (ms *MutableStateImpl) ApplyWorkflowExecutionOptionsUpdatedEvent(event *historypb.HistoryEvent) error {
override := event.GetWorkflowExecutionOptionsUpdatedEventAttributes().GetVersioningOverride()
if event.GetWorkflowExecutionOptionsUpdatedEventAttributes().GetUnsetVersioningOverride() {
override = nil
}
carlydf marked this conversation as resolved.
Show resolved Hide resolved
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.

Loading