-
Notifications
You must be signed in to change notification settings - Fork 21
Transparent proxy: TP Loader Cloud SDK native integration #981
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
base: main
Are you sure you want to change the base?
Conversation
b860033 to
cb21b31
Compare
...rvice/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyLoader.java
Outdated
Show resolved
Hide resolved
...rvice/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyLoader.java
Outdated
Show resolved
Hide resolved
...rvice/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyLoader.java
Outdated
Show resolved
Hide resolved
...rvice/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyLoader.java
Outdated
Show resolved
Hide resolved
...rvice/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyLoader.java
Outdated
Show resolved
Hide resolved
...rvice/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyLoader.java
Outdated
Show resolved
Hide resolved
...rvice/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyLoader.java
Outdated
Show resolved
Hide resolved
...rvice/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyLoader.java
Outdated
Show resolved
Hide resolved
...e/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxyLoaderTest.java
Show resolved
Hide resolved
bc1d50c to
f7ee4bd
Compare
|
@MatKuhr please review |
72dc4c1 to
70ee9ae
Compare
...vice/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultNetworkValidator.java
Outdated
Show resolved
Hide resolved
18db618 to
de06843
Compare
MatKuhr
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall approach looks good! Haven't looked at tests yet. The only essential question for me is, if we can/should perform an actual call to TP already during tryGetDestination.
...vice/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultNetworkValidator.java
Outdated
Show resolved
Hide resolved
...ion-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/NetworkValidator.java
Outdated
Show resolved
Hide resolved
...ion-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxy.java
Show resolved
Hide resolved
...vice/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DefaultNetworkValidator.java
Show resolved
Hide resolved
...ion-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxy.java
Outdated
Show resolved
Hide resolved
...ion-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxy.java
Outdated
Show resolved
Hide resolved
1f09efa to
dd731b9
Compare
628ae71 to
44ae3be
Compare
...ion-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxy.java
Outdated
Show resolved
Hide resolved
...ion-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxy.java
Outdated
Show resolved
Hide resolved
...ion-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxy.java
Outdated
Show resolved
Hide resolved
| Try<Destination> | ||
| tryGetDestination( @Nonnull final String destinationName, @Nonnull DestinationOptions options ) | ||
| { | ||
| final TransparentProxyDestination destination = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| final TransparentProxyDestination destination = | |
| if (!options.getOptionKeys().isEmpty()) { | |
| log.warn("DestinationOptions have been provided, but are not yet supported by the Transparent Proxy implementation and will be ignored."); | |
| } | |
| final TransparentProxyDestination destination = |
...ion-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/TransparentProxy.java
Outdated
Show resolved
Hide resolved
| final int statusCode = response.getStatusLine().getStatusCode(); | ||
|
|
||
| boolean destinationNotFound = false; | ||
| if( statusCode == HttpStatus.SC_BAD_GATEWAY ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if( statusCode == HttpStatus.SC_BAD_GATEWAY ) What does TP do, if the backend system itself responds with 504?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then there are no error headers so it wont enter in the conditions
| TransparentProxyDestination.gateway(destinationName, uri).build(); | ||
|
|
||
| if( isDestinationNotFound(destination, destinationName) ) { | ||
| return Try.failure(new DestinationAccessException("Destination not found: " + destinationName)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's critical that DestinationNotFoundException is thrown, otherwise the chain will not try further loaders.
| return Try.failure(new DestinationAccessException("Destination not found: " + destinationName)); | |
| return Try.failure(new DestinationNotFoundException("Destination '" + destinationName + "' could not be resolved for the current tenant " + tenant + " by Transparent Proxy running on " + uri)); |
Also, we should include more information in the exception, otherwise users have little information for troubleshooting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to DestinationNotFoundException. Message would be retrieved from TP "X-Error-Message" header:
"Destination 'google44' not found in tenant 'tp-integration-tests-8imc9i7e'. Contact the Destination Administrator."
or if fragment exists
Destination 'google' with fragment 'blalala' not found in tenant 'tp-integration-tests-8imc9i7e'. Contact the Destination Administrator.
if these are okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep that sounds good!
Does the TP allow the tenant to be null by the way? If not, we may have an issue, because the Cloud SDK generally allows this
| boolean destinationNotFound = false; | ||
| if( statusCode == HttpStatus.SC_BAD_GATEWAY ) { | ||
| final String errorInternalCode = getHeaderValue(response, X_ERROR_INTERNAL_CODE_HEADER); | ||
| if( Integer.toString(HttpStatus.SC_NOT_FOUND).equals(errorInternalCode) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there also a dedicated error code in case the destination was found, but the authToken contains an error? If so, we could also directly throw a DestinationAccessException in that case, because that is also how the standard implementation behaves.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not dedicated, but it is covered in current impl and throws DestinationAccessException in that case.
Also we are using TP error headers to return more detailed error message including Origin and TP error message
5971ceb to
e2d8139
Compare
e2d8139 to
c6e4756
Compare
No description provided.