-
Notifications
You must be signed in to change notification settings - Fork 366
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
PUT operation disrupt objects in case re-authentication is done #706
Comments
I analysed the problem a bit deeper and tried some strategies to fix the problem. However, based on the current implementation structure, I don't see an easy path without touching many parts. In particular for file and url payloads, the request entities would have to be reconstructed (to create a new InputStream). Currently, my feeling is that the quickest fix which prevents at least the current flawed behavior and has a simple, well-defined behaviour, is to add a check to all connector implementations of HttpExecutorServiceImpl.java which prevent a retry in case an entity is present and instead fail regularly due to invalid credentials, e.g.
I didn't yet create a PR because maybe someone with deeper os4j knowhow has a better proposal. Regards, |
I assume that this can be fixed using Expect: 100-continue. |
Can be enabled in httpclient via HttpClientFactory.registerInterceptor( new HttpClientConfigInterceptor() {
@Override
void onClientCreate(HttpClientBuilder client, RequestConfig.Builder requestConfig, Config config) {
requestConfig.expectContinueEnabled = true
}
}) |
Hi, using the 100-continue approach looks very interesting; but the coding above is connector specific (here HTTP connector), and cannot be easily enabled from the outside. Following this approach, I guess the clean way would be add a kind of "expectContinueEnabled" setting to org.openstack4j.core.transport.Config and handle it in the respective connectors accordingly. What do you think? Regards, |
@westenb afaik not all connectors support this. Okhttp has broken support since last year. |
Hi @westenb , this issue is present for OSClientV2 also? Or only for OSClientV3? Thanks. |
Hi @juliccr , as far as I understand, this issue is independent of the client version / openstack service, as this is part of the generic HTTP request/handling. The issue occurs whenever a request including a payload (InputStream) is done, and during the handling a re-authentication is occurring (e.g. due to token expiration). I believe this was already introduced when solving #45 long time ago, but apparently no one ran into the issue so far?! Regards, Eric |
Ok, thank you so much, @westenb , I'll try it out then ;) . Regards, Julián. |
@westenb closing this for now, please reopen if this issue is related to o4j |
Hello,
there seems to be severe issue with the re-authentication in combination with modifying requests (e.g. PUT) with InputStream payloads.
Scenario:
OSClient is created from a previously stored Token, and PUT operation is done (e.g. SWIFT file upload). If the Token is expired, the HttpExecutorServiceImpl (e.g. from the Jersey connector) will trigger a re-authentication and retry the request
However, the same Payload object is re-used as far as I can tell, which in case of an InputStream will be a stream which has been processed already during the first call. This leads in the case of uploading a file to SWIFT to the severe effect that the retry will succeed but create a file with content length 0 (in simple words: destroy the file). I believe the InputStream / Entity should be resetted before the Retry.
Is my analysis correct?
Regards,
Eric
PS: Maybe it would also make sense to remove this retry logic from the specific connectors, and have that at a central place.
The text was updated successfully, but these errors were encountered: