Fix mirroring all services when remote selector is empty#11344
Fix mirroring all services when remote selector is empty#11344mateiidavid merged 4 commits intomainfrom
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]>
olix0r
left a comment
There was a problem hiding this comment.
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]>
* 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:
isExportedandisRemote. 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
kubernetesservice.Testing
With the change in place, tested: