-
Notifications
You must be signed in to change notification settings - Fork 351
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
dataclients/kubernetes: change GetEndpointAddresses to return addresses without scheme and port #2917
dataclients/kubernetes: change GetEndpointAddresses to return addresses without scheme and port #2917
Conversation
302dd49
to
4b0187f
Compare
epID := endpointID{ | ||
ResourceID: newResourceID(namespace, name), | ||
Protocol: protocol, | ||
} |
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 was logically wrong because it does not contain target port unlike other places that use state.cachedEndpoints
@@ -22,18 +22,18 @@ type endpointList struct { | |||
Items []*endpoint `json:"items"` | |||
} | |||
|
|||
func formatEndpointString(ip, protocol string, port int) string { | |||
return protocol + "://" + net.JoinHostPort(ip, strconv.Itoa(port)) | |||
func formatEndpointString(ip, scheme string, port int) string { |
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 not strictly required for this refactoring but I noticed the inconsistency and decided to fix it along.
9b79d6c
to
493c3fc
Compare
state.mu.Lock() | ||
defer state.mu.Unlock() | ||
if cached, ok := state.cachedEndpoints[epID]; ok { | ||
if cached, ok := state.cachedAddresses[rID]; ok { |
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.
I think we can even drop the cache as implementation became straightforward now
493c3fc
to
471cfb4
Compare
a86199b
to
ce25bc5
Compare
I would like to kindly ask why we should provide format different from what we already have in the |
Redis endpoints are used by redis client, these are not backend endpoints for the proxy. |
TestConcurrentKubernetesClusterStateAccessWithRemoteRedis fails because it creates an endpoint with a single address and multiple ports Lines 150 to 166 in be4ef50
while in k8s cluster endpoints have multiple addresses and a single port. I've created #2919 to address this. |
…es without scheme and port * use -kubernetes-redis-service-port flag to explicitly configure redis port * use separate cluster state cache for addresses since cache key does not contain port * rename helpers protocol argument to scheme This is a breaking change for users that: * use kubernetes dataclient GetEndpointAddresses method * use dynamic redis shards discovery AND use non-standard redis port AND do not specify -kubernetes-redis-service-port For #2476 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
ce25bc5
to
d05dd7b
Compare
👍 |
Please make sure that the release notes contain all information what needs to be done to migrate (breaking change with simple migration path if documented). |
👍 |
Returning cached endpoint addreses from exported GetEndpointAddresses makes it possible for caller to modify cached values. Since the logic of obtaining endpoint addresses is lightweight this change simply drops caching altogether. Follow up on #2917 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Returning cached endpoint addreses from exported GetEndpointAddresses makes it possible for caller to modify cached values. Since the logic of obtaining endpoint addresses is lightweight this change simply drops caching altogether. Follow up on #2917 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
for i := 0; i < len(a); i++ { | ||
a[i] = strings.TrimPrefix(a[i], "http://") |
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.
Here is an obscure bug, see https://github.com/zalando/skipper/pull/2917/files#r1486405631
a[i] = strings.TrimPrefix(a[i], "http://") | ||
a[i] = net.JoinHostPort(a[i], port) |
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.
Here is an obscure bug - the code modifies cached value of a
returned from kdc.GetEndpointAddresses, see #2929
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.
It was not observed in production because k8s poll interval is 3 seconds and redis endpoints update interval is 10s
Returning cached endpoint addreses from exported GetEndpointAddresses makes it possible for caller to modify cached values. Since the logic of obtaining endpoint addresses is lightweight this change simply drops caching altogether. Follow up on #2917 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
Returning cached endpoint addreses from exported GetEndpointAddresses makes it possible for caller to modify cached values. Since the logic of obtaining endpoint addresses is lightweight this change simply drops caching altogether. Follow up on #2917 Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
This is a breaking change for users that:
For #2476