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 new API's simpler representation of versioning data #3432

Merged
merged 8 commits into from Mar 15, 2023

Conversation

Sushisource
Copy link
Member

What changed?
Handle changes in temporalio/api#237 which simplify the graph representation. Draft until that is merged (and sdk-go, etc).

Why?
Simpler better

How did you test it?
Changed all existing tests which still made sense, dropped nonsense ones, added new ones.

Potential risks
None, not in use yet.

Is hotfix candidate?

@Sushisource Sushisource mentioned this pull request Sep 27, 2022
@Sushisource Sushisource force-pushed the versioning-api-refactor branch 2 times, most recently from 2d201a1 to de0fe81 Compare September 28, 2022 17:26
@sync-by-unito sync-by-unito bot closed this Mar 3, 2023
@yycptt yycptt reopened this Mar 3, 2023
service/frontend/workflow_handler.go Outdated Show resolved Hide resolved
service/matching/taskQueueManager_test.go Outdated Show resolved Hide resolved
if data == nil || data.GetVersionSets() == nil {
return nil
}
asBytes, err := data.Marshal()
Copy link
Member

Choose a reason for hiding this comment

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

this is technically not guaranteed to be deterministic. I'm not sure how much we care

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems kinda important. Can I use these XXX_Marshall functions? Gogo proto's docs are less than clear. Or is there some other simple way to guarantee that without doing it all by hand?

Copy link
Member

Choose a reason for hiding this comment

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

I don't know if there's anything in the proto lib or generated code that guarantees it. But I think in practice we can rely on it being deterministic within a single binary (running on a single architecture), which is the situation we care about

}
sets := g.GetVersionSets()
startIndex := len(sets) - maxDepth
shortened := g.GetVersionSets()[startIndex:]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
shortened := g.GetVersionSets()[startIndex:]
shortened := util.SliceTail(g.GetVersionSets(), maxDepth)

(package common/util)

or really maybe just inline this at the two sites? one function that does two kinda related but different things is a little icky

Copy link
Member Author

Choose a reason for hiding this comment

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

Used the util, but kept this. I just can't bring myself to copy-paste stuff lol.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed this anyways since the linter whines about it

service/matching/version_sets.go Outdated Show resolved Hide resolved
}

existingData.VersionSets = append(existingData.GetVersionSets(), &taskqueuepb.CompatibleVersionSet{
Versions: []string{targetedVersion},
Copy link
Member

Choose a reason for hiding this comment

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

need to generate a uuid here. I have it in my pending PR on top of this but you could add it here if you want

Copy link
Member Author

Choose a reason for hiding this comment

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

Added

}

func extractTargetedVersion(req *workflowservice.UpdateWorkerBuildIdCompatabilityRequest) string {
if req.GetAddNewCompatibleVersion() != nil {
Copy link
Member

@dnr dnr Mar 10, 2023

Choose a reason for hiding this comment

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

kinda weird to effectively do this type switch twice, and using a different technique too. I know go (nor proto) doesn't have the pattern matching that would make this nice, but maybe better to do one switch and just pull these out of the typed value? (i.e. drop this function entirely and just read the fields as required in the function above)

Copy link
Member Author

Choose a reason for hiding this comment

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

Problem is I also need to get it out first to pass it into findVersion. I've made the styles consistent now but I don't immediately see a non-super-duplicative way to get rid of this fn.

Copy link
Member

Choose a reason for hiding this comment

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

yeah, I meant duplicate calls to findVersion in each branch. it's more duplication in some ways (code in branches of type switch) and less in others (type switch itself). overall I'm guessing it comes out shorter. but it's subjective so 🤷

service/matching/version_sets.go Outdated Show resolved Hide resolved
service/matching/version_sets_test.go Outdated Show resolved Hide resolved
@Sushisource Sushisource marked this pull request as ready for review March 13, 2023 16:42
@Sushisource Sushisource requested a review from a team as a code owner March 13, 2023 16:42
@Sushisource
Copy link
Member Author

Will be merged after API/Go sdk changes

@Sushisource Sushisource force-pushed the versioning-api-refactor branch 6 times, most recently from 3830d5f to dae80d0 Compare March 14, 2023 16:18
Copy link
Member

@dnr dnr left a comment

Choose a reason for hiding this comment

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

just stylistic stuff at this point so feel free to take the suggestions you like

@@ -44,8 +44,8 @@ require (
go.opentelemetry.io/otel/metric v0.36.0
go.opentelemetry.io/otel/sdk v1.13.0
go.opentelemetry.io/otel/sdk/metric v0.36.0
go.temporal.io/api v1.18.1
go.temporal.io/sdk v1.21.1
go.temporal.io/api v1.19.0
Copy link
Member

Choose a reason for hiding this comment

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

in the future I don't think there's any reason to "release" the api repo, we can just use whatever commit

service/frontend/workflow_handler.go Outdated Show resolved Hide resolved
service/frontend/workflow_handler.go Outdated Show resolved Hide resolved
if data == nil || data.GetVersionSets() == nil {
return nil
}
asBytes, err := data.Marshal()
Copy link
Member

Choose a reason for hiding this comment

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

I don't know if there's anything in the proto lib or generated code that guarantees it. But I think in practice we can rely on it being deterministic within a single binary (running on a single architecture), which is the situation we care about

service/matching/version_sets.go Outdated Show resolved Hide resolved
}
// Limit graph size if it's grown too large
newResp := depthLimiter(existingData, maxSize)
existingData.VersionSets = newResp.GetMajorVersionSets()
Copy link
Member

Choose a reason for hiding this comment

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

creating a "response" struct in the function to just pull out one field is one reason I wanted to inline this. I still think that would be better, but it's subjective at this point

service/matching/version_sets.go Outdated Show resolved Hide resolved

// Finds the version in the version sets, returning (set index, index within that set)
// Returns -1, -1 if not found.
func findVersion(data *persistence.VersioningData, buildID string) findVersionRes {
Copy link
Member

Choose a reason for hiding this comment

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

use multiple return values instead of struct?

Suggested change
func findVersion(data *persistence.VersioningData, buildID string) findVersionRes {
func findVersion(data *persistence.VersioningData, buildID string) (setIndex int, indexInSet int) {

Copy link
Member Author

Choose a reason for hiding this comment

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

The linter bitched at me for that lol

}

func extractTargetedVersion(req *workflowservice.UpdateWorkerBuildIdCompatabilityRequest) string {
if req.GetAddNewCompatibleVersion() != nil {
Copy link
Member

Choose a reason for hiding this comment

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

yeah, I meant duplicate calls to findVersion in each branch. it's more duplication in some ways (code in branches of type switch) and less in others (type switch itself). overall I'm guessing it comes out shorter. but it's subjective so 🤷

@Sushisource Sushisource enabled auto-merge (squash) March 15, 2023 16:32
@Sushisource Sushisource merged commit 07ffab5 into temporalio:master Mar 15, 2023
7 checks passed
@Sushisource Sushisource deleted the versioning-api-refactor branch March 15, 2023 17:01
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.

None yet

3 participants