-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Location based Load Balancing #10720
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
Changes from all commits
8cbda27
14eb898
30ec747
106069e
6c0241d
6f37049
6d0fa85
d545d3d
a9e60ca
585cbfc
484e2c3
ff01e4b
70b0a7d
a09f729
16f3a35
e1dbb30
ec604c1
13f3220
5f86655
2e7bbad
caf852b
1b72d55
79ad5a7
6e143b4
0496af9
1c6bed8
71ebe14
29d7cc3
985241a
d4eafd1
8e81897
a2ab1e0
9cd4393
61f6fc1
a2f61f9
6c23568
cbb99d7
cac5215
31ffe5a
16283e3
c404c34
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| // Copyright 2019 Istio Authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package model | ||
|
|
||
| type LocalityInterface interface { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is this ? It's not java - we don't define interfaces for structs.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is to support passing both model.Locality and core.Locality as a param.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then please add a comment to indicate this.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also - which core.Locality ? From envoy ?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, will do |
||
| GetRegion() string | ||
| GetZone() string | ||
| GetSubZone() string | ||
| } | ||
|
|
||
| // Identifies location of where either Envoy runs or where upstream hosts run. | ||
| type Locality struct { | ||
| // Region this proxy belongs to. | ||
| Region string | ||
| // Defines the local service zone where Envoy is running. Though optional, it | ||
| // should be set if discovery service routing is used and the discovery | ||
| // service exposes :ref:`zone data <envoy_api_field_endpoint.LocalityLbEndpoints.locality>`, | ||
| // either in this message or via :option:`--service-zone`. The meaning of zone | ||
| // is context dependent, e.g. `Availability Zone (AZ) | ||
| // <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html>`_ | ||
| // on AWS, `Zone <https://cloud.google.com/compute/docs/regions-zones/>`_ on | ||
| // GCP, etc. | ||
| Zone string | ||
| // When used for locality of upstream hosts, this field further splits zone | ||
| // into smaller chunks of sub-zones so they can be load balanced | ||
| // independently. | ||
| SubZone string | ||
| } | ||
|
|
||
| func (l *Locality) GetRegion() string { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same - let's not introduce java-style in go, we don't use this pattern anywhere in istio.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ACK |
||
| if l != nil { | ||
| return l.Region | ||
| } | ||
| return "" | ||
| } | ||
|
|
||
| func (l *Locality) GetZone() string { | ||
| if l != nil { | ||
| return l.Zone | ||
| } | ||
| return "" | ||
| } | ||
|
|
||
| func (l *Locality) GetSubZone() string { | ||
| if l != nil { | ||
| return l.SubZone | ||
| } | ||
| return "" | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -496,6 +496,9 @@ type ServiceDiscovery interface { | |
| // determine the intended destination of a connection without a Host header on the request. | ||
| GetProxyServiceInstances(*Proxy) ([]*ServiceInstance, error) | ||
|
|
||
| // GetProxyLocality returns the locality where the proxy runs. | ||
| GetProxyLocality(*Proxy) string | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please remove this method - the locality is part of the ServiceInstance and node, it is not a separate call to make to the registry. We already had support for returning it ( and AFAIK it worked for Consul as well if the proper labels were set )
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, we can get from |
||
|
|
||
| // ManagementPorts lists set of management ports associated with an IPv4 address. | ||
| // These management ports are typically used by the platform for out of band management | ||
| // tasks such as health checks, etc. In a scenario where the proxy functions in the | ||
|
|
@@ -535,12 +538,12 @@ func (h Hostname) Matches(o Hostname) bool { | |
| return true | ||
| } | ||
|
|
||
| hWildcard := string(h[0]) == "*" | ||
| hWildcard := len(h) > 0 && string(h[0]) == "*" | ||
| if hWildcard && len(o) == 0 { | ||
| return true | ||
| } | ||
|
|
||
| oWildcard := string(o[0]) == "*" | ||
| oWildcard := len(o) > 0 && string(o[0]) == "*" | ||
| if !hWildcard && !oWildcard { | ||
| // both are non-wildcards, so do normal string comparison | ||
| return h == o | ||
|
|
@@ -574,8 +577,8 @@ func (h Hostname) SubsetOf(o Hostname) bool { | |
| return true | ||
| } | ||
|
|
||
| hWildcard := string(h[0]) == "*" | ||
| oWildcard := string(o[0]) == "*" | ||
| hWildcard := len(h) > 0 && string(h[0]) == "*" | ||
| oWildcard := len(o) > 0 && string(o[0]) == "*" | ||
| if !oWildcard { | ||
| if hWildcard { | ||
| return false | ||
|
|
||
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 is too dangerous - invalid location-based config should not crash down the entire cluster ( which will happen since pilot will crash loop ).
Please report an error, increment a stat - but make sure pilot keeps running.
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.
Isn't this a normal behavior for a system to stop bootstrap to prevent undefined error once a config is invalid?
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.
Not in a production system. Configs need to be validate before submission, and ignored/dropped if they are invalid in prod - we don't want the entire production to go down because of a bad config.
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 is in the bootstrap procedure , for a reload procedure i think we can omit it and keep running use the previous config.