You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/09/08 13:02:57 UTC

[GitHub] [nifi] bejancsaba opened a new pull request, #6375: NIFI-10458 Add support for the DESCRIBE/MANIFEST Operation

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

   <!-- Licensed to the Apache Software Foundation (ASF) under one or more -->
   <!-- contributor license agreements.  See the NOTICE file distributed with -->
   <!-- this work for additional information regarding copyright ownership. -->
   <!-- The ASF licenses this file to You under the Apache License, Version 2.0 -->
   <!-- (the "License"); you may not use this file except in compliance with -->
   <!-- the License.  You may obtain a copy of the License at -->
   <!--     http://www.apache.org/licenses/LICENSE-2.0 -->
   <!-- Unless required by applicable law or agreed to in writing, software -->
   <!-- distributed under the License is distributed on an "AS IS" BASIS, -->
   <!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
   <!-- See the License for the specific language governing permissions and -->
   <!-- limitations under the License. -->
   
   # Summary
   
   [NIFI-10458](https://issues.apache.org/jira/browse/NIFI-10458)
   
   With this change the DESCRIBE / MANIFEST capability was added to the MiNiFi Agent. This means that similarly to the C++ agent it can be controlled with the property "c2.full.heartbeat" whether the manifest (which is the biggest part of the heartbeat) is included or not. If the C2 server requires the manifest from the agent it can issue a DESCRIBE / MANIFEST operation which will be fulfilled in the acknowledgement. To notify the server about potential manifest changes the manifest hash is updated so the server can determine whether there was a change or not and whether it needs to request a DESCRIBE / MANIFEST.
   
   # 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 8
     - [ ] JDK 11
     - [ ] JDK 17
   
   ### Licensing
   
   - [ ] 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)
   - [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
   
   ### Documentation
   
   - [ ] 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] asfgit closed pull request #6375: NIFI-10458 Add support for the DESCRIBE/MANIFEST Operation

Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #6375: NIFI-10458 Add support for the DESCRIBE/MANIFEST Operation
URL: https://github.com/apache/nifi/pull/6375


-- 
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] bejancsaba commented on a diff in pull request #6375: NIFI-10458 Add support for the DESCRIBE/MANIFEST Operation

Posted by GitBox <gi...@apache.org>.
bejancsaba commented on code in PR #6375:
URL: https://github.com/apache/nifi/pull/6375#discussion_r969448783


##########
c2/c2-client-bundle/c2-client-service/src/main/java/org/apache/nifi/c2/client/service/C2HeartbeatFactory.java:
##########
@@ -225,4 +234,27 @@ private File getConfDirectory() {
 
         return confDirectory;
     }
+
+    private String calculateManifestHash(List<Bundle> loadedBundles) {

Review Comment:
   You are absolutely right. For now I would leave it as is and as soon as the next extension comes in we can extract the logic at that point. Are you ok with this approach?



-- 
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] ferencerdei commented on a diff in pull request #6375: NIFI-10458 Add support for the DESCRIBE/MANIFEST Operation

Posted by GitBox <gi...@apache.org>.
ferencerdei commented on code in PR #6375:
URL: https://github.com/apache/nifi/pull/6375#discussion_r968201180


##########
c2/c2-client-bundle/c2-client-service/src/main/java/org/apache/nifi/c2/client/service/C2HeartbeatFactory.java:
##########
@@ -225,4 +234,27 @@ private File getConfDirectory() {
 
         return confDirectory;
     }
+
+    private String calculateManifestHash(List<Bundle> loadedBundles) {

Review Comment:
   As more factors will come into play with the new C2 operation implementations, I think it would be better to separate this logic into a class.



-- 
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] bejancsaba commented on a diff in pull request #6375: NIFI-10458 Add support for the DESCRIBE/MANIFEST Operation

Posted by GitBox <gi...@apache.org>.
bejancsaba commented on code in PR #6375:
URL: https://github.com/apache/nifi/pull/6375#discussion_r966036354


##########
c2/c2-client-bundle/c2-client-service/src/main/java/org/apache/nifi/c2/client/service/C2HeartbeatFactory.java:
##########
@@ -225,4 +242,14 @@ private File getConfDirectory() {
 
         return confDirectory;
     }
+
+    public String calculateManifestHash(List<Bundle> loadedBundles) {
+        byte[] bytes = messageDigest.digest(loadedBundles.stream()

Review Comment:
   Thanks, updated



##########
c2/c2-client-bundle/c2-client-service/src/main/java/org/apache/nifi/c2/client/service/C2HeartbeatFactory.java:
##########
@@ -225,4 +242,14 @@ private File getConfDirectory() {
 
         return confDirectory;
     }
+
+    public String calculateManifestHash(List<Bundle> loadedBundles) {
+        byte[] bytes = messageDigest.digest(loadedBundles.stream()
+            .map(bundle -> bundle.getGroup() + bundle.getArtifact() + bundle.getVersion())
+            .sorted()
+            .collect(Collectors.joining(","))
+            .getBytes(StandardCharsets.UTF_8));
+
+        return UUID.nameUUIDFromBytes(bytes).toString();

Review Comment:
   Updated as requested



-- 
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 #6375: NIFI-10458 Add support for the DESCRIBE/MANIFEST Operation

Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on code in PR #6375:
URL: https://github.com/apache/nifi/pull/6375#discussion_r965958209


##########
c2/c2-client-bundle/c2-client-service/src/main/java/org/apache/nifi/c2/client/service/C2HeartbeatFactory.java:
##########
@@ -62,6 +69,12 @@ public class C2HeartbeatFactory {
     public C2HeartbeatFactory(C2ClientConfig clientConfig, FlowIdHolder flowIdHolder) {
         this.clientConfig = clientConfig;
         this.flowIdHolder = flowIdHolder;
+
+        try {
+            messageDigest = MessageDigest.getInstance("SHA-512");

Review Comment:
   Good choice of SHA-512.



##########
c2/c2-client-bundle/c2-client-service/src/main/java/org/apache/nifi/c2/client/service/C2HeartbeatFactory.java:
##########
@@ -225,4 +242,14 @@ private File getConfDirectory() {
 
         return confDirectory;
     }
+
+    public String calculateManifestHash(List<Bundle> loadedBundles) {
+        byte[] bytes = messageDigest.digest(loadedBundles.stream()

Review Comment:
   Although this specific use of `MessageDigest.digest(byte[] bytes)` should be safe, other reuse of the `MessageDigest` instance is not safe. It would be better to construct a new instance of `MessageDigest` for each invocation of `calculateManifestHash`.



##########
c2/c2-client-bundle/c2-client-service/src/main/java/org/apache/nifi/c2/client/service/C2HeartbeatFactory.java:
##########
@@ -225,4 +242,14 @@ private File getConfDirectory() {
 
         return confDirectory;
     }
+
+    public String calculateManifestHash(List<Bundle> loadedBundles) {
+        byte[] bytes = messageDigest.digest(loadedBundles.stream()
+            .map(bundle -> bundle.getGroup() + bundle.getArtifact() + bundle.getVersion())
+            .sorted()
+            .collect(Collectors.joining(","))
+            .getBytes(StandardCharsets.UTF_8));
+
+        return UUID.nameUUIDFromBytes(bytes).toString();

Review Comment:
   The `UUID.nameUUIDFromBytes()` leverages MD5 hashing internally, which effectively reduces precision of the SHA-512 hash. It would be better to use hexadecimal encoding of the SHA-512 digest bytes.



-- 
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] bejancsaba commented on pull request #6375: NIFI-10458 Add support for the DESCRIBE/MANIFEST Operation

Posted by GitBox <gi...@apache.org>.
bejancsaba commented on PR #6375:
URL: https://github.com/apache/nifi/pull/6375#issuecomment-1240789452

   > Thanks for this improvement @bejancsaba, without reviewing the substantive details, I provided a few comments on the hashing implementation.
   
   Thank you for taking a look addressed your hashing specific comments.


-- 
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