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

Fix versioning override with AutoUpgrade behavior #1765

Merged

Conversation

antlai-temporal
Copy link
Contributor

What was changed

The current implementation for versioning override fails for AutoUpgrade
because it uses an empty Deployment struct instead of a nil pointer.

See #1764 for details.

Also missing gofmt of some unrelated files corrected.

Why?

This is a blocker for the new versioning-3 implementation.

Checklist

  1. Closes
    Versioning override AutoUpgrade using a ref to an empty deployment struct instead of a nil pointer #1764
  2. How was this tested:

Integration test

@antlai-temporal antlai-temporal requested a review from a team as a code owner January 8, 2025 01:32
@@ -105,6 +105,9 @@ func workflowExecutionOptionsMaskToProto(mask []string) *fieldmaskpb.FieldMask {
}

func workerDeploymentToProto(d Deployment) *deploymentpb.Deployment {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not make the source of this a pointer if unset is a valid state? Meaning, make VersioningOverride.Deployment accept a pointer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it was cleaner not to expose pointers and just use an empty struct. Otherwise you ended up with what "a pointer to an empty struct" means vs a nil pointer. It is also consistent with the other apis that use Deployment.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like the server treats an empty struct here as invalid and errors is that correct?

Copy link
Member

@cretz cretz Jan 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Otherwise you ended up with what "a pointer to an empty struct" means vs a nil pointer.

If there is a difference between empty and null in the server-side API and we need to represent that difference, we should do the same here. If the server errors on empty, good, that tells the user it was invalid like it might for anything else invalid. If the server wants to treat empty and null as the same, we can too.

It is also consistent with the other apis that use Deployment.

Are there other fields where the zero value of a struct means nil when converting to proto? I think we should consider fixing those too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, other empty structs related to deployment are ok, but this one was not... They may eventually fix that, but this is
blocking the autoUpgrade override...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cretz There was a difference but it was not intentional, there should be no difference. It is just that the OSS server release is out, and it is better to fix it internally in the first SDK release without exposing it, and eventually change it in the server...
All the other values that I can think of would take either empty or nil. I mapped VersioningOverride{} to nil mostly to keep things more clear, but I don't think it is strictly needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add a comment explaining this so future readers understand why we are inconsistent here?

If the server will always treat nil and empty the same then I am fine using an empty struct instead of a pointer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment added

@antlai-temporal antlai-temporal merged commit 938dcad into temporalio:master Jan 8, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants