NIFI-9562: add 'archive' conflict resolution strategy to PutFile#5664
NIFI-9562: add 'archive' conflict resolution strategy to PutFile#5664markobean wants to merge 1 commit intoapache:mainfrom
Conversation
|
I am not supportive of this change as there is already a good and more flexible mechanism for users to setup their flows for this behavior. And notable the version of this processor pre Apache had all this bundled into a single mechanism. It was highly error prone and too limiting. The current model allows the user substantial flexibility in how they choose to handle conflicts, renaming, archive locations. In the current simpler form the user has a PutFile that if upon conflict they choose to fail. On fail they can route to a different PutFile whereby the filename is changed first and so on. You might suggest that 'fail' is not sufficient since there could be other types of failure like not enough disk space, etc.. and you want to know precisely that it failed due to a naming conflict. If so the simpler change is to add a conflict resolution of 'namingconflict' and route to such a relationship. But that distinction also in practice didn't turn out to be helpful. |
|
The option of changing the filename is not applicable to the use case in mind. Suppose a PutFile is writing an updated file used by a Controller Service. The Controller Service will reload the file when a change is detected, but it requires the filename to remain the same. Therefore, changing the filename upon PutFile failure and trying again is not possible in this scenario. Also, in the above use case, it is desirable to save (archive) the current file before replacing it. The archived file can be used as a fallback if the new file is corrupt or otherwise unusable. The archive also can provide a historical record of when a certain configuration changed. I'm not sure I follow the "error prone and too limiting". The rules as laid out seem pretty straight-forward. Can you further explain the concern or historical errors that occurred? Thanks. |
|
The JIRA and code just describe what you want to do not the why. In your last comment it sounds like the why (a specific use case) is more clear. If I follow correctly you have a case whereby you have a service which looks at a specific file and you periodically want to update that file. And whenever you do update the file you'd like to have the previous file saved somewhere in case an operator might want to rollback. Makes perfect sense. Without this change how that would be well accomplished is a flow that simply writes a copy of the new dataset to the archive location using PutFile. Then using another PutFile writes a copy of it to the actual target location. You can modify names, replace, etc.. all as you wish. The full power/flexibility of the existing mechanisms are available to the user. They're not limited by what renaming options you exposed in PutFile, etc.. Additionally we didn't have to make substantial changes to a high use Processor and add a new set of properties to it. Do the existing capabilities not address the use case you've laid out or another use case you've not yet mentioned? |
|
Your recommendation is exactly what we are currently performing. Specifically, writing the "new" file to a semi-permanent location prior to overwriting the existing file. So, the historical information is preserved, albeit prior to being "in use" by the controller service. Yet, this is perfectly adequate. The idea of incorporating the functionality into the PutFile processor itself is that it seemed a logical extension of the processor's capability. It seemed convenient to add the option to the processor especially since doing so is fully backward compatible with existing behavior. Also, it has the advantage of not duplicating data and archiving a copy if there was ever only a single file by that name, i.e. if there was no need for an archived copy. I'm still not clear on the words of caution you've brought up based on past experience. However, you are correct that a NiFi flow can be configured to accomplish nearly the same functionality. Also, it just occurred to me that performing this in a flow can result in archiving a file only once per cluster, but putting it in the processor itself means each node in the cluster would redundantly archive the file. |
Thank you for submitting a contribution to Apache NiFi.
Please provide a short description of the PR here:
Adds a conflict resolution strategy of "archive" for PutFile. Instead of overwriting an existing file or failing, the existing file is moved to an archive directory. The filename is optionally changed when it is archived. See the updated processor description and description of new properties for more details.
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
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.