ListWorkerDeployments : Versioning-3.1#7173
Conversation
| // userData, _, err := c.partitionMgr.GetUserDataManager().GetUserData() | ||
| // if err != nil { | ||
| // return err | ||
| // } | ||
|
|
||
| // deploymentVersionData := userData.GetData().GetPerType()[int32(c.queue.TaskType())].GetDeploymentVersionData() | ||
| // if findDeploymentVersion(deploymentVersionData, workerDeployment.SeriesName, workerDeployment.BuildId) >= 0 { | ||
| // // already registered in user data, we can assume the workflow is running. | ||
| // // TODO: consider replication scenarios where user data is replicated before | ||
| // // the deployment workflow. | ||
| // return nil | ||
| // } |
There was a problem hiding this comment.
had forgotten to uncomment this and the next block of code - important since it basically serves as a de-dup mechanism for multiple polls coming in with the same worker-deployment information!
| request.PageSize = maxPageSize | ||
| } | ||
|
|
||
| resp, nextPageToken, err := wh.workerDeploymentClient.ListWorkerDeployments(ctx, namespaceEntry, int(request.PageSize), request.NextPageToken) |
There was a problem hiding this comment.
I don't think it's worth changing for all of these APIs, but personally I find it easier to write code / keep up with shifting parameters if the input to my helper function (in this case workerDeploymentClient.ListWorkerDeployments) is just the proto request object + namespaceEntry. Then all the necessary parameters are already present.
Up to you though and I think not worth changing now, just letting you know for the future that it's totally fine to pass the whole request object if that's easier for you.
There was a problem hiding this comment.
I think this was a design decision which was followed since the pre-release days and I didn't wanna alter it - fwiw, I agree with you - I shall keep things as is for now but not repeat the same thing in future
| // userData, _, err := c.partitionMgr.GetUserDataManager().GetUserData() | ||
| // if err != nil { | ||
| // return err | ||
| // } | ||
|
|
||
| // deploymentVersionData := userData.GetData().GetPerType()[int32(c.queue.TaskType())].GetDeploymentVersionData() | ||
| // if findDeploymentVersion(deploymentVersionData, workerDeployment.SeriesName, workerDeployment.BuildId) >= 0 { | ||
| // // already registered in user data, we can assume the workflow is running. | ||
| // // TODO: consider replication scenarios where user data is replicated before | ||
| // // the deployment workflow. | ||
| // return nil | ||
| // } |
| deploymentVersions := userData.GetData().GetPerType()[int32(c.queue.TaskType())].GetDeploymentData() | ||
| if findDeploymentVersion(deploymentVersions, worker_versioning.DeploymentVersionFromDeployment(workerDeployment)) >= 0 { | ||
| break |
There was a problem hiding this comment.
| deploymentVersions := userData.GetData().GetPerType()[int32(c.queue.TaskType())].GetDeploymentData() | |
| if findDeploymentVersion(deploymentVersions, worker_versioning.DeploymentVersionFromDeployment(workerDeployment)) >= 0 { | |
| break | |
| deploymentData := userData.GetData().GetPerType()[int32(c.queue.TaskType())].GetDeploymentData() | |
| if findDeploymentVersion(deploymentData, worker_versioning.DeploymentVersionFromDeployment(workerDeployment)) >= 0 { | |
| break |
This is still deploymentData, it just has a Deployments field and a Versions field now.
| select { | ||
| case <-userDataChanged: | ||
| case <-ctx.Done(): | ||
| c.logger.Error("timed out waiting for deployment to appear in user data") |
There was a problem hiding this comment.
| c.logger.Error("timed out waiting for deployment to appear in user data") | |
| c.logger.Error("timed out waiting for worker deployment version to appear in user data") |
Is this more accurate?
| ctx, | ||
| namespaceEntry, | ||
| WorkerDeploymentVersionWorkflowType, | ||
| WorkerDeploymentWorkflowType, |
There was a problem hiding this comment.
nice catch -- although I'm confused why our tests didn't catch this. Seems like sending an update to the wrong WF type should have always failed
There was a problem hiding this comment.
I know - I wondered on this too....
|
|
||
| // Namespace division | ||
| WorkerDeploymentVersionNamespaceDivision = "TemporalWorkerDeploymentVersion" | ||
| WorkerDeploymentVersionNamespaceDivision = "TemporalWorkerDeployment" |
There was a problem hiding this comment.
Should this variable be called WorkerDeploymentNamespaceDivision ?
There was a problem hiding this comment.
I think the naming with "version" is left over from when "Deployment" (instance) was the "first-class-citizen" of this whole API
There was a problem hiding this comment.
oops, yeah you are right - changing this to be called WorkerDeploymentNamespaceDivision
| // add version to worker-deployment workflow | ||
| activityCtx = workflow.WithActivityOptions(ctx, defaultActivityOptions) | ||
| err = workflow.ExecuteActivity(activityCtx, d.a.AddVersionToWorkerDeployment, &deploymentspb.AddVersionToWorkerDeploymentRequest{ | ||
| DeploymentName: d.VersionState.DeploymentName, | ||
| Version: d.VersionState.Version, | ||
| RequestId: d.newUUID(ctx), | ||
| }).Get(ctx, nil) | ||
| if err != nil { | ||
| return err | ||
| } | ||
|
|
There was a problem hiding this comment.
ah sorry - we were adding the same version twice to the worker-deployment workflow (we were doing this twice)!
There was a problem hiding this comment.
oh I see the duplicate code above -- got it
|
|
||
| func (d *WorkflowRunner) validateSetCurrent(args *deploymentspb.SetCurrentVersionArgs) error { | ||
| if d.State.CurrentVersion != args.Version { | ||
| if d.State.RoutingInfo.CurrentVersion != args.Version { |
There was a problem hiding this comment.
Nit: I think it's more idiomatic in Go, and more readable, to structure the function like
func foo(...) error {
if errorCondition {
return err
}
return nil
}
Returning success at the end and errors in the middle makes it easier to read. The section "A longer example" in https://8thlight.com/insights/exploring-error-handling-patterns-in-go this article also calls this out with another example.
## What changed? <!-- Describe what has changed in this PR --> - ListWorkerDeployments API - Also removed presence of locks when adding a version to a worker-deployment workflow. Causes deadlocks and we don't need them. ## Why? <!-- Tell your future self why have you made these changes --> - Versioning-3.1 ## How did you test it? <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> - Added functional tests (happy-path) - Existing suite ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> - None, feature ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) --> - No
## What changed? <!-- Describe what has changed in this PR --> - ListWorkerDeployments API - Also removed presence of locks when adding a version to a worker-deployment workflow. Causes deadlocks and we don't need them. ## Why? <!-- Tell your future self why have you made these changes --> - Versioning-3.1 ## How did you test it? <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> - Added functional tests (happy-path) - Existing suite ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> - None, feature ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) --> - No
## What changed? <!-- Describe what has changed in this PR --> - ListWorkerDeployments API - Also removed presence of locks when adding a version to a worker-deployment workflow. Causes deadlocks and we don't need them. ## Why? <!-- Tell your future self why have you made these changes --> - Versioning-3.1 ## How did you test it? <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> - Added functional tests (happy-path) - Existing suite ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> - None, feature ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) --> - No
## What changed? <!-- Describe what has changed in this PR --> - ListWorkerDeployments API - Also removed presence of locks when adding a version to a worker-deployment workflow. Causes deadlocks and we don't need them. ## Why? <!-- Tell your future self why have you made these changes --> - Versioning-3.1 ## How did you test it? <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> - Added functional tests (happy-path) - Existing suite ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> - None, feature ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) --> - No
## What changed? <!-- Describe what has changed in this PR --> - ListWorkerDeployments API - Also removed presence of locks when adding a version to a worker-deployment workflow. Causes deadlocks and we don't need them. ## Why? <!-- Tell your future self why have you made these changes --> - Versioning-3.1 ## How did you test it? <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> - Added functional tests (happy-path) - Existing suite ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> - None, feature ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) --> - No
## What changed? <!-- Describe what has changed in this PR --> - ListWorkerDeployments API - Also removed presence of locks when adding a version to a worker-deployment workflow. Causes deadlocks and we don't need them. ## Why? <!-- Tell your future self why have you made these changes --> - Versioning-3.1 ## How did you test it? <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> - Added functional tests (happy-path) - Existing suite ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> - None, feature ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) --> - No
## What changed? <!-- Describe what has changed in this PR --> - ListWorkerDeployments API - Also removed presence of locks when adding a version to a worker-deployment workflow. Causes deadlocks and we don't need them. ## Why? <!-- Tell your future self why have you made these changes --> - Versioning-3.1 ## How did you test it? <!-- How have you verified this change? Tested locally? Added a unit test? Checked in staging env? --> - Added functional tests (happy-path) - Existing suite ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> - None, feature ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) --> - No
What changed?
Why?
How did you test it?
Potential risks
Documentation
Is hotfix candidate?