You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pegasus.apache.org by "GehaFearless (via GitHub)" <gi...@apache.org> on 2024/02/21 14:16:23 UTC

[PR] refactor: optimize zookeeper cilent sasl init [incubator-pegasus]

GehaFearless opened a new pull request, #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914

   (no comment)


-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] refactor: optimize zookeeper client init for sasl [incubator-pegasus]

Posted by "acelyc111 (via GitHub)" <gi...@apache.org>.
acelyc111 commented on code in PR #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914#discussion_r1498553469


##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -158,27 +167,48 @@ int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
 {
     utils::auto_write_lock l(_watcher_lock);
     if (nullptr == _handle) {
-        if (FLAGS_enable_zookeeper_kerberos) {
+        if (utils::is_empty(FLAGS_sasl_mechanisms_type)) {

Review Comment:
   It's better to keep compatibility to retain FLAGS_enable_zookeeper_kerberos.
   
   Since FLAGS_sasl_mechanisms_type is newly introduced, you can validate the config relationship by DSN_DEFINE_group_validator().



##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -24,35 +24,44 @@
  * THE SOFTWARE.
  */
 
+#include <sasl/sasl.h>
 #include <stdlib.h>
 #include <zookeeper/zookeeper.h>
 #include <algorithm>
 #include <utility>
 
 #include "runtime/app_model.h"
 #include "runtime/rpc/rpc_address.h"
+#include "utils/filesystem.h"
 #include "utils/flags.h"
 #include "utils/fmt_logging.h"
+#include "utils/strings.h"
 #include "zookeeper/proto.h"
 #include "zookeeper/zookeeper.jute.h"
 #include "zookeeper_session.h"
 
-DSN_DECLARE_bool(enable_zookeeper_kerberos);
-DSN_DEFINE_string(security,
-                  zookeeper_kerberos_service_name,
-                  "zookeeper",
-                  "zookeeper kerberos service name");
-DSN_DEFINE_string(security,
-                  zookeeper_sasl_service_fqdn,
-                  "",
-                  "The FQDN of a Zookeeper server, used in Kerberos Principal");
 // TODO(yingchun): to keep compatibility, the global name is FLAGS_timeout_ms. The name is not very
 //  suitable, maybe improve the macro to us another global name.
 DSN_DEFINE_int32(zookeeper,
                  timeout_ms,
                  30000,
                  "The timeout of accessing ZooKeeper, in milliseconds");
 DSN_DEFINE_string(zookeeper, hosts_list, "", "Zookeeper hosts list");
+DSN_DEFINE_string(zookeeper, sasl_service_name, "zookeeper", "");
+DSN_DEFINE_string(zookeeper,
+                  sasl_service_fqdn,

Review Comment:
   How about keeping the config names to keep compatible? Otherwise uses have to update their config files when upgrade to new Pegasus version.



##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -158,27 +167,48 @@ int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
 {
     utils::auto_write_lock l(_watcher_lock);
     if (nullptr == _handle) {
-        if (FLAGS_enable_zookeeper_kerberos) {
+        if (utils::is_empty(FLAGS_sasl_mechanisms_type)) {
+            _handle = zookeeper_init(
+                FLAGS_hosts_list, global_watcher, FLAGS_timeout_ms, nullptr, this, 0);
+        } else {
+            int err = sasl_client_init(nullptr);

Review Comment:
   To improve the readability, you can reduce the indents, for example:
   ```
   utils::auto_write_lock l(_watcher_lock);
   if (nullptr != _handle) {
       return;
   }
   
   if (kerberos_is_disabled) {
      ...
      return;
   }
   
   int err = sasl_client_init(nullptr);
   ...
   ```



-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] refactor: optimize zookeeper client init for sasl [incubator-pegasus]

Posted by "GehaFearless (via GitHub)" <gi...@apache.org>.
GehaFearless commented on code in PR #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914#discussion_r1498729195


##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -158,27 +167,48 @@ int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
 {
     utils::auto_write_lock l(_watcher_lock);
     if (nullptr == _handle) {
-        if (FLAGS_enable_zookeeper_kerberos) {
+        if (utils::is_empty(FLAGS_sasl_mechanisms_type)) {

Review Comment:
   Limited impact, I will explain in the release notes



-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] refactor: optimize zookeeper client init for sasl [incubator-pegasus]

Posted by "GehaFearless (via GitHub)" <gi...@apache.org>.
GehaFearless commented on code in PR #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914#discussion_r1503576221


##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -24,35 +24,55 @@
  * THE SOFTWARE.
  */
 
+#include <sasl/sasl.h>
 #include <stdlib.h>
 #include <zookeeper/zookeeper.h>
 #include <algorithm>
 #include <utility>
 
 #include "runtime/app_model.h"
 #include "runtime/rpc/rpc_address.h"
+#include "utils/filesystem.h"
 #include "utils/flags.h"
 #include "utils/fmt_logging.h"
+#include "utils/strings.h"
 #include "zookeeper/proto.h"
 #include "zookeeper/zookeeper.jute.h"
 #include "zookeeper_session.h"
 
 DSN_DECLARE_bool(enable_zookeeper_kerberos);
-DSN_DEFINE_string(security,

Review Comment:
   https://github.com/apache/incubator-pegasus/commit/966c5b831d0a6b9742aea60786c46123f4a053bd
   
   There 2 conifgs just add at last month. And there is no issue involved. 
   Is it necessary to do this work? This leads to more difficult to read configurations.



-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] refactor: optimize zookeeper client init for sasl [incubator-pegasus]

Posted by "acelyc111 (via GitHub)" <gi...@apache.org>.
acelyc111 commented on code in PR #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914#discussion_r1498969590


##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -24,35 +24,44 @@
  * THE SOFTWARE.
  */
 
+#include <sasl/sasl.h>
 #include <stdlib.h>
 #include <zookeeper/zookeeper.h>
 #include <algorithm>
 #include <utility>
 
 #include "runtime/app_model.h"
 #include "runtime/rpc/rpc_address.h"
+#include "utils/filesystem.h"
 #include "utils/flags.h"
 #include "utils/fmt_logging.h"
+#include "utils/strings.h"
 #include "zookeeper/proto.h"
 #include "zookeeper/zookeeper.jute.h"
 #include "zookeeper_session.h"
 
-DSN_DECLARE_bool(enable_zookeeper_kerberos);
-DSN_DEFINE_string(security,
-                  zookeeper_kerberos_service_name,
-                  "zookeeper",
-                  "zookeeper kerberos service name");
-DSN_DEFINE_string(security,
-                  zookeeper_sasl_service_fqdn,
-                  "",
-                  "The FQDN of a Zookeeper server, used in Kerberos Principal");
 // TODO(yingchun): to keep compatibility, the global name is FLAGS_timeout_ms. The name is not very
 //  suitable, maybe improve the macro to us another global name.
 DSN_DEFINE_int32(zookeeper,
                  timeout_ms,
                  30000,
                  "The timeout of accessing ZooKeeper, in milliseconds");
 DSN_DEFINE_string(zookeeper, hosts_list, "", "Zookeeper hosts list");
+DSN_DEFINE_string(zookeeper, sasl_service_name, "zookeeper", "");
+DSN_DEFINE_string(zookeeper,
+                  sasl_service_fqdn,

Review Comment:
   Please describe the changes in commit description first, then when new version released, we can reference it or copied it directly.



-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] refactor: optimize zookeeper client init for sasl [incubator-pegasus]

Posted by "acelyc111 (via GitHub)" <gi...@apache.org>.
acelyc111 commented on code in PR #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914#discussion_r1499121703


##########
src/security/negotiation.cpp:
##########
@@ -31,6 +31,7 @@ DSN_DEFINE_bool(security,
                 enable_zookeeper_kerberos,
                 false,
                 "whether to enable kerberos for zookeeper client");
+DSN_TAG_VARIABLE(enable_zookeeper_kerberos, FT_MUTABLE);

Review Comment:
   Why change it to FT_MUTABLE, isn't it immutable after the zk session has been established?



##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -24,35 +24,56 @@
  * THE SOFTWARE.
  */
 
+#include <sasl/sasl.h>
 #include <stdlib.h>
 #include <zookeeper/zookeeper.h>
 #include <algorithm>
 #include <utility>
 
 #include "runtime/app_model.h"
 #include "runtime/rpc/rpc_address.h"
+#include "utils/filesystem.h"
 #include "utils/flags.h"
 #include "utils/fmt_logging.h"
+#include "utils/strings.h"
 #include "zookeeper/proto.h"
 #include "zookeeper/zookeeper.jute.h"
 #include "zookeeper_session.h"
 
 DSN_DECLARE_bool(enable_zookeeper_kerberos);
-DSN_DEFINE_string(security,
-                  zookeeper_kerberos_service_name,
-                  "zookeeper",
-                  "zookeeper kerberos service name");
-DSN_DEFINE_string(security,
-                  zookeeper_sasl_service_fqdn,
-                  "",
-                  "The FQDN of a Zookeeper server, used in Kerberos Principal");
 // TODO(yingchun): to keep compatibility, the global name is FLAGS_timeout_ms. The name is not very
 //  suitable, maybe improve the macro to us another global name.
 DSN_DEFINE_int32(zookeeper,
                  timeout_ms,
                  30000,
                  "The timeout of accessing ZooKeeper, in milliseconds");
 DSN_DEFINE_string(zookeeper, hosts_list, "", "Zookeeper hosts list");
+DSN_DEFINE_string(zookeeper, sasl_service_name, "zookeeper", "");
+DSN_DEFINE_string(zookeeper,
+                  sasl_service_fqdn,
+                  "",
+                  "SASL server name ('zk-sasl-md5' for DIGEST-MD5; default: reverse DNS lookup)");
+DSN_DEFINE_string(zookeeper,
+                  sasl_mechanisms_type,
+                  "",
+                  "SASL mechanisms (GSSAPI and/or DIGEST-MD5)");
+DSN_DEFINE_string(zookeeper, sasl_user_name, "", "");
+DSN_DEFINE_string(zookeeper, sasl_realm, "", "Realm (for SASL/GSSAPI)");
+DSN_DEFINE_string(zookeeper,
+                  sasl_password_file,
+                  "",
+                  "File containing the password (recommended for SASL/DIGEST-MD5)");
+DSN_TAG_VARIABLE(sasl_mechanisms_type, FT_MUTABLE);

Review Comment:
   Same, how can they be mutable?



##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -158,27 +167,48 @@ int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
 {
     utils::auto_write_lock l(_watcher_lock);
     if (nullptr == _handle) {
-        if (FLAGS_enable_zookeeper_kerberos) {
+        if (utils::is_empty(FLAGS_sasl_mechanisms_type)) {
+            _handle = zookeeper_init(
+                FLAGS_hosts_list, global_watcher, FLAGS_timeout_ms, nullptr, this, 0);
+        } else {
+            int err = sasl_client_init(nullptr);

Review Comment:
   Didn't update this?



-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] refactor: optimize zookeeper client init for sasl [incubator-pegasus]

Posted by "acelyc111 (via GitHub)" <gi...@apache.org>.
acelyc111 commented on code in PR #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914#discussion_r1503560900


##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -24,35 +24,55 @@
  * THE SOFTWARE.
  */
 
+#include <sasl/sasl.h>
 #include <stdlib.h>
 #include <zookeeper/zookeeper.h>
 #include <algorithm>
 #include <utility>
 
 #include "runtime/app_model.h"
 #include "runtime/rpc/rpc_address.h"
+#include "utils/filesystem.h"
 #include "utils/flags.h"
 #include "utils/fmt_logging.h"
+#include "utils/strings.h"
 #include "zookeeper/proto.h"
 #include "zookeeper/zookeeper.jute.h"
 #include "zookeeper_session.h"
 
 DSN_DECLARE_bool(enable_zookeeper_kerberos);
-DSN_DEFINE_string(security,

Review Comment:
   It's better to keep these configs, `sasl_service_name` and `sasl_service_fqdn` are acceptable to be added as well. You can:
   1. Check `zookeeper_kerberos_service_name` and `zookeeper_sasl_service_fqdn` must be empty, or they are equal to `sasl_service_name/fqdn`.
   2. Add "deprecated" to the description of the old configs.
   3. If the old configs are not empty, log warning logs to notify that they are deprecated.



-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] refactor: optimize zookeeper client init for sasl [incubator-pegasus]

Posted by "GehaFearless (via GitHub)" <gi...@apache.org>.
GehaFearless commented on code in PR #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914#discussion_r1500169776


##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -158,27 +167,48 @@ int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
 {
     utils::auto_write_lock l(_watcher_lock);
     if (nullptr == _handle) {
-        if (FLAGS_enable_zookeeper_kerberos) {
+        if (utils::is_empty(FLAGS_sasl_mechanisms_type)) {
+            _handle = zookeeper_init(
+                FLAGS_hosts_list, global_watcher, FLAGS_timeout_ms, nullptr, this, 0);
+        } else {
+            int err = sasl_client_init(nullptr);

Review Comment:
   Should I repeat the following code?
   
   https://github.com/apache/incubator-pegasus/pull/1914/files#:~:text=CHECK_NOTNULL(_handle%2C,zoo_state(_handle)%3B



-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] refactor: optimize zookeeper client init for sasl [incubator-pegasus]

Posted by "acelyc111 (via GitHub)" <gi...@apache.org>.
acelyc111 commented on code in PR #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914#discussion_r1503552270


##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -157,29 +177,58 @@ zookeeper_session::zookeeper_session(const service_app_info &node) : _handle(nul
 int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
 {
     utils::auto_write_lock l(_watcher_lock);
-    if (nullptr == _handle) {
-        if (FLAGS_enable_zookeeper_kerberos) {
-            zoo_sasl_params_t sasl_params = {0};
-            sasl_params.service = FLAGS_zookeeper_kerberos_service_name;
-            sasl_params.mechlist = "GSSAPI";
-            CHECK(dsn::rpc_address::from_host_port(FLAGS_zookeeper_sasl_service_fqdn),
-                  "zookeeper_sasl_service_fqdn {} is invalid",
-                  FLAGS_zookeeper_sasl_service_fqdn);
-            sasl_params.host = FLAGS_zookeeper_sasl_service_fqdn;
-            _handle = zookeeper_init_sasl(FLAGS_hosts_list,
-                                          global_watcher,
-                                          FLAGS_timeout_ms,
-                                          nullptr,
-                                          this,
-                                          0,
-                                          NULL,
-                                          &sasl_params);
-        } else {
+    do {
+        if (nullptr != _handle) {
+            break;
+        }
+        if (utils::is_empty(FLAGS_sasl_mechanisms_type)) {
             _handle = zookeeper_init(
                 FLAGS_hosts_list, global_watcher, FLAGS_timeout_ms, nullptr, this, 0);
+            break;
         }
-        CHECK_NOTNULL(_handle, "zookeeper session init failed");
-    }
+        int err = sasl_client_init(nullptr);
+        CHECK_EQ_MSG(err,
+                     SASL_OK,
+                     "Unable to initialize SASL library {}",
+                     sasl_errstring(err, nullptr, nullptr));
+
+        if (!utils::is_empty(FLAGS_sasl_password_file)) {
+            CHECK(utils::filesystem::file_exists(FLAGS_sasl_password_file),
+                  "sasl_password_file {} not exist!",
+                  FLAGS_sasl_password_file);
+        }
+
+        auto param_host = "";
+        if (!utils::is_empty(FLAGS_sasl_service_fqdn)) {
+            rpc_address addr;

Review Comment:
   ```suggestion
   ```



##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -157,29 +177,58 @@ zookeeper_session::zookeeper_session(const service_app_info &node) : _handle(nul
 int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
 {
     utils::auto_write_lock l(_watcher_lock);
-    if (nullptr == _handle) {
-        if (FLAGS_enable_zookeeper_kerberos) {
-            zoo_sasl_params_t sasl_params = {0};
-            sasl_params.service = FLAGS_zookeeper_kerberos_service_name;
-            sasl_params.mechlist = "GSSAPI";
-            CHECK(dsn::rpc_address::from_host_port(FLAGS_zookeeper_sasl_service_fqdn),
-                  "zookeeper_sasl_service_fqdn {} is invalid",
-                  FLAGS_zookeeper_sasl_service_fqdn);
-            sasl_params.host = FLAGS_zookeeper_sasl_service_fqdn;
-            _handle = zookeeper_init_sasl(FLAGS_hosts_list,
-                                          global_watcher,
-                                          FLAGS_timeout_ms,
-                                          nullptr,
-                                          this,
-                                          0,
-                                          NULL,
-                                          &sasl_params);
-        } else {
+    do {
+        if (nullptr != _handle) {
+            break;
+        }
+        if (utils::is_empty(FLAGS_sasl_mechanisms_type)) {
             _handle = zookeeper_init(
                 FLAGS_hosts_list, global_watcher, FLAGS_timeout_ms, nullptr, this, 0);
+            break;
         }
-        CHECK_NOTNULL(_handle, "zookeeper session init failed");
-    }
+        int err = sasl_client_init(nullptr);
+        CHECK_EQ_MSG(err,
+                     SASL_OK,
+                     "Unable to initialize SASL library {}",
+                     sasl_errstring(err, nullptr, nullptr));
+
+        if (!utils::is_empty(FLAGS_sasl_password_file)) {
+            CHECK(utils::filesystem::file_exists(FLAGS_sasl_password_file),
+                  "sasl_password_file {} not exist!",
+                  FLAGS_sasl_password_file);
+        }
+
+        auto param_host = "";
+        if (!utils::is_empty(FLAGS_sasl_service_fqdn)) {
+            rpc_address addr;
+            CHECK(dsn::rpc_address::from_host_port(FLAGS_sasl_service_fqdn),
+                  "sasl_service_fqdn {} is invalid",

Review Comment:
   ```suggestion
                     "sasl_service_fqdn '{}' is invalid",
   ```



-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] refactor: optimize zookeeper client init for sasl [incubator-pegasus]

Posted by "GehaFearless (via GitHub)" <gi...@apache.org>.
GehaFearless commented on code in PR #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914#discussion_r1498729195


##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -158,27 +167,48 @@ int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
 {
     utils::auto_write_lock l(_watcher_lock);
     if (nullptr == _handle) {
-        if (FLAGS_enable_zookeeper_kerberos) {
+        if (utils::is_empty(FLAGS_sasl_mechanisms_type)) {

Review Comment:
   Limited impact, I will explain in the release notes



##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -24,35 +24,44 @@
  * THE SOFTWARE.
  */
 
+#include <sasl/sasl.h>
 #include <stdlib.h>
 #include <zookeeper/zookeeper.h>
 #include <algorithm>
 #include <utility>
 
 #include "runtime/app_model.h"
 #include "runtime/rpc/rpc_address.h"
+#include "utils/filesystem.h"
 #include "utils/flags.h"
 #include "utils/fmt_logging.h"
+#include "utils/strings.h"
 #include "zookeeper/proto.h"
 #include "zookeeper/zookeeper.jute.h"
 #include "zookeeper_session.h"
 
-DSN_DECLARE_bool(enable_zookeeper_kerberos);
-DSN_DEFINE_string(security,
-                  zookeeper_kerberos_service_name,
-                  "zookeeper",
-                  "zookeeper kerberos service name");
-DSN_DEFINE_string(security,
-                  zookeeper_sasl_service_fqdn,
-                  "",
-                  "The FQDN of a Zookeeper server, used in Kerberos Principal");
 // TODO(yingchun): to keep compatibility, the global name is FLAGS_timeout_ms. The name is not very
 //  suitable, maybe improve the macro to us another global name.
 DSN_DEFINE_int32(zookeeper,
                  timeout_ms,
                  30000,
                  "The timeout of accessing ZooKeeper, in milliseconds");
 DSN_DEFINE_string(zookeeper, hosts_list, "", "Zookeeper hosts list");
+DSN_DEFINE_string(zookeeper, sasl_service_name, "zookeeper", "");
+DSN_DEFINE_string(zookeeper,
+                  sasl_service_fqdn,

Review Comment:
   Limited impact, I will explain in the release notes



-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] refactor: optimize zookeeper client init for sasl [incubator-pegasus]

Posted by "acelyc111 (via GitHub)" <gi...@apache.org>.
acelyc111 commented on code in PR #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914#discussion_r1500370713


##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -158,27 +167,48 @@ int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
 {
     utils::auto_write_lock l(_watcher_lock);
     if (nullptr == _handle) {
-        if (FLAGS_enable_zookeeper_kerberos) {
+        if (utils::is_empty(FLAGS_sasl_mechanisms_type)) {
+            _handle = zookeeper_init(
+                FLAGS_hosts_list, global_watcher, FLAGS_timeout_ms, nullptr, this, 0);
+        } else {
+            int err = sasl_client_init(nullptr);

Review Comment:
   I see, so how about this:
   ```
   utils::auto_write_lock l(_watcher_lock);
   do {
       if (nullptr != _handle) {
           break;
        }
   
       if (<kerberos_is_disabled>) {
           ...
           break;
       }
       
       int err = sasl_client_init(nullptr);
       ...
   } while (false);
   
   CHECK_NOTNULL(_handle, "zookeeper session init failed");
   ...
   
   ```



-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] refactor: optimize zookeeper client init for sasl [incubator-pegasus]

Posted by "acelyc111 (via GitHub)" <gi...@apache.org>.
acelyc111 commented on code in PR #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914#discussion_r1498554810


##########
src/zookeeper/zookeeper_session.cpp:
##########
@@ -158,27 +167,48 @@ int zookeeper_session::attach(void *callback_owner, const state_callback &cb)
 {
     utils::auto_write_lock l(_watcher_lock);
     if (nullptr == _handle) {
-        if (FLAGS_enable_zookeeper_kerberos) {
+        if (utils::is_empty(FLAGS_sasl_mechanisms_type)) {
+            _handle = zookeeper_init(
+                FLAGS_hosts_list, global_watcher, FLAGS_timeout_ms, nullptr, this, 0);
+        } else {
+            int err = sasl_client_init(nullptr);

Review Comment:
   To improve the readability, you can reduce the indents, for example:
   ```
   utils::auto_write_lock l(_watcher_lock);
   if (nullptr != _handle) {
       return;
   }
   
   if (<kerberos_is_disabled>) {
      ...
      return;
   }
   
   int err = sasl_client_init(nullptr);
   ...
   ```



-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org


Re: [PR] refactor: optimize zookeeper client init for sasl [incubator-pegasus]

Posted by "empiredan (via GitHub)" <gi...@apache.org>.
empiredan merged PR #1914:
URL: https://github.com/apache/incubator-pegasus/pull/1914


-- 
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: dev-unsubscribe@pegasus.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@pegasus.apache.org
For additional commands, e-mail: dev-help@pegasus.apache.org