-
Notifications
You must be signed in to change notification settings - Fork 890
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 new versioning fields #7119
Changes from all commits
6ff6bbd
a108af0
03db39f
16fc81c
1a201c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3159,7 +3159,7 @@ func (ms *MutableStateImpl) AddActivityTaskStartedEvent( | |
} | ||
} | ||
|
||
ai.LastStartedDeployment = deployment | ||
ai.LastDeploymentVersion = worker_versioning.DeploymentVersionFromDeployment(deployment) | ||
|
||
if !ai.HasRetryPolicy { | ||
event := ms.hBuilder.AddActivityTaskStartedEvent( | ||
|
@@ -4411,10 +4411,20 @@ func (ms *MutableStateImpl) ApplyWorkflowExecutionOptionsUpdatedEvent(event *his | |
override := event.GetWorkflowExecutionOptionsUpdatedEventAttributes().GetVersioningOverride() | ||
previousEffectiveDeployment := ms.GetEffectiveDeployment() | ||
previousEffectiveVersioningBehavior := ms.GetEffectiveVersioningBehavior() | ||
if ms.GetExecutionInfo().GetVersioningInfo() == nil { | ||
ms.GetExecutionInfo().VersioningInfo = &workflowpb.WorkflowExecutionVersioningInfo{} | ||
if override != nil { | ||
if ms.GetExecutionInfo().GetVersioningInfo() == nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we wanna set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, the idea was if override is nil it means we have an override already and want to unset it, hence ms.GetExecutionInfo().VersioningInfo has already a value. But I don't think it's wise to make that assumption. I improved the else block in line 4423. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice, this looks much better - thanks for addressing |
||
ms.GetExecutionInfo().VersioningInfo = &workflowpb.WorkflowExecutionVersioningInfo{} | ||
} | ||
ms.GetExecutionInfo().VersioningInfo.VersioningOverride = &workflowpb.VersioningOverride{ | ||
Behavior: override.GetBehavior(), | ||
// We read from both old and new fields but write in the new fields only. | ||
//nolint:staticcheck // SA1019 deprecated Deployment will clean up later | ||
PinnedVersion: worker_versioning.DeploymentVersionFromDeployment(worker_versioning.DeploymentOrVersion(override.GetDeployment(), override.GetPinnedVersion())), | ||
} | ||
} else if ms.GetExecutionInfo().GetVersioningInfo() != nil { | ||
// TODO (shahab): this behavior has changed in main branch. Update it when merging to main. | ||
ms.GetExecutionInfo().VersioningInfo.VersioningOverride = nil | ||
} | ||
ms.GetExecutionInfo().VersioningInfo.VersioningOverride = override | ||
|
||
if !proto.Equal(ms.GetEffectiveDeployment(), previousEffectiveDeployment) || | ||
ms.GetEffectiveVersioningBehavior() != previousEffectiveVersioningBehavior { | ||
|
@@ -4442,6 +4452,7 @@ func (ms *MutableStateImpl) ApplyWorkflowExecutionOptionsUpdatedEvent(event *his | |
// and it will start the same transition in the workflow. So removing the transition would not make a difference | ||
// and would in fact add some extra work for the server. | ||
ms.executionInfo.GetVersioningInfo().DeploymentTransition = nil | ||
ms.executionInfo.GetVersioningInfo().VersionTransition = nil | ||
|
||
// If effective deployment or behavior change, we need to reschedule any pending tasks, because History will reject | ||
// the task's start request if the task is being started by a poller that is not from the workflow's effective | ||
|
@@ -7312,7 +7323,7 @@ func (ms *MutableStateImpl) initVersionedTransitionInDB() { | |
} | ||
|
||
// GetEffectiveDeployment returns the effective deployment in the following order: | ||
// 1. DeploymentTransition.Deployment: this is returned when the wf is transitioning to a | ||
// 1. DeploymentVersionTransition.Deployment: this is returned when the wf is transitioning to a | ||
// new deployment | ||
// 2. VersioningOverride.Deployment: this is returned when user has set a PINNED override | ||
// at wf start time, or later via UpdateWorkflowExecutionOptions. | ||
|
@@ -7327,6 +7338,12 @@ func (ms *MutableStateImpl) GetEffectiveDeployment() *deploymentpb.Deployment { | |
} | ||
|
||
func (ms *MutableStateImpl) GetDeploymentTransition() *workflowpb.DeploymentTransition { | ||
vi := ms.GetExecutionInfo().GetVersioningInfo() | ||
if t := vi.GetVersionTransition(); t != nil { | ||
return &workflowpb.DeploymentTransition{ | ||
Deployment: worker_versioning.DeploymentFromDeploymentVersion(t.GetDeploymentVersion()), | ||
} | ||
} | ||
return ms.GetExecutionInfo().GetVersioningInfo().GetDeploymentTransition() | ||
} | ||
|
||
|
@@ -7361,8 +7378,11 @@ func (ms *MutableStateImpl) StartDeploymentTransition(deployment *deploymentpb.D | |
ms.GetExecutionInfo().VersioningInfo = versioningInfo | ||
} | ||
|
||
versioningInfo.DeploymentTransition = &workflowpb.DeploymentTransition{ | ||
Deployment: deployment, | ||
// Only store transition in VersionTransition but read from both VersionTransition and DeploymentVersionTransition. | ||
//nolint:staticcheck // SA1019 deprecated DeploymentTransition will clean up later | ||
versioningInfo.DeploymentTransition = nil | ||
versioningInfo.VersionTransition = &workflowpb.DeploymentVersionTransition{ | ||
DeploymentVersion: worker_versioning.DeploymentVersionFromDeployment(deployment), | ||
} | ||
|
||
// Because deployment is changed, we clear sticky queue to make sure the next wf task does not | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can now use:
tv.DeploymentName()
andtv.DeploymentVersion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... I'm actually removing them in https://github.com/temporalio/temporal/pull/7126/files#diff-969e474fa5d1098f4d0735292efd98defd6af7cc7cf4506613dc5e07991f4c46R263. The idea is we just use old BuildID and DeploymentSeries testvars in all places. Until we refactor the code and get rid of old names altogether. The problem with having two testvars (say DeploymentSeries and DeploymentName) is that test helper functions don't know to use which one and that defeats the purpose of testvars.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we not just write newer tests with the updated test-vars names and then when removing the old versioning names altogether, remove the old test-vars objects too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can do that, but that would require creating a clone of versioning_3_tests.go (which is not a bad idea, but not what I did, I just repurposed the tests to use new proto fields.)