NIFI-8346 PutAzureBlobStorage doesn't route to failure despite the exception during upload#4917
NIFI-8346 PutAzureBlobStorage doesn't route to failure despite the exception during upload#4917adenes wants to merge 3 commits intoapache:mainfrom
Conversation
…ception during upload
|
@adenes Thanks for catching this. Is there an easy way to manually reproduce? |
jfrazee
left a comment
There was a problem hiding this comment.
@adenes Hey, in testing this I also noticed this fixes similar incorrect behavior when auth fails, so we should definitely get this in.
Would you be able to add a case for one or the other of these to the ITs? The auth one is probably easier since I think you'd just have to add a case re-setting AzureStorageUtils.ACCOUNT_KEY to something invalid.
|
@jfrazee , you can reproduce it with a simple flow (GFF -> PutAzureBlobStorage), just first you need to upload a blob to an Azure storage container and set its access tier to archive. Then if you try to put to that (existing) blob you'll see the |
|
@adenes Yeah, that's basically the flow I ended up running. |
Good point, thanks, will add a new test case for it. |
…ception during upload Add IT test case for PutAzureBlobStorage to test if in case of invalid credentials the FF is routed to failure
|
@jfrazee , I have added a new test case to test the invalid credentials scenario. |
| } catch (StorageException | URISyntaxException e) { | ||
| } catch (StorageException | URISyntaxException | IOException e) { | ||
| storedException.set(e); | ||
| throw new IOException(e); |
There was a problem hiding this comment.
I should have caught this before but we probably shouldn't double-wrap this.
| throw new IOException(e); | |
| throw (e instanceof IOException) ? (IOException) e : new IOException(e); |
| attributes.put("azure.timestamp", String.valueOf(properties.getLastModified())); | ||
| } catch (StorageException | URISyntaxException e) { | ||
| } catch (StorageException | URISyntaxException | IOException e) { | ||
| storedException.set(e); |
There was a problem hiding this comment.
Reviewing the larger context of this block, is there a reason to continue maintaining this reference to the storageException? The checked StorageException and URISyntaxException could be wrapped in the existing throw new IOException(). If there is a particular reason to evaluate or log the StorageException, that could be handled here, or in the outer catch block. Either way, it seems like it would be worth untangling the exception handling to avoid this kind of scenario down the road.
There was a problem hiding this comment.
@exceptionfactory, thanks for the comment. I have checked the bigger context, and although I agree that the storedException is not needed here, but when the original exception gets propagated to the outer catch block it's wrapped into a ProcessException by the framework.
This means that to get the original exception something like if (e instanceof ProcessException && e.getCause() instanceof IOException && e.getCause().getCause() != null)... would be needed.
In my opinion the current logic is cleaner and easier to understand.
There was a problem hiding this comment.
Thanks for the response @adenes. I was actually wondering whether that check for ProcessException in the outer catch block should be there at all. As it stands, anything that throws a ProcessException will keep FlowFiles in the queue instead of routing to failure. Perhaps that is the desired behavior with this particular Processor, but if it is not necessary, the exception handling could be generalized to avoid the instanceof check so that all exceptions result in routing to failure. I am fine with the changes as implemented now, but wanted to raise this question given the current issue with exception handling.
There was a problem hiding this comment.
I looked at the blame to see what the original intent is and it's not 100% clear. I have to assume then that REL_FAILURE is intended to be specifically for Blob Storage or Blob Storage operation failures and nothing else.
I think we should leave as-is for now. We really need to get back to #4430 or similar to get this on more current dependencies. We can probably (re)think through the "right" exception handling there.
There was a problem hiding this comment.
Thanks for the background @jfrazee, leaving it as-is for now sounds good.
…ception during upload Remove unnecessary wrapping of IOException
…ions This closes apache#4917 Signed-off-by: Joey Frazee <jfrazee@apache.org>
If uploading to an archived blob an IOException is thrown by the azure storage client library. If this happens the flowfile is not transferred to the failure relationship.
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
squashor use--forcewhen pushing to allow for clean monitoring of changes.For code changes:
mvn -Pcontrib-check clean installat the rootnififolder?LICENSEfile, including the mainLICENSEfile undernifi-assembly?NOTICEfile, including the mainNOTICEfile found undernifi-assembly?.displayNamein addition to .name (programmatic access) for each of the new properties?For documentation related changes:
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.