-
Notifications
You must be signed in to change notification settings - Fork 98
NIFIREG-395 - Implemented the ability to import and export versioned flows through the UI #319
Conversation
…ioned flows through the UI. - Added REST endpoints in BucketFlowResource for importFlow, importVersionedFlow, exportVersionedFlow. - Added import and export dialogs.
This PR is still WIP, but is open for initial review. I still need to add integration tests and resolve some styling issues, specifically with text alignment in the dialogs. @exceptionfactory @thenatog @bbende @pvillard31 Would you please review? @scottyaslan @sardell @akocsis @andras Would you please review the frontend code? Thank you! |
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.
@mtien-apache nice work, this is going to be very helpful!
I left a few inline comments, but here are some overall results from testing with a secured registry where I authenticated with LDAP (i.e. using JWTs)...
Using JSON obtained from NiFi "Download flow definition"
- Initial import worked correctly
- Trying to import a second version of the flow resulted in an error "Version must be greater than zero, or use -1 to indicate latest version"
- Trying to download a version of the flow popped up the file download dialog with the name "versionedFlow", after clicking save Chrome showed a download for "versionedFlow.txt" and said "Failed - Needs authorization"
Using JSON obtained from another NiFi Registry (i.e. it had the snapshot metadata populated from the other registry):
- Import New Flow produced an error "No applicable policies could be found. Contact the system administrator.", I think because it was trying to store it based on the previous metadata that was never cleared out
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
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.
Thanks for the work on this feature @mtien-apache! Noted a few questions, will run through another review when it is no longer in draft status.
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Show resolved
Hide resolved
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
var version = this.selectedVersion; | ||
|
||
this.nfRegistryApi.exportDropletVersionedSnapshot(this.droplet.link.href, version).subscribe(function (response) { | ||
if (!response.status || response.status === 200) { |
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.
Does a false for response.status
also indicate a success? Not quite following the logic.
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.
@exceptionfactory A successful response has typically been just the response body returned. So, when the body is returned (a success) there will not be a status property. I can see how this could be confusing at first glance and without much context. This if-statement is used throughout the codebase, so I decided to follow the conventions.
.../webapp/components/explorer/grid-list/dialogs/import-new-flow/nf-registry-import-new-flow.js
Outdated
Show resolved
Hide resolved
nifi-registry-core/nifi-registry-web-ui/src/main/webapp/services/nf-registry.api.js
Outdated
Show resolved
Hide resolved
- Revised import REST endpoints that sets a new snapshot metadata to ensure previous Registry data is not used. - Refactored some logic from the export REST endpoint into the ServiceFacade. - Fixed the frontend download API endpoint to use the appropriate href data url.
I have pushed a commit that resolves the importing and exporting issues found by @bbende, as well as addressing other feedback found above this comment. Thanks for the first reviews, @bbende and @exceptionfactory ! |
This new functionality is great! It is going to be extremely useful. Here are some thoughts after some UI/UX testing:
|
Additional thoughts:
|
Testing how the feature does error handling and noticed the following: When importing new flow, if I select a JSON file that is valid JSON, but not a valid flow definition file, after selecting import I get the error message "Cannot create versioned flow snapshot - flowContents must not be null". After closing the dialog, it seems like nothing was imported, but if you refresh the view a new flow is imported with version 0. (As an aside, if you select "Download version" on this corrupt flow, the UI seems to open a dialog on the left side of the window.) |
Related to my last comment, here are the messages in the error dialogs I have found so far:
It would be great if we could make these error messages more user friendly. But that could definitely be done as a separate Jira/PR. I wouldn't block this PR to address this. |
@andrewmlim Thanks for reviewing!
|
Hey @mtien-apache - thanks for all your work on this. @andrewmlim 's comments all make sense to me and I would proceed with his recommendations. RE the Delete button color, yes the vibrant red is intentional as Drew observed. I believe this color is also used in other "delete" scenarios, so perhaps double-check to make sure color usage is consistent. |
@moranr Thanks for confirming - will proceed with the UI changes. @andrewmlim Confirmed the Delete button color is the same as other Delete buttons used throughout Registry (eg, Delete Buckets). |
…he Import dialogs. - Fixed the flow definition file upload input fields to handle text overflow. NIFIREG-395 - Address PR feedback. - Adjusted import dialog label names. - Updated exported file name and format. - Added messages to inform the user why the Import New Flow button is disabled.
…uploaded. - Refactored client side import file methods to directly pass the file to the server as an API param. - Refactored client side uploadFlow method to re-use BucketFlowResource.createFlow. - Removed BucketFlowResource.importFlow method. - Refactored logic in BucketFlowResource.importVersionedFlow to the service facade.
Pushed 2 commits:
UI changes:
|
Testing the latest changes and noticed that whenever I select "Import new version", the version is always shown as "v.2" in the "Import New Version" dialog even if is it the 3rd, 4th, 5th, etc. version that I am importing. |
I've seen the change where the name of the flow download is no longer always flow-version-#.json. But the name of the download defaults to the name of the process group defined in the flow definition not the name of the flow as I suggested in my earlier comments. For example, I import a new flow and give it the flow name "Kafka2HDFS" and select a flow definition file that has the name "ASDF" for the process group. This new flow is imported successfully. Within the NiFi Registry UI, there is nothing that references/displays "ASDF". But if I choose to download this flow version from Registry, the name of the file is "ASDF-version-1.json". I expected it to be "Kafka2HDFS-version-1.json". |
For the incomplete flow definition JSON file, the error I see now when importing is: "Unexpected end-of-input: expected close marker for Object (start marker at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 1]) at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 2, column: 1]" which is more specific to the issue (that there is no closing } in the JSON), but less readable. |
@andrewmlim I refactored the resource method to let the Spring framework to automatically handle the deserialization and removed the "Deserialization of uploaded JSON failed" message. Agree to improve the error message in a separate PR for the "Cannot create versioned flow snapshot - flowContents must not be null" message.
After investigating this exception message, it seems the exception is being caught by an Although I agree the error message could be better, it at least points to which line the error is found. I believe this is sufficient for the time being. Thoughts? |
I agree that it is sufficient for now. All of the error messages can be handled outside of this PR. Thanks! |
- Fixed Import New Version dialog to show the next version being imported. - Added frontend and backend integration tests. - Created ExportedVersionedFlowSnapshot object. - Added test resource file and updated rat configuration to skip the file during contrib-check. - Refactored frontend and server side code.
Pushed a commit:
Will add more frontend tests. |
@andrewmlim (cc: @moranr ) It seems like the initial focus behavior is based on keyboard actions and from an accessibility perspective, it's the expected behavior. When using the arrow keys, the focus moves with the new selection. I think what is making it confusing is that the keyboard and mouseover selections have the same red highlighting styles. I believe this highlighting behavior was always present but probably wasn't an issue since there had only been 1 menu item (Delete). One proposed fix is I can dig in to change the styles between a keyboard selection and mouseover selection, something like in other dropdown menus in Registry: Thoughts? |
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.
The recent updates look good @mtien-apache! I noted a few additional minor recommendations.
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
...gistry-web-api/src/main/java/org/apache/nifi/registry/web/service/StandardServiceFacade.java
Outdated
Show resolved
Hide resolved
...gistry-web-api/src/main/java/org/apache/nifi/registry/web/service/StandardServiceFacade.java
Outdated
Show resolved
Hide resolved
...istry-core/nifi-registry-web-api/src/test/java/org/apache/nifi/registry/web/api/FlowsIT.java
Outdated
Show resolved
Hide resolved
.../webapp/components/explorer/grid-list/dialogs/import-new-flow/nf-registry-import-new-flow.js
Outdated
Show resolved
Hide resolved
return this.http.get(url, options).pipe( | ||
map(function (response) { | ||
// export the VersionedFlowSnapshot by creating a hidden anchor element | ||
var stringSnapshot = encodeURIComponent(JSON.stringify(response.body, null, 2)); |
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 it necessary to call JSON.stringify()
or is it possible to just get the text content of response.body? If response.body
is already JSON, that means it went through an unnecessary serialization step, which would be great to avoid if possible.
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.
@exceptionfactory Good catch! I can return a responseType: 'text'
and omit calling JSON.stringify()
. The file content will not be in pretty print format but that seems ok to me.
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
Latest changes look good! One minor comment... when downloading a version, the window that pops up has the latest version labeled as "Latest Version (v.#)" but then the other items in the list are just "Version #", seems a little inconsistent that one has "v." and the others don't. Should the latest one just say "Latest Version (#)" or maybe "Version # (latest)" ? Also, while writing this, I started thinking about how we have generally been referring to this as import/export, and the buttons for import use the word "Import", but the for export we are calling it "Download Version". I'm not too hung up on this, but started wondering if that should be called "Export Version" to better correspond with "Import"? |
I tested a secure Registry with different authorizations given to users (on the users themselves and also on bucket policies). Auth looks good! |
I think the most consistent label would be "Latest (Version #)". "Export Version" is a good suggestion. Like Bryan, I don't think that change is critical. |
@mtien-apache I like that suggestion.
Also agree here, but not critical. Typically you see Upload/Download or Import/Export used in together. |
- Updated Flow Actions menu hover and focus styles. - Changed dialog title to 'Export Version', the latest menu item name, and renamed the component. - Disabled frontend export flows depending on read permissions. - Added and updated tests
Pushed commits that addresses all remaining changes and PR feedback. The PR is ready for a full review. Recent changes include:
|
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.
Thanks for working through the feedback details @mtien-apache! This looks just about good to go, I noted one more detail around the HTTP 201 Created response.
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Show resolved
Hide resolved
...nifi-registry-web-api/src/main/java/org/apache/nifi/registry/web/api/BucketFlowResource.java
Outdated
Show resolved
Hide resolved
These look good! Thanks for making all of these improvements @mtien-apache ! |
- Updated comments header
@mtien-apache I just finished looking at the UI code and testing your changes in the UI. Nice work. I'm a +1 (non-binding). |
Closed in favor of apache/nifi#5107 |
Thank you for submitting a contribution to Apache NiFi Registry.
Please provide a short description of the PR here:
Description of PR
[WIP] This PR adds the ability for a user to take a previously saved versionedFlowSnapshot JSON file and import it as a new flow definition to an existing bucket or import it as the next new version of an existing flow through the UI.
This PR also adds the ability to export a versionedFlowSnapshot as a JSON file, which removes snapshot metadata associated with the given Registry.
New dialogs have been created to handle import and export.
The REST endpoints added in
BucketFlowResource
are -importFlow
-/buckets/{bucketId}/flows/import
importVersionedFlow
-/buckets/{bucketId}/flows/{flowId}/versions/import
exportVersionedFlow
-/buckets/{bucketId}/flows/{flowId}/versions/{versionNumber: \d+}/export
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 NIFIREG-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:
mvn -Pcontrib-check clean install
at the rootnifi-registry
folder?LICENSE
file, including the mainLICENSE
file undernifi-registry-assembly
?NOTICE
file, including the mainNOTICE
file found undernifi-registry-assembly
?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.