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

cleanup of the JettyServletEngineAdapters and JettyHttpProxy for Jetty 9.4 and 12 #309

Merged
merged 5 commits into from
Nov 18, 2024

Conversation

lachlan-roberts
Copy link
Collaborator

  • Prefer use of insertHandler() where possible.
  • Do not add an RPC connector if in HttpConnector mode.
  • Only perform the configuration of the HttpConfiguration once.
  • In HTTP mode merge the two SizeLimitHandlers into one instead of having separate ones for request and response content.
  • Remove the GAE CoreSizeLimitHandler and use the one provided by Jetty.

@lachlan-roberts
Copy link
Collaborator Author

This is targeted at the gzip-headers-jetty94 branch as it is built on top of those changes, but I will re-target this at main once #308 is merged.

@ludoch
Copy link
Collaborator

ludoch commented Nov 14, 2024

@maigovannon will do the full review.

@ludoch ludoch removed their request for review November 14, 2024 01:34
// Don't add the RPC Connector if in HttpConnector mode.
if (!isHttpConnectorMode)
{
rpcConnector =
Copy link
Collaborator

Choose a reason for hiding this comment

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

I understand that the rpcConnector won't be needed for HTTP mode but with this change we are no longer initializating this field anymore for both modes. Any chance that it would cause an NPE below for HttpConnector when we actually service the request?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This field is only ever used in JettyServletEngineAdaptor.serviceRequest, and in the GEN2 runtimes the only way we get to serviceRequest is through the ForwardingHandler in the JettyHttpProxy, and in HttpConnectorMode we never add this handler to go over RPC.

Comment on lines 125 to 126
if (!isHttpConnectorMode)
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

[nit] Suggest we stick to the K&R style since that is the convention in most other places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Comment on lines +138 to +147
HttpConfiguration httpConfiguration = rpcConnector.getHttpConfiguration();
httpConfiguration.setSendDateHeader(false);
httpConfiguration.setSendServerVersion(false);
httpConfiguration.setSendXPoweredBy(false);
if (LEGACY_MODE) {
httpConfiguration.setRequestCookieCompliance(CookieCompliance.RFC2965);
httpConfiguration.setResponseCookieCompliance(CookieCompliance.RFC2965);
httpConfiguration.setUriCompliance(UriCompliance.LEGACY);
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

What are your thoughts about movign all this to the constructor of DelegateConnector itself? I see that it class is only here and if you feel you don't want to give these defaults for all constructors of this instance, should we create static createDefaultDelegateConnector() ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What are your thoughts about movign all this to the constructor of DelegateConnector itself?

I wrote the jetty-delegate code to be a generic mechansim not google specific things, which could potentially be applied to other protocols other than the google RPC, so that it could potentially be extracted out into Jetty to be maintained in the future.

The interface with google code is done in the com.google.apphosting.runtime.jetty.delegate.impl package.

So I think adding compliance modes specific for the google usage should be here rather than in the DelegateConnector.

Copy link
Collaborator

@ludoch ludoch left a comment

Choose a reason for hiding this comment

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

Any extra tests that would validate the new behavior of the refactoring?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Would that fix the flakiness seen with 12.0.15 #304 ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Don't think so, I compared both SizeLimitHandlers and they were essentially the same other than some improved error handling in the Jetty one.

Opened #310 to track this.

};
server.addConnector(rpcConnector);

// Don't add the RPC Connector if in HttpConnector mode.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hum. so we did that, what the side effect? 2 connectors and one not used? More memory used?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Probably, but I don't think the memory saving here is that significant considering the DelegateConnector was never used.

httpConfiguration.setSendDateHeader(false);
httpConfiguration.setSendServerVersion(false);
httpConfiguration.setSendXPoweredBy(false);
if (LEGACY_MODE) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just a question there (hard to diff), LEGACY_MODE is still in both rpc and http connector, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes but for http connector it is done in com.google.apphosting.runtime.jetty.proxy.JettyHttpProxy#newConnector.

Base automatically changed from gzip-headers-jetty94 to main November 18, 2024 04:03
@lachlan-roberts lachlan-roberts merged commit b4c953a into main Nov 18, 2024
7 checks passed
@lachlan-roberts lachlan-roberts deleted the cleanupOfJettyServletEngineAdaptors branch November 18, 2024 04:10
ludoch pushed a commit that referenced this pull request Nov 22, 2024
…tEngineAdaptors

PiperOrigin-RevId: 697802010
Change-Id: I1f6149e6fd89a1ab5d1ce75b9ae416b8f0fb4faf
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.

3 participants