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

xds: listener type validation #11933

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

shivaspeaks
Copy link
Member

Fixes #11737

@shivaspeaks shivaspeaks changed the title Listener type validation xds: listener type validation Mar 3, 2025
@shivaspeaks shivaspeaks requested a review from ejona86 March 3, 2025 15:25
@ejona86 ejona86 self-requested a review March 5, 2025 21:20
Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I didn't mean to approve

@shivaspeaks shivaspeaks added the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Mar 6, 2025
@grpc-kokoro grpc-kokoro removed the kokoro:run Add this label to a PR to tell Kokoro the code is safe and tests can be run label Mar 6, 2025
@shivaspeaks shivaspeaks requested a review from ejona86 March 6, 2025 20:52
@Override
public void onResourceDoesNotExist(final String resourceName) {
if (stopped) {
return;
}
StatusException statusException = Status.UNAVAILABLE.withDescription(
String.format("Listener %s unavailable, xDS node ID: %s", resourceName,
String.format("%s listener unavailable, xDS node ID: %s", resourceName,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: what would be the reason to switch the order of the error format here? I think Listener %s is slightly more common in the code base. Consistent formatting helps with searching when debugging issues.

Copy link
Member

@ejona86 ejona86 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found these comments laying around. I don't know why I didn't send it out earlier.

@shivaspeaks shivaspeaks requested a review from ejona86 March 18, 2025 17:03
@shivaspeaks shivaspeaks requested a review from ejona86 March 19, 2025 15:58
@shivaspeaks shivaspeaks requested a review from ejona86 March 19, 2025 18:07
@larry-safran
Copy link
Contributor

While it is in the gRFC, why is it really important to enforce a returned address being non-null? This doesn't seem to really provide value as the address was already known for communicating to the xds server in the first place.

@ejona86
Copy link
Member

ejona86 commented Mar 24, 2025

This doesn't seem to really provide value as the address was already known for communicating to the xds server in the first place.

The returned Listener address tells the server what to listen on. We didn't remove it. We just made it so that the control plane can have a trivial job of filling in the correct value.

public void onChanged_listenerAddressMismatch()
throws ExecutionException, InterruptedException, TimeoutException {

when(mockBuilder.build()).thenReturn(mockServer);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already done in @Before. Delete it?

filterRegistry, executor.getScheduledExecutorService());

final SettableFuture<Server> start = SettableFuture.create();
Executors.newSingleThreadExecutor().execute(new Runnable() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This thread is going to be hanging and outlive the test. Run xdsServerWrapper.shutdownNow() at the end to let the start() return. Ideally you'd wait for the start future to complete as well (which will throw an exception), so you know the thread has (essentially) returned.

Copy link
Member Author

@shivaspeaks shivaspeaks Mar 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is a teardown happening after every test in @After which does xdsServerWrapper.shutdownNow(). So I doubt if we should be adding in the test as well!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, shutdownNow can be called twice. I'm not wild about the lifecycles in the test as we won't notice if it is broken. But I think a lot of these tests are bad already, so let's call it good enough as-is.

filterRegistry, executor.getScheduledExecutorService());

final SettableFuture<Server> start = SettableFuture.create();
Executors.newSingleThreadExecutor().execute(new Runnable() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, shutdownNow can be called twice. I'm not wild about the lifecycles in the test as we won't notice if it is broken. But I think a lot of these tests are bad already, so let's call it good enough as-is.

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

Successfully merging this pull request may close these issues.

XdsNameResolver and XdsServerWrapper don't check listener type
5 participants