You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "greyp9 (via GitHub)" <gi...@apache.org> on 2023/04/13 23:44:17 UTC

[GitHub] [nifi] greyp9 opened a new pull request, #7173: NIFI-11439 - correct provenance reporting parameter

greyp9 opened a new pull request, #7173:
URL: https://github.com/apache/nifi/pull/7173

   In previous PR, missed adjustment of URL supplied to provenance reporting subsystem.
   
   # Summary
   
   [NIFI-11439](https://issues.apache.org/jira/browse/NIFI-11439)
   
   # Tracking
   
   Please complete the following tracking steps prior to pull request creation.
   
   ### Issue Tracking
   
   - [x] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI) issue created
   
   ### Pull Request Tracking
   
   - [x] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-00000`
   - [x] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-00000`
   
   ### Pull Request Formatting
   
   - [x] Pull Request based on current revision of the `main` branch
   - [x] Pull Request refers to a feature branch with one commit containing changes
   
   # Verification
   
   Please indicate the verification steps performed prior to pull request creation.
   
   ### Build
   
   - [x] Build completed using `mvn clean install -P contrib-check`
     - [x] JDK 11
     - [x] JDK 17
   
   ### Licensing
   
   - [x] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
   - [x] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [x] Documentation formatting appears as expected in rendered files
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory commented on a diff in pull request #7173: NIFI-11439 - correct provenance reporting parameter

Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory commented on code in PR #7173:
URL: https://github.com/apache/nifi/pull/7173#discussion_r1166213682


##########
nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/FetchGCSObject.java:
##########
@@ -273,7 +275,15 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
 
         final long millis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos);
         getLogger().info("Successfully retrieved GCS Object for {} in {} millis; routing to success", new Object[]{flowFile, millis});
-        session.getProvenanceReporter().fetch(flowFile, "https://" + bucketName + ".storage.googleapis.com/" + key, millis);
+
+        String transitUri;
+        try {
+            final URL url = new URL(storage.getOptions().getHost());
+            transitUri = String.format("%s://%s.%s/%s", url.getProtocol(), bucketName, url.getHost(), key);
+        } catch (MalformedURLException e) {
+            transitUri = e.getClass().getSimpleName();
+        }

Review Comment:
   Using `URI.create()` avoids the checked `MalformedURLException` and because the Storage API URL must be valid for making the request, recommend the following approach:
   ```suggestion
           final URI storageApiUri = URI.create(storage.getOptions().getHost());
           final String transitUri = String.format("%s://%s.%s/%s", uri,getScheme(), bucketName, uri.getHost(), key);
   ```



##########
nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/PutGCSObject.java:
##########
@@ -542,9 +544,15 @@ public void process(InputStream rawIn) throws IOException {
             }
             session.transfer(flowFile, REL_SUCCESS);
             final long millis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos);
-            final String url = "https://" + bucket + ".storage.googleapis.com/" + key;
 
-            session.getProvenanceReporter().send(flowFile, url, millis);
+            String transitUri;
+            try {
+                final URL url = new URL(storage.getOptions().getHost());
+                transitUri = String.format("%s://%s.%s/%s", url.getProtocol(), bucket, url.getHost(), key);
+            } catch (MalformedURLException e) {
+                transitUri = e.getClass().getSimpleName();
+            }

Review Comment:
   It seems like the implementation could be moved to a protected `getTransitUri()` method in `AbstractGCSProcessor`, or the changed could be implemented in both classes.
   ```suggestion
           final URI storageApiUri = URI.create(storage.getOptions().getHost());
           final String transitUri = String.format("%s://%s.%s/%s", uri,getScheme(), bucketName, uri.getHost(), key);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] greyp9 commented on a diff in pull request #7173: NIFI-11439 - correct provenance reporting parameter

Posted by "greyp9 (via GitHub)" <gi...@apache.org>.
greyp9 commented on code in PR #7173:
URL: https://github.com/apache/nifi/pull/7173#discussion_r1166843465


##########
nifi-nar-bundles/nifi-gcp-bundle/nifi-gcp-processors/src/main/java/org/apache/nifi/processors/gcp/storage/FetchGCSObject.java:
##########
@@ -273,7 +275,15 @@ public void onTrigger(final ProcessContext context, final ProcessSession session
 
         final long millis = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNanos);
         getLogger().info("Successfully retrieved GCS Object for {} in {} millis; routing to success", new Object[]{flowFile, millis});
-        session.getProvenanceReporter().fetch(flowFile, "https://" + bucketName + ".storage.googleapis.com/" + key, millis);
+
+        String transitUri;
+        try {
+            final URL url = new URL(storage.getOptions().getHost());
+            transitUri = String.format("%s://%s.%s/%s", url.getProtocol(), bucketName, url.getHost(), key);
+        } catch (MalformedURLException e) {
+            transitUri = e.getClass().getSimpleName();
+        }

Review Comment:
   Yep, that's better.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nifi] exceptionfactory closed pull request #7173: NIFI-11439 - correct provenance reporting parameter

Posted by "exceptionfactory (via GitHub)" <gi...@apache.org>.
exceptionfactory closed pull request #7173: NIFI-11439 - correct provenance reporting parameter
URL: https://github.com/apache/nifi/pull/7173


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org