-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Fix mirroring all services when remote selector is empty #11344
Conversation
The multicluster link supports two selectors: one for normal (endpoint-based) mirrors, and one for remote-discovery where only service imports are created. When the remote-discovery selector is empty (i.e. an empty object '{}'), then all services in a cluster will be mirrored. The created imports also have an underlying Endpoints object created. There are two distinct checks that decide whether a service import should be created: `isExported` and `isRemote`. When a selector is empty, the checks are shortcircuted and return early. The former check (`isExported`) additionally also checks if a service is remote, without checking if the corresponding selector is empty. This allows services to slip through since an empty selector encompasses everything. The change fixes the issue by removing any remote discovery checks from `isExported`. Where necessary, we add another call to `isRemote`. Fixes #11309 Signed-off-by: Matei David <[email protected]>
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'd feel a lot more confident about this change if we were able to test it...
How hard would it be to wire up an integration test that catches the original issue?
Signed-off-by: Matei David <[email protected]>
That's a great point, I should've added a test. They're trivial to write, they just don't follow the usual integration test patterns we've been using in
Before the change, one of the cases fails (remote discovery label when empty catches all services), which is expected. After the change it passes.
|
Signed-off-by: Matei David <[email protected]>
Signed-off-by: Matei David <[email protected]>
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.
Thanks @mateiidavid , LGTM 👍
* Fix mirroring all services when remote selector is empty The multicluster link supports two selectors: one for normal (endpoint-based) mirrors, and one for remote-discovery where only service imports are created. When the remote-discovery selector is empty (i.e. an empty object '{}'), then all services in a cluster will be mirrored. The created imports also have an underlying Endpoints object created. There are two distinct checks that decide whether a service import should be created: `isExported` and `isRemote`. When a selector is empty, the checks are shortcircuted and return early. The former check (`isExported`) additionally also checks if a service is remote, without checking if the corresponding selector is empty. This allows services to slip through since an empty selector encompasses everything. The change fixes the issue by removing any remote discovery checks from `isExported`. Where necessary, we add another call to `isRemote`. Fixes linkerd#11309 Signed-off-by: Matei David <[email protected]> * Add an integration test for empty selectors Signed-off-by: Matei David <[email protected]> * Differentiate test service ports Signed-off-by: Matei David <[email protected]> * @alpeb's feedback Signed-off-by: Matei David <[email protected]> --------- Signed-off-by: Matei David <[email protected]>
* Fix mirroring all services when remote selector is empty The multicluster link supports two selectors: one for normal (endpoint-based) mirrors, and one for remote-discovery where only service imports are created. When the remote-discovery selector is empty (i.e. an empty object '{}'), then all services in a cluster will be mirrored. The created imports also have an underlying Endpoints object created. There are two distinct checks that decide whether a service import should be created: `isExported` and `isRemote`. When a selector is empty, the checks are shortcircuted and return early. The former check (`isExported`) additionally also checks if a service is remote, without checking if the corresponding selector is empty. This allows services to slip through since an empty selector encompasses everything. The change fixes the issue by removing any remote discovery checks from `isExported`. Where necessary, we add another call to `isRemote`. Fixes linkerd#11309 Signed-off-by: Matei David <[email protected]> * Add an integration test for empty selectors Signed-off-by: Matei David <[email protected]> * Differentiate test service ports Signed-off-by: Matei David <[email protected]> * @alpeb's feedback Signed-off-by: Matei David <[email protected]> --------- Signed-off-by: Matei David <[email protected]> Signed-off-by: Adam Shaw <[email protected]>
The multicluster link supports two selectors: one for normal (endpoint-based) mirrors, and one for remote-discovery where only service imports are created. When the remote-discovery selector is empty (i.e. an empty object '{}'), then all services in a cluster will be mirrored. The created imports also have an underlying Endpoints object created.
There are two distinct checks that decide whether a service import should be created:
isExported
andisRemote
. When a selector is empty, the checks are shortcircuted and return early. The former check (isExported
) additionally also checks if a service is remote, without checking if the corresponding selector is empty. This allows services to slip through since an empty selector encompasses everything.The change fixes the issue by removing any remote discovery checks from
isExported
. Where necessary, we add another call toisRemote
.Fixes #11309
Reproducing the issue
The source cluster will now contain imports for all services in the target, including the
kubernetes
service.Testing
With the change in place, tested: