Skip to content

add support for sourceip hashing in tcp proxy #35014

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

Merged
merged 7 commits into from
Sep 9, 2021

Conversation

ramaraochavali
Copy link
Contributor

Fixes #33558

  • Configuration Infrastructure
  • Docs
  • Installation
  • Networking
  • Performance and Scalability
  • Policies and Telemetry
  • Security
  • Test and Release
  • User Experience
  • Developer Infrastructure

Please check any characteristics that apply to this pull request.

  • [] Does not have any user-facing changes. This may include CLI changes, API changes, behavior changes, performance improvements, etc.

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
@ramaraochavali ramaraochavali requested a review from a team as a code owner September 3, 2021 11:33
@google-cla google-cla bot added the cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. label Sep 3, 2021
@istio-testing istio-testing added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 3, 2021
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
@ramaraochavali ramaraochavali requested review from a team as code owners September 3, 2021 11:36
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
@howardjohn
Copy link
Member

We need to update the API docs as well. Also add an integration test to https://github.com/istio/istio/blob/f2909db45681292f4acaf550d83cc92f2be47828/tests/integration/pilot/common/routing.go#L1409.

The other thing is backwards compatibility. I think we are probably ok here, but it could represent a behavioral change for some users

return buildOutboundNetworkFiltersWithSingleDestination(push, node, statPrefix, clusterName, port)
destRule := push.DestinationRule(node, service)
destinationRule := CastDestinationRule(destRule)
return buildOutboundNetworkFiltersWithSingleDestination(push, node, statPrefix, clusterName, port, destinationRule)
}
return buildOutboundNetworkFiltersWithWeightedClusters(node, routes, push, port, configMeta)
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't it need src ip hash?

Copy link
Contributor Author

@ramaraochavali ramaraochavali Sep 4, 2021

Choose a reason for hiding this comment

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

I do not know if it makes sense for weighted clusters - Does it? We build a single TCP Proxy and there are multiple upstream cluster. I am not sure how we can decide for which cluster sourceIP needs to be used - we certainly can not enforce for all?

Copy link
Member

Choose a reason for hiding this comment

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

Don't we support it for HTTP? We should be consistent at least I think

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 just looked at envoy code and it picks the cluster based on weights first applies the hash - so we should be able to do it here as well. Let me try

}

idleTimeout, err := time.ParseDuration(node.Metadata.IdleTimeout)
if err == nil {
tcpProxy.IdleTimeout = durationpb.New(idleTimeout)
}

// If destinationrule has consistent hash source ip set, use it for tcp proxy.
if destinationRule != nil && destinationRule.GetTrafficPolicy().GetLoadBalancer().GetConsistentHash() != nil &&
destinationRule.GetTrafficPolicy().GetLoadBalancer().GetConsistentHash().GetUseSourceIp() {
Copy link
Member

Choose a reason for hiding this comment

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

You should consider subset hash here

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. I will add

@ramaraochavali
Copy link
Contributor Author

We need to update the API docs as well. Also add an integration test to

Yes. Planning to update API docs once this is merged. Will add an integration test

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
@ramaraochavali ramaraochavali requested a review from a team as a code owner September 4, 2021 07:58
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
@ramaraochavali
Copy link
Contributor Author

@hzxuzhonghu @howardjohn any more comments on this?

Copy link
Member

@howardjohn howardjohn left a comment

Choose a reason for hiding this comment

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

LGTM aside from weighted cluster concerns

}

idleTimeout, err := time.ParseDuration(node.Metadata.IdleTimeout)
if err == nil {
tcpProxy.IdleTimeout = durationpb.New(idleTimeout)
}

if destinationRule != nil {
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
if destinationRule != nil {
if destinationRule.GetTrafficPolicy().GetLoadBalancer().GetConsistentHash().GetUseSourceIp() {

protobuf adds nil checks into each Get call

Copy link
Member

Choose a reason for hiding this comment

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

nevermind it doesn't quite work due to subsets. But we can simplify L85-L86

return buildOutboundNetworkFiltersWithSingleDestination(push, node, statPrefix, clusterName, port)
destRule := push.DestinationRule(node, service)
destinationRule := CastDestinationRule(destRule)
return buildOutboundNetworkFiltersWithSingleDestination(push, node, statPrefix, clusterName, port, destinationRule)
}
return buildOutboundNetworkFiltersWithWeightedClusters(node, routes, push, port, configMeta)
Copy link
Member

Choose a reason for hiding this comment

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

Don't we support it for HTTP? We should be consistent at least I think

Signed-off-by: Rama Chavali <rama.rao@salesforce.com>
@ramaraochavali
Copy link
Contributor Author

/test unit-tests_istio

@ramaraochavali
Copy link
Contributor Author

/test integ-security-multicluster-tests_istio

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/networking cla: yes Set by the Google CLA bot to indicate the author of a PR has signed the Google CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consistent hashing not supported for tcp/tls proxies
5 participants