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

NIFI-8181 - Added a property to specify whether to allow HTTP2 protoc… #4804

Closed
wants to merge 4 commits into from

Conversation

thenatog
Copy link
Contributor

@thenatog thenatog commented Feb 3, 2021

…ol for requests.

Thank you for submitting a contribution to Apache NiFi.

Please provide a short description of the PR here:

Description of PR

Enables X functionality; fixes bug NIFI-YYYY.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced
    in the commit message?

  • Does your PR title start with NIFI-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.

  • Has your PR been rebased against the latest commit within the target branch (typically main)?

  • Is your initial contribution a single, squashed commit? Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not squash or use --force when pushing to allow for clean monitoring of changes.

For code changes:

  • Have you ensured that the full suite of tests is executed via mvn -Pcontrib-check clean install at the root nifi folder?
  • Have you written or updated unit tests to verify your changes?
  • Have you verified that the full build is successful on JDK 8?
  • Have you verified that the full build is successful on JDK 11?
  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?
  • If applicable, have you updated the LICENSE file, including the main LICENSE file under nifi-assembly?
  • If applicable, have you updated the NOTICE file, including the main NOTICE file found under nifi-assembly?
  • If adding new Properties, have you added .displayName in addition to .name (programmatic access) for each of the new properties?

For documentation related changes:

  • Have you ensured that format looks appropriate for the output in which it is rendered?

Note:

Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.

Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @thenatog. Instead of adding a Boolean property, what about following the semantics of OkHttpClient.Builder.protocols() and allowing the specification of the actual protocol values? OkHttpClient defaults to supporting HTTP 1.1 and HTTP 2, but also supports several other protocols according to current documentation.

To maintain backward compatibility with the default OkHttpClient.Builder configuration, setting the property value to HTTP 1.1 and HTTP 2 should be the default value. Allowing the specification of multiple protocol values using comma separation would support the capability described and also provide additional flexibility for other use cases. Supporting multiple values would require custom validation, but the Protocol enum from OkHttpClient could be used to validate acceptable string values.

@thenatog
Copy link
Contributor Author

thenatog commented Feb 3, 2021

I guess it is possible to allow users to explicitly choose a protocol, but they are not mutually exclusive. If you choose HTTP/2, we will need to include HTTP/1.1 as well, which is basically what the True/False enables. I don't know if users are that interested in figuring out what protocol to choose eg. H2_PRIOR_KNOWLEDGE or QUIC.

I can change the default to True. I also forgot to add user docs so I'll do that now.

@markap14
Copy link
Contributor

markap14 commented Feb 3, 2021

That's interesting @exceptionfactory. I didn't realize there were other additional protocols supported by the library. Personally I'm a bit torn on how I think we should best approach it. We can have a single property for specifying which protocols to support, but that has the downside that it's a bad user experience. It requires that the user look up the documentation each time to understand exactly what needs to be typed in, and must then type it in whereas the boolean approach allows them to just select the value (when it's appropriate). We could add an additional property for each protocol that that means we'd be adding several properties to a processor that already has a lot of properties.

What it really comes down to, IMO, is a trade-off between power vs. ease of use. The boolean property is easier to use when it applies (which I think is going to be > 99% of the time) but is less powerful because it doesn't support the additional protocols. The other options are not as nice a user experience but are more powerful.

Personally, I think we should lean more toward ease of use than power, so I think I prefer the boolean.

@thenatog
Copy link
Contributor Author

thenatog commented Feb 3, 2021

I've set the default to True and realized the documentation for standard processors is compiled from PropertyDescriptor descriptions which I had already added.

I think that allowing users to explicitly set protocols may be too library specific. "H2_PRIOR_KNOWLEDGE" for example sounds like it is specifically for use with the okhttp client library for certain use cases, and is not necessarily broadly applicable to HTTP generally. I may be wrong.

My approach would be to go with this simpler approach for now, and if we find that users want more specific control then we can move to that. The issue again being that they would be specifying names of protocols that are derived from okhttp which may not exist in a different HTTP client library.

Copy link
Contributor

@exceptionfactory exceptionfactory left a comment

Choose a reason for hiding this comment

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

Thanks for comments @thenatog and @markap14. It is certainly a tradeoff between customization an ease of use, and it could get complicated when it comes to entering specific string values.

Staying with the Boolean property approach, would it make more sense to change the property to Disable HTTP/2 and set the default value to false? That way, if the property is set to true, the processor would explicitly set the HTTP/1.1 protocol, but otherwise would not set the protocols() property in the OkHttpClient.Builder. This would allow the default OkHttpClient behavior to be maintained, without necessarily having to specify the default protocols in this processor. I think this approach might also provide more flexibility in the future if the need arises to support some other protocols.

…ctively the same thing. Fixed docs to show HTTP/2, small codestyle fixes.
@exceptionfactory
Copy link
Contributor

@thenatog One additional note in favor of reversing the property to "Disable HTTP/2" instead of "Support HTTP2/": Naming a new property "Support HTTP/2" makes it sound like the processor did not previously support HTTP/2, when it actually did. In the end, these are certainly just semantic differences. Although leaning toward "Disable HTTP/2", if you and @markap14 prefer "Support HTTP/2", that's fine.

@markap14
Copy link
Contributor

markap14 commented Feb 5, 2021

I think I would be in favor of Disable also but don't have a particularly strong opinion.

@thenatog
Copy link
Contributor Author

thenatog commented Feb 8, 2021

Updated to Disable HTTP/2 instead.

@exceptionfactory
Copy link
Contributor

Thanks for adjusting the property naming approach @thenatog. Built and tested. +1 Merging.

@asfgit asfgit closed this in 4ebeb4e Feb 8, 2021
driesva pushed a commit to driesva/nifi that referenced this pull request Mar 19, 2021
This closes apache#4804

Signed-off-by: David Handermann <exceptionfactory@apache.org>
krisztina-zsihovszki pushed a commit to krisztina-zsihovszki/nifi that referenced this pull request Jun 28, 2022
This closes apache#4804

Signed-off-by: David Handermann <exceptionfactory@apache.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants