You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by bb...@apache.org on 2020/10/06 20:55:05 UTC

[geode-native] branch develop updated: GEODE-8569: Add missing method to ClientMessageDecoder (#663)

This is an automated email from the ASF dual-hosted git repository.

bbender pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode-native.git


The following commit(s) were added to refs/heads/develop by this push:
     new 496541a  GEODE-8569: Add missing method to ClientMessageDecoder (#663)
496541a is described below

commit 496541a5ebd9c50b7abf61d38ea91c981a37f1c3
Author: Blake Bender <bb...@pivotal.io>
AuthorDate: Tue Oct 6 13:54:54 2020 -0700

    GEODE-8569: Add missing method to ClientMessageDecoder (#663)
    
    - This would be called, and thus throw an exception, for client logs using AuthInitialize
    - Also added v10.0.3 to version lookup for regex function dispatcher.  Apparently we'd
      never tried to decode a v10.0.3 log before, go figure
    - geode-native only dumps up to 8KB of a message, then truncates, so
      just catch all exceptions reading a message and add an error message to
      the JSON output for that message
    
    Co-authored-by: Blake Bender <bb...@vmware.com>
---
 tools/gnmsg/client_message_decoder.py | 42 +++++++++++++++++++++++++++++++++--
 tools/gnmsg/client_messages.py        |  6 ++++-
 tools/gnmsg/server_message_decoder.py |  2 ++
 3 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/tools/gnmsg/client_message_decoder.py b/tools/gnmsg/client_message_decoder.py
index 86e1353..c9f9fb5 100644
--- a/tools/gnmsg/client_message_decoder.py
+++ b/tools/gnmsg/client_message_decoder.py
@@ -36,6 +36,7 @@ class ClientMessageDecoder(DecoderBase):
         self.send_trace_parts_retriever_ = None
         self.get_send_trace_parts_functions = {
             "0.0.42": self.get_send_trace_parts_base,
+            "10.0.3": self.get_send_trace_parts_base,
             "10.1.1": self.get_send_trace_parts_base,
             "10.1.2": self.get_send_trace_parts_base,
             "10.1.3": self.get_send_trace_parts_base,
@@ -43,12 +44,46 @@ class ClientMessageDecoder(DecoderBase):
         }
         self.send_trace_parsers = {
             "0.0.42": self.parse_request_fields_base,
+            "10.0.3": self.parse_request_fields_base,
             "10.1.1": self.parse_request_fields_base,
             "10.1.2": self.parse_request_fields_base,
             "10.1.3": self.parse_request_fields_base,
             "9.1.1": self.parse_request_fields_v911,
         }
-
+        #
+        # Native client code believes this is the list of messages that require a security footer.
+        # We will use this list to verify and report if a message is sent that needs one but doesn't
+        # have it, since this has been the source of at least one difficult-to-diagnose bug in the
+        # past.  To see the decision-making code that filters on this message list, look at
+        # ThinClientBaseDM::beforeSendingRequest and TcrMessage::isUserInitiativeOps in geode-native
+        # C++ code base.
+        self.message_requires_security_part = [
+            "ADD_PDX_ENUM",
+            "ADD_PDX_TYPE",
+            "CLIENT_READY",
+            "CLOSE_CONNECTION",
+            "COMMIT",
+            "GETCQSTATS_MSG_TYPE",
+            "GET_CLIENT_PARTITION_ATTRIBUTES",
+            "GET_CLIENT_PR_METADATA",
+            "GET_ENTRY",
+            "GET_FUNCTION_ATTRIBUTES",
+            "GET_PDX_ENUM_BY_ID",
+            "GET_PDX_ID_FOR_ENUM",
+            "GET_PDX_ID_FOR_TYPE",
+            "GET_PDX_TYPE_BY_ID",
+            "INVALID",
+            "MAKE_PRIMARY",
+            "MONITORCQ_MSG_TYPE",
+            "PERIODIC_ACK",
+            "PING",
+            "REQUEST_EVENT_VALUE",
+            "ROLLBACK"
+            "SIZE",
+            "TX_FAILOVER",
+            "TX_SYNCHRONIZATION",
+            "USER_CREDENTIAL_MESSAGE",
+        ]
     def search_for_version(self, line):
         if self.nc_version_ == None:
             expression = re.compile(r"Product version:.*Native (\d+)\.(\d+)\.(\d+)-")
@@ -160,6 +195,9 @@ class ClientMessageDecoder(DecoderBase):
         if self.send_trace_parser_ is not None:
             return self.send_trace_parser_(message_bytes)
 
+    def request_requires_security_footer(self, message_type):
+        return message_type in self.message_requires_security_part
+
     def process_line(self, line):
         connection = None
         is_send_trace = False
@@ -194,7 +232,7 @@ class ClientMessageDecoder(DecoderBase):
                     send_trace["SecurityFlag"],
                 ) = self.parse_request_fields(message_bytes)
                 if (send_trace["SecurityFlag"] == 1) and (
-                    self.request_requires_security_footer(send_trace["Type"])
+                    self.request_requires_security_footer(str(send_trace["Type"]))
                 ):
                     print(
                         "ERROR: Security flag is set, but no footer was added for this message!"
diff --git a/tools/gnmsg/client_messages.py b/tools/gnmsg/client_messages.py
index 6110f4a..6f8b9e1 100644
--- a/tools/gnmsg/client_messages.py
+++ b/tools/gnmsg/client_messages.py
@@ -410,4 +410,8 @@ client_message_parsers = {
 def parse_client_message(properties, message_bytes):
     offset = CHARS_IN_MESSAGE_HEADER
     if properties["Type"] in client_message_parsers.keys():
-        client_message_parsers[properties["Type"]](properties, message_bytes, offset)
+        try:
+            client_message_parsers[properties["Type"]](properties, message_bytes, offset)
+        except:
+            properties["ERROR"] = "Exception reading message - probably incomplete"
+            return
\ No newline at end of file
diff --git a/tools/gnmsg/server_message_decoder.py b/tools/gnmsg/server_message_decoder.py
index 2395a01..5c3eab5 100644
--- a/tools/gnmsg/server_message_decoder.py
+++ b/tools/gnmsg/server_message_decoder.py
@@ -36,6 +36,7 @@ class ServerMessageDecoder(DecoderBase):
         self.nc_version_ = None
         self.get_receive_trace_parts_functions_ = {
             "0.0.42": self.get_receive_trace_header_base,
+            "10.0.3": self.get_receive_trace_header_base,
             "10.1.1": self.get_receive_trace_header_base,
             "10.1.2": self.get_receive_trace_header_base,
             "10.1.3": self.get_receive_trace_header_base,
@@ -43,6 +44,7 @@ class ServerMessageDecoder(DecoderBase):
         }
         self.receive_trace_parsers_ = {
             "0.0.42": self.parse_response_fields_base,
+            "10.0.3": self.parse_response_fields_base,
             "10.1.1": self.parse_response_fields_base,
             "10.1.2": self.parse_response_fields_base,
             "10.1.3": self.parse_response_fields_base,