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/04/21 13:22:47 UTC

[GitHub] [nifi-minifi-cpp] martinzink opened a new pull request, #1314: MINIFICPP-1808 Improve RawSocketProtocol authorization error logging

martinzink opened a new pull request, #1314:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1314

   Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
   
   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 MINIFICPP-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?
   
   ### For code changes:
   - [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the LICENSE file?
   - [ ] If applicable, have you updated the NOTICE file?
   
   ### For documentation related changes:
   - [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
   
   ### Note:
   Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
   


-- 
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-minifi-cpp] martinzink commented on a diff in pull request #1314: MINIFICPP-1808 Improve RawSocketProtocol authorization error logging

Posted by GitBox <gi...@apache.org>.
martinzink commented on code in PR #1314:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1314#discussion_r857406565


##########
libminifi/src/sitetosite/RawSocketProtocol.cpp:
##########
@@ -240,6 +240,12 @@ bool RawSiteToSiteClient::initiateCodecResourceNegotiation() {
   }
 }
 
+namespace {
+void logPortStateError(std::shared_ptr<core::logging::Logger>& logger, utils::Identifier port_id, const std::string& error) {

Review Comment:
   I trust the compiler and since its slightly more readable I've changed it (thanks for the suggestion) :+1: 
   https://github.com/apache/nifi-minifi-cpp/pull/1314/commits/deb192a736ab05fc942379c959d97a6657d9aae0



-- 
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-minifi-cpp] lordgamez commented on a diff in pull request #1314: MINIFICPP-1808 Improve RawSocketProtocol authorization error logging

Posted by GitBox <gi...@apache.org>.
lordgamez commented on code in PR #1314:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1314#discussion_r856154796


##########
libminifi/src/sitetosite/RawSocketProtocol.cpp:
##########
@@ -240,6 +240,12 @@ bool RawSiteToSiteClient::initiateCodecResourceNegotiation() {
   }
 }
 
+namespace {
+void logPortStateError(std::shared_ptr<core::logging::Logger>& logger, utils::Identifier port_id, const std::string& error) {

Review Comment:
   Would this may be simpler as a lambda inside `RawSiteToSiteClient::handShake`? We could lose 2 parameters that way.
   
   ```
   auto logPortStateError = [this](const std::string& error) { logger_->log_error("Site2Site HandShake Failed because destination port, %s, is %s", port_id_.to_string(), error); };
   ```



-- 
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-minifi-cpp] adam-markovics commented on a diff in pull request #1314: MINIFICPP-1808 Improve RawSocketProtocol authorization error logging

Posted by GitBox <gi...@apache.org>.
adam-markovics commented on code in PR #1314:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1314#discussion_r856315142


##########
libminifi/src/sitetosite/RawSocketProtocol.cpp:
##########
@@ -240,6 +240,12 @@ bool RawSiteToSiteClient::initiateCodecResourceNegotiation() {
   }
 }
 
+namespace {
+void logPortStateError(std::shared_ptr<core::logging::Logger>& logger, utils::Identifier port_id, const std::string& error) {

Review Comment:
   It's a dilemma to me. If it's a lambda, it has to be stored in a variable, that is allocated every time the function runs. Not a big performance issue BTW.



-- 
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-minifi-cpp] szaszm commented on a diff in pull request #1314: MINIFICPP-1808 Improve RawSocketProtocol authorization error logging

Posted by GitBox <gi...@apache.org>.
szaszm commented on code in PR #1314:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1314#discussion_r856416586


##########
libminifi/src/sitetosite/RawSocketProtocol.cpp:
##########
@@ -240,6 +240,12 @@ bool RawSiteToSiteClient::initiateCodecResourceNegotiation() {
   }
 }
 
+namespace {
+void logPortStateError(std::shared_ptr<core::logging::Logger>& logger, utils::Identifier port_id, const std::string& error) {

Review Comment:
   @adam-markovics that's going to be inlined and optimized out, no variable is created on the stack, unless you're using `-O0`.
   My concern is that it's more complex than the raw calls, but it's shorter as well, and it's all local, so it doesn't really matter. I'm neutral.



-- 
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-minifi-cpp] fgerlits commented on a diff in pull request #1314: MINIFICPP-1808 Improve RawSocketProtocol authorization error logging

Posted by GitBox <gi...@apache.org>.
fgerlits commented on code in PR #1314:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1314#discussion_r860805153


##########
libminifi/src/sitetosite/RawSocketProtocol.cpp:
##########
@@ -310,31 +310,32 @@ bool RawSiteToSiteClient::handShake() {
     }
   }
 
-  std::string error;
+  auto logPortStateError = [this](const std::string& error) {
+    logger_->log_error("Site2Site HandShake Failed because destination port, %s, is %s", port_id_.to_string(), error);
+  };
 
   switch (code) {
     case PROPERTIES_OK:
       logger_->log_debug("Site2Site HandShake Completed");
       peer_state_ = HANDSHAKED;
       return true;
     case PORT_NOT_IN_VALID_STATE:
-      error = "in invalid state";
-      break;
+      logPortStateError("in invalid state");
+      return false;
     case UNKNOWN_PORT:
-      error = "an unknown port";
-      break;
+      logPortStateError("an unknown port");
+      return false;
     case PORTS_DESTINATION_FULL:
-      error = "full";
-      break;
+      logPortStateError("full");
+      return false;
+    case UNAUTHORIZED:
+      logger_->log_error("Site2Site HandShake failed: UNAUTHORIZED");
+      return false;
     // Unknown error
     default:
       logger_->log_error("HandShake Failed because of unknown respond code %d", code);
       return false;

Review Comment:
   as discussed, we can leave it like this for now



-- 
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-minifi-cpp] fgerlits closed pull request #1314: MINIFICPP-1808 Improve RawSocketProtocol authorization error logging

Posted by GitBox <gi...@apache.org>.
fgerlits closed pull request #1314: MINIFICPP-1808 Improve RawSocketProtocol authorization error logging
URL: https://github.com/apache/nifi-minifi-cpp/pull/1314


-- 
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-minifi-cpp] fgerlits commented on a diff in pull request #1314: MINIFICPP-1808 Improve RawSocketProtocol authorization error logging

Posted by GitBox <gi...@apache.org>.
fgerlits commented on code in PR #1314:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1314#discussion_r859528263


##########
libminifi/src/sitetosite/RawSocketProtocol.cpp:
##########
@@ -310,31 +310,32 @@ bool RawSiteToSiteClient::handShake() {
     }
   }
 
-  std::string error;
+  auto logPortStateError = [this](const std::string& error) {
+    logger_->log_error("Site2Site HandShake Failed because destination port, %s, is %s", port_id_.to_string(), error);
+  };
 
   switch (code) {
     case PROPERTIES_OK:
       logger_->log_debug("Site2Site HandShake Completed");
       peer_state_ = HANDSHAKED;
       return true;
     case PORT_NOT_IN_VALID_STATE:
-      error = "in invalid state";
-      break;
+      logPortStateError("in invalid state");
+      return false;
     case UNKNOWN_PORT:
-      error = "an unknown port";
-      break;
+      logPortStateError("an unknown port");
+      return false;
     case PORTS_DESTINATION_FULL:
-      error = "full";
-      break;
+      logPortStateError("full");
+      return false;
+    case UNAUTHORIZED:
+      logger_->log_error("Site2Site HandShake failed: UNAUTHORIZED");
+      return false;
     // Unknown error
     default:
       logger_->log_error("HandShake Failed because of unknown respond code %d", code);
       return false;

Review Comment:
   these two could use `logPortStateError()`, too: knowing the port number could be useful in these cases, too
   
   also, I would remove the comment in line 334



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