Skip to content
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

XdsNameResolver and XdsServerWrapper don't check listener type #11737

Open
ejona86 opened this issue Dec 10, 2024 · 5 comments
Open

XdsNameResolver and XdsServerWrapper don't check listener type #11737

ejona86 opened this issue Dec 10, 2024 · 5 comments
Assignees
Milestone

Comments

@ejona86
Copy link
Member

ejona86 commented Dec 10, 2024

Our resource parsing supports two listener types (I'm not confident enough validation is happening here):

if (listener.hasApiListener()) {
return processClientSideListener(listener, args);
} else {
return processServerSideListener(listener, args);
}

But XdsNameResolver and XdsServerWrapper don't check that they got the right type. No changes were made to XdsNameResolver when non-API listener type was allowed, so I doubt the logic exists but I'm just not seeing it.

I also don't see XdsServerWrapper call address(), so it appears it is not follow gRFC A36.

The XdsServer must be "not serving" if the address does not match.

@ejona86 ejona86 added the bug label Dec 10, 2024
@ejona86 ejona86 added this to the Next milestone Dec 10, 2024
@ejona86
Copy link
Member Author

ejona86 commented Dec 16, 2024

Looks like the client receiving a socket listener will throw a NullPointerException, because httpConnectionManager() is null and instead listener() is set:

HttpConnectionManager httpConnectionManager = update.httpConnectionManager();
List<VirtualHost> virtualHosts = httpConnectionManager.virtualHosts();
String rdsName = httpConnectionManager.rdsName();

@shivaspeaks
Copy link
Member

Looks like the client receiving a socket listener will throw a NullPointerException

But SocketListener is a non-api server side listener and it will never be used in XdsNameResolver! Isn't it so? XdsListenerResouce validates a check for non-api listener type.
Oh so you mean this is not guaranteed/enforced here in XdsNameResolver! Then we need to do a validation in XdsNameResolver and in XdsServerWrapper.

@ejona86
Copy link
Member Author

ejona86 commented Jan 15, 2025

Yes, it isn't guaranteed. We expect a failure but we shouldn't trigger a NullPointerException.

@shivaspeaks
Copy link
Member

For the second part of this issue that it does not seem to follow gRFC A36. A simple conditional check with listenerAddress seems good enough. I believe we don't want to throw Exception from here, just marking it as not serving and logging the warning. Something like this in onChanged(LdsUpdate):

String ldsAddress = update.listener().address();
      if (!listenerAddress.equals(ldsAddress)) {
        logger.warning(
            String.format(
                "Listener address mismatch: expected %s, but got %s. Transitioning to NOT_SERVING.",
                listenerAddress, ldsAddress));
        listener.onNotServing(
            Status.UNKNOWN.withDescription(
                String.format(
                    "Listener address mismatch: expected %s, but got %s.",
                    listenerAddress, ldsAddress)).asRuntimeException());
      }

@ejona86
Copy link
Member Author

ejona86 commented Jan 16, 2025

In general, it is really rare to pass an error along and log a warning. There can be some times in our server code because passing the error along is only ever seen by metrics. But here, the default listener logs the error so you'd be double-logging. Don't log directly. I'll note you also need to make sure the server is not serving. It looks like handleConfigNotFound() would be the method to look at for how to do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants