-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
do not ignore subsets in soft sticky sessions #6822
do not ignore subsets in soft sticky sessions #6822
Conversation
merging as this is a bug fix to the soft session affinity code that went in earlier. Need to respect subsets in destination rule properly. |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
} | ||
} | ||
|
||
if consistentHash == nil { |
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.
flip this around to make this whole section more concise:
consistentHash := rule.GetTrafficPolicy().GetLoadBalancer().GetConsistentHash()
for _, subset := range rule.GetSubsets() {
if subset.GetName() == subsetName {
consistentHash = subset.GetTrafficPolicy().GetLoadBalancer().GetConsistentHash()
break
}
}
if consistentHash == nil {
return nil
}
@@ -128,4 +128,186 @@ func TestBuildHTTPRoutes(t *testing.T) { | |||
} | |||
g.Expect(routes[0].GetRoute().GetHashPolicy()).To(gomega.ConsistOf(hashPolicy)) | |||
}) | |||
|
|||
t.Run("ForVirtualServiceWithSubsetsWithRingHash", func(t *testing.T) { |
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.
Add a test case for a DestinationRule with no TrafficPolicy
object please; I suspect you'll get some nil-pointer panics due to rule.GetTrafficPolicy().GetLoadBalancer().GetConsistentHash()
.
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.
This will not panic thanks to the accessors
Port: &networking.PortSelector_Number{ | ||
Number: 65000, | ||
Port: &networking.PortSelector_Name{ | ||
Name: "foo", |
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.
add tests for ports only.. Names are deprecated..
port name is deprecated. traffic policies at the port level should only be inspected for port number when updating a route to use a hash policy.
990a20d
to
950a06c
Compare
Co-authored-by: Zachary Gershman <zgershman@pivotal.io>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: utako Assign the PR to them by writing The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
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.
...
portLevelSettings := rule.GetTrafficPolicy().GetPortLevelSettings() | ||
settingsHash := portLevelSettingsConsistentHash(destination, portLevelSettings) | ||
if settingsHash != nil { | ||
consistentHash = settingsHash |
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.
This needs to move to top before matching on subsets. Port level settings in subsets overrides the port level settings in top level.
settingsHash := portLevelSettingsConsistentHash(destination, subsetPortLevelSettings) | ||
if settingsHash != nil { | ||
consistentHash = settingsHash | ||
} |
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.
No if condition here. Essentially there is no inheritance. If something is missing it goes to default values. So you can assign everything to consistentHash and do a nil check in the end.
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'd be able to move the nil checks if this were patterned more after cluster.go
. We'll see about clarifying the behavior so it's more obvious in the next commit. We were hoping to avoid modifying the hash policy in place for clarity's sake.
if settingsHash != nil { | ||
consistentHash = settingsHash | ||
} | ||
|
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.
Same as above.
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.
Also this should be above the subset search for loop
Co-authored-by: Zachary Gershman <zgershman@pivotal.io>
piggybacking off of #6742.