You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by da...@apache.org on 2016/12/23 00:47:31 UTC

[2/6] kudu git commit: KUDU-1812. address comments on 1179bbdb

KUDU-1812. address comments on 1179bbdb

Change-Id: Ia6d4d1b76c0c24b3468c27f68354c44cb4223bc4
Reviewed-on: http://gerrit.cloudera.org:8080/5566
Tested-by: Kudu Jenkins
Reviewed-by: Adar Dembo <ad...@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/f3447a10
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/f3447a10
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/f3447a10

Branch: refs/heads/master
Commit: f3447a104fd5b6ca71122914838ea5f7d73c8efe
Parents: cef7b10
Author: Dan Burkert <da...@apache.org>
Authored: Thu Dec 22 11:14:09 2016 -0800
Committer: Dan Burkert <da...@apache.org>
Committed: Fri Dec 23 00:14:46 2016 +0000

----------------------------------------------------------------------
 src/kudu/client/client.h                 |  3 ++-
 src/kudu/client/write_op.h               |  3 ++-
 src/kudu/common/column_predicate-test.cc |  4 +++-
 src/kudu/common/partial_row.h            |  4 +++-
 src/kudu/common/partition-test.cc        |  2 +-
 src/kudu/common/types-test.cc            | 17 ++++++++++++++++-
 src/kudu/tools/tool_main.cc              | 10 +++++++---
 src/kudu/util/logging.h                  |  2 +-
 8 files changed, 35 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/f3447a10/src/kudu/client/client.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/client.h b/src/kudu/client/client.h
index 2cf5dbc..3c1f9b1 100644
--- a/src/kudu/client/client.h
+++ b/src/kudu/client/client.h
@@ -1924,7 +1924,8 @@ class KUDU_EXPORT KuduScanner {
 
   /// @return String representation of this scan.
   ///
-  /// @internal This method must not be used in log messages because it contains
+  /// @internal
+  /// @note This method must not be used in log messages because it contains
   ///   sensitive predicate values. Use Scanner::Data::DebugString instead.
   std::string ToString() const;
 

http://git-wip-us.apache.org/repos/asf/kudu/blob/f3447a10/src/kudu/client/write_op.h
----------------------------------------------------------------------
diff --git a/src/kudu/client/write_op.h b/src/kudu/client/write_op.h
index b4433e5..734ec31 100644
--- a/src/kudu/client/write_op.h
+++ b/src/kudu/client/write_op.h
@@ -76,7 +76,8 @@ class KUDU_EXPORT KuduWriteOperation {
 
   /// @return String representation of the operation.
   ///
-  /// @internal this method does *NOT* redact row values. The
+  /// @internal
+  /// @note this method does note redact row values. The
   ///   caller must handle redaction themselves, if necessary.
   virtual std::string ToString() const = 0;
  protected:

http://git-wip-us.apache.org/repos/asf/kudu/blob/f3447a10/src/kudu/common/column_predicate-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/column_predicate-test.cc b/src/kudu/common/column_predicate-test.cc
index 5c13cfa..9f56186 100644
--- a/src/kudu/common/column_predicate-test.cc
+++ b/src/kudu/common/column_predicate-test.cc
@@ -17,9 +17,11 @@
 
 #include "kudu/common/column_predicate.h"
 
+#include <vector>
+
+#include <gflags/gflags_declare.h>
 #include <glog/logging.h>
 #include <gtest/gtest.h>
-#include <vector>
 
 #include "kudu/common/schema.h"
 #include "kudu/common/types.h"

http://git-wip-us.apache.org/repos/asf/kudu/blob/f3447a10/src/kudu/common/partial_row.h
----------------------------------------------------------------------
diff --git a/src/kudu/common/partial_row.h b/src/kudu/common/partial_row.h
index 96f4d4b..adbed4f 100644
--- a/src/kudu/common/partial_row.h
+++ b/src/kudu/common/partial_row.h
@@ -459,7 +459,9 @@ class KUDU_EXPORT KuduPartialRow {
 
   /// @return String representation for the partial row.
   ///
-  /// @internal NOTE: this is not redacted.
+  /// @internal
+  /// @note this method does note redact row values. The
+  ///   caller must handle redaction themselves, if necessary.
   std::string ToString() const;
 
   /// @return The schema object for the partial row.

http://git-wip-us.apache.org/repos/asf/kudu/blob/f3447a10/src/kudu/common/partition-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/partition-test.cc b/src/kudu/common/partition-test.cc
index 5b2464c..d338a82 100644
--- a/src/kudu/common/partition-test.cc
+++ b/src/kudu/common/partition-test.cc
@@ -23,7 +23,7 @@
 #include <vector>
 
 #include <boost/optional.hpp>
-#include <gflags/gflags.h>
+#include <gflags/gflags_declare.h>
 
 #include "kudu/common/common.pb.h"
 #include "kudu/common/partial_row.h"

http://git-wip-us.apache.org/repos/asf/kudu/blob/f3447a10/src/kudu/common/types-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/types-test.cc b/src/kudu/common/types-test.cc
index 5e9f835..c297444 100644
--- a/src/kudu/common/types-test.cc
+++ b/src/kudu/common/types-test.cc
@@ -16,11 +16,13 @@
 // under the License.
 
 #include <cmath>
-#include <gtest/gtest.h>
 #include <string>
 #include <tuple>
 #include <vector>
 
+#include <gflags/gflags.h>
+#include <gtest/gtest.h>
+
 #include "kudu/common/types.h"
 #include "kudu/gutil/strings/substitute.h"
 #include "kudu/util/test_util.h"
@@ -32,6 +34,8 @@ using std::string;
 using std::tuple;
 using std::vector;
 
+DECLARE_bool(log_redact_user_data);
+
 namespace kudu {
 
 class TestTypes : public KuduTest {};
@@ -71,6 +75,17 @@ TEST_F(TestTypes, TestTimestampPrinting) {
   time = MathLimits<int64>::kMax;
   info->AppendDebugStringForValue(&time, &result);
   ASSERT_EQ("294247-01-10T04:00:54.775807Z", result);
+  result = "";
+
+  {
+    // Check that row values are redacted when the log_redact_user_data flag is set.
+    google::FlagSaver flag_saver;
+    FLAGS_log_redact_user_data = true;
+    time = 0;
+    info->AppendDebugStringForValue(&time, &result);
+    ASSERT_EQ("<redacted>", result);
+    result = "";
+  }
 }
 
 namespace {

http://git-wip-us.apache.org/repos/asf/kudu/blob/f3447a10/src/kudu/tools/tool_main.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tools/tool_main.cc b/src/kudu/tools/tool_main.cc
index 2d0533b..d48d95e 100644
--- a/src/kudu/tools/tool_main.cc
+++ b/src/kudu/tools/tool_main.cc
@@ -222,10 +222,14 @@ static bool ParseCommandLineFlags(int* argc, char*** argv) {
 }
 
 int main(int argc, char** argv) {
-  bool show_help = ParseCommandLineFlags(&argc, &argv);
   FLAGS_logtostderr = true;
-  // Disable redaction so that user data printed to the console will be shown in full.
-  FLAGS_log_redact_user_data = false;
+  bool show_help = ParseCommandLineFlags(&argc, &argv);
+
+  if (google::GetCommandLineFlagInfoOrDie("log_redact_user_data").is_default) {
+    // Disable redaction so that user data printed to the console will be shown in full.
+    FLAGS_log_redact_user_data = false;
+  }
+
   kudu::InitGoogleLoggingSafe(argv[0]);
   return kudu::tools::RunTool(argc, argv, show_help);
 }

http://git-wip-us.apache.org/repos/asf/kudu/blob/f3447a10/src/kudu/util/logging.h
----------------------------------------------------------------------
diff --git a/src/kudu/util/logging.h b/src/kudu/util/logging.h
index 9bdc370..18a8a3c 100644
--- a/src/kudu/util/logging.h
+++ b/src/kudu/util/logging.h
@@ -60,7 +60,7 @@
 // to short-circuit expensive logic.
 #define KUDU_SHOULD_REDACT() (FLAGS_log_redact_user_data && kudu::tls_redact_user_data)
 
-// Either evaluate and return 'expr', or return the string "redacted", depending on whether
+// Either evaluate and return 'expr', or return the string "<redacted>", depending on whether
 // redaction is enabled in the current scope.
 #define KUDU_REDACT(expr) \
   (KUDU_SHOULD_REDACT() ? kudu::kRedactionMessage : (expr))