diff --git a/conf/mds.conf b/conf/mds.conf index cc8c661e0d..1e1a7eb273 100644 --- a/conf/mds.conf +++ b/conf/mds.conf @@ -21,10 +21,6 @@ mds.etcd.retry.times=3 mds.etcd.dlock.timeoutMs=10000 # dlock lease timeout mds.etcd.dlock.ttlSec=10 -# etcd auth options -etcd.auth.enable=false -etcd.auth.username= -etcd.auth.password= # # segment分配量统计相关配置 diff --git a/conf/snapshot_clone_server.conf b/conf/snapshot_clone_server.conf index 1c043686cd..d4fdf2b64c 100644 --- a/conf/snapshot_clone_server.conf +++ b/conf/snapshot_clone_server.conf @@ -86,11 +86,6 @@ etcd.retry.times=3 etcd.dlock.timeoutMs=10000 # dlock lease timeout etcd.dlock.ttlSec=10 -# etcd auth options -etcd.auth.enable=false -etcd.auth.username= -etcd.auth.password= - # # leader选举相关参数 diff --git a/curvefs/conf/mds.conf b/curvefs/conf/mds.conf index 41a5aae45f..0c28d89946 100644 --- a/curvefs/conf/mds.conf +++ b/curvefs/conf/mds.conf @@ -35,10 +35,6 @@ etcd.dailtimeoutMs=5000 etcd.operation.timeoutMs=5000 # number of times a failed operation can be retried etcd.retry.times=3 -# etcd auth options -etcd.auth.enable=false -etcd.auth.username= -etcd.auth.password= # # leader election options diff --git a/curvefs/docker/debian11/Dockerfile b/curvefs/docker/debian11/Dockerfile index 7a0fc90e61..9ea3ca5c1c 100644 --- a/curvefs/docker/debian11/Dockerfile +++ b/curvefs/docker/debian11/Dockerfile @@ -1,7 +1,6 @@ FROM opencurvedocker/curve-base:debian11 -COPY libmemcached.so libmemcached.so.11 libhashkit.so.2 libetcdclient.so /usr/lib/ +COPY libmemcached.so libmemcached.so.11 libhashkit.so.2 /usr/lib/ COPY curvefs /curvefs RUN mkdir -p /etc/curvefs /core /etc/curve && chmod a+x /entrypoint.sh \ && cp /curvefs/tools/sbin/curvefs_tool /usr/bin \ - && cp /curvefs/etcd/sbin/etcdctl /usr/bin/ \ && cp /curvefs/tools-v2/sbin/curve /usr/bin/ diff --git a/curvefs/src/mds/mds.cpp b/curvefs/src/mds/mds.cpp index f67791a9b0..6e5d8644b5 100644 --- a/curvefs/src/mds/mds.cpp +++ b/curvefs/src/mds/mds.cpp @@ -58,9 +58,7 @@ MDS::MDS() etcdClient_(), leaderElection_(), status_(), - etcdEndpoint_(), - etcdUsername_(), - etcdPassword_() {} + etcdEndpoint_() {} MDS::~MDS() {} @@ -357,8 +355,7 @@ void MDS::InitEtcdClient() { << ", etcd address: " << std::string(etcdConf.Endpoints, etcdConf.len) << ", etcdtimeout: " << etcdConf.DialTimeout << ", operation timeout: " << etcdTimeout - << ", etcd retrytimes: " << etcdRetryTimes - << ", etcd auth enable: " << etcdConf.authEnable; + << ", etcd retrytimes: " << etcdRetryTimes; LOG_IF(FATAL, !CheckEtcd()) << "Check etcd failed"; @@ -366,32 +363,20 @@ void MDS::InitEtcdClient() { << std::string(etcdConf.Endpoints, etcdConf.len) << ", etcdtimeout: " << etcdConf.DialTimeout << ", operation timeout: " << etcdTimeout - << ", etcd retrytimes: " << etcdRetryTimes - << ", etcd auth enable: " << etcdConf.authEnable; + << ", etcd retrytimes: " << etcdRetryTimes; etcdClientInited_ = true; } void MDS::InitEtcdConf(EtcdConf* etcdConf) { conf_->GetValueFatalIfFail("etcd.endpoint", &etcdEndpoint_); - etcdConf->len = etcdEndpoint_.size(); - etcdConf->Endpoints = &etcdEndpoint_[0]; conf_->GetValueFatalIfFail("etcd.dailtimeoutMs", &etcdConf->DialTimeout); - // etcd auth config - bool authEnable = false; - conf_->GetBoolValue("etcd.auth.enable", &authEnable); - etcdConf->authEnable = authEnable ? 1 : 0; - if (authEnable) { - conf_->GetValueFatalIfFail("etcd.auth.username", &etcdUsername_); - etcdConf->username = &etcdUsername_[0]; - etcdConf->usernameLen = etcdUsername_.size(); - conf_->GetValueFatalIfFail("etcd.auth.password", &etcdPassword_); - etcdConf->password = &etcdPassword_[0]; - etcdConf->passwordLen = etcdPassword_.size(); - } LOG(INFO) << "etcd.endpoint: " << etcdEndpoint_; LOG(INFO) << "etcd.dailtimeoutMs: " << etcdConf->DialTimeout; + + etcdConf->len = etcdEndpoint_.size(); + etcdConf->Endpoints = &etcdEndpoint_[0]; } bool MDS::CheckEtcd() { diff --git a/curvefs/src/mds/mds.h b/curvefs/src/mds/mds.h index 9c9c8cbadc..52df06388c 100644 --- a/curvefs/src/mds/mds.h +++ b/curvefs/src/mds/mds.h @@ -181,8 +181,6 @@ class MDS { bvar::Status status_; std::string etcdEndpoint_; - std::string etcdUsername_; - std::string etcdPassword_; }; } // namespace mds diff --git a/docker/debian11/Dockerfile b/docker/debian11/Dockerfile index c6f086eb31..59d21881b1 100644 --- a/docker/debian11/Dockerfile +++ b/docker/debian11/Dockerfile @@ -13,10 +13,8 @@ RUN cd /curve-tgt/curve-sdk && \ make install-programs && \ rm -rf /curve-tgt COPY curvebs /curvebs -COPY libetcdclient.so /usr/lib/ RUN mkdir -p /etc/curve /etc/nebd /curve/init.d/ && \ chmod a+x /entrypoint.sh && \ cp /curvebs/nbd/sbin/curve-nbd /usr/bin/ && \ cp /curvebs/tools/sbin/curve_ops_tool /usr/bin/ && \ - cp /curvebs/etcd/sbin/etcdctl /usr/bin/ && \ cp /curvebs/tools-v2/sbin/curve /usr/bin/ diff --git a/src/chunkserver/chunkserver.cpp b/src/chunkserver/chunkserver.cpp index 22f302c9da..398e938240 100644 --- a/src/chunkserver/chunkserver.cpp +++ b/src/chunkserver/chunkserver.cpp @@ -111,6 +111,7 @@ int ChunkServer::Run(int argc, char** argv) { // 打印参数 conf.PrintConfig(); + conf.ExposeMetric("chunkserver_config"); curve::common::ExposeCurveVersion(); // ============================初始化各模块==========================// diff --git a/src/mds/server/mds.cpp b/src/mds/server/mds.cpp index 272bc9609f..62d7b3e2bd 100644 --- a/src/mds/server/mds.cpp +++ b/src/mds/server/mds.cpp @@ -45,6 +45,9 @@ using ::curve::common::BLOCKSIZEKEY; using ::curve::common::CHUNKSIZEKEY; MDS::~MDS() { + if (etcdEndpoints_) { + delete etcdEndpoints_; + } if (fileLockManager_) { delete fileLockManager_; } @@ -199,23 +202,14 @@ void MDS::Stop() { } void MDS::InitEtcdConf(EtcdConf* etcdConf) { - conf_->GetValueFatalIfFail("mds.etcd.endpoint", &etcdEndpoints_); - etcdConf->len = etcdEndpoints_.size(); - etcdConf->Endpoints = &etcdEndpoints_[0]; + std::string endpoint; + conf_->GetValueFatalIfFail("mds.etcd.endpoint", &endpoint); + etcdEndpoints_ = new char[endpoint.size()]; + etcdConf->Endpoints = etcdEndpoints_; + std::memcpy(etcdConf->Endpoints, endpoint.c_str(), endpoint.size()); + etcdConf->len = endpoint.size(); conf_->GetValueFatalIfFail( "mds.etcd.dailtimeoutMs", &etcdConf->DialTimeout); - // etcd auth config - bool authEnable = false; - conf_->GetBoolValue("etcd.auth.enable", &authEnable); - etcdConf->authEnable = authEnable ? 1 : 0; - if (authEnable) { - conf_->GetValueFatalIfFail("etcd.auth.username", &etcdUsername_); - etcdConf->username = &etcdUsername_[0]; - etcdConf->usernameLen = etcdUsername_.size(); - conf_->GetValueFatalIfFail("etcd.auth.password", &etcdPassword_); - etcdConf->password = &etcdPassword_[0]; - etcdConf->passwordLen = etcdPassword_.size(); - } } void MDS::StartServer() { @@ -267,8 +261,7 @@ void MDS::InitEtcdClient(const EtcdConf& etcdConf, << ", etcdaddr len: " << etcdConf.len << ", etcdtimeout: " << etcdConf.DialTimeout << ", operation timeout: " << etcdTimeout - << ", etcd retrytimes: " << retryTimes - << ", auth enable = " << etcdConf.authEnable; + << ", etcd retrytimes: " << retryTimes; std::string out; @@ -282,8 +275,7 @@ void MDS::InitEtcdClient(const EtcdConf& etcdConf, << ", etcdaddr len: " << etcdConf.len << ", etcdtimeout: " << etcdConf.DialTimeout << ", operation timeout: " << etcdTimeout - << ", etcd retrytimes: " << retryTimes - << ", auth enable = " << etcdConf.authEnable; + << ", etcd retrytimes: " << retryTimes; } void MDS::InitLeaderElection(const LeaderElectionOptions& leaderElectionOp) { diff --git a/src/mds/server/mds.h b/src/mds/server/mds.h index 1f2ed529ed..6dafbc056a 100644 --- a/src/mds/server/mds.h +++ b/src/mds/server/mds.h @@ -235,11 +235,9 @@ class MDS { std::shared_ptr cleanDiscardSegmentTask_; std::shared_ptr coordinator_; std::shared_ptr heartbeatManager_; + char* etcdEndpoints_; FileLockManager* fileLockManager_; std::shared_ptr snapshotCloneClient_; - std::string etcdEndpoints_; - std::string etcdUsername_; - std::string etcdPassword_; }; bool ParsePoolsetRules(const std::string& str, diff --git a/src/snapshotcloneserver/snapshotclone_server.cpp b/src/snapshotcloneserver/snapshotclone_server.cpp index be92a61d9d..91a6c199e7 100644 --- a/src/snapshotcloneserver/snapshotclone_server.cpp +++ b/src/snapshotcloneserver/snapshotclone_server.cpp @@ -115,31 +115,21 @@ void InitSnapshotCloneServerOptions(std::shared_ptr conf, &(serverOption->dlockOpts.ttlSec)); } -void SnapShotCloneServer::InitEtcdConf(EtcdConf* etcdConf) { - conf_->GetValueFatalIfFail("etcd.endpoint", &etcdEndpoints_); - etcdConf->len = etcdEndpoints_.size(); - etcdConf->Endpoints = &etcdEndpoints_[0]; - conf_->GetValueFatalIfFail( - "etcd.dailtimeoutMs", &etcdConf->DialTimeout); - // etcd auth config - bool authEnable = false; - conf_->GetBoolValue("etcd.auth.enable", &authEnable); - etcdConf->authEnable = authEnable ? 1 : 0; - if (authEnable) { - conf_->GetValueFatalIfFail("etcd.auth.username", &etcdUsername_); - etcdConf->username = &etcdUsername_[0]; - etcdConf->usernameLen = etcdUsername_.size(); - conf_->GetValueFatalIfFail("etcd.auth.password", &etcdPassword_); - etcdConf->password = &etcdPassword_[0]; - etcdConf->passwordLen = etcdPassword_.size(); - } +void InitEtcdConf(std::shared_ptr conf, EtcdConf* etcdConf) { + std::string endpoint; + conf->GetValueFatalIfFail("etcd.endpoint", &endpoint); + char* etcdEndpoints_ = new char[endpoint.size()]; + etcdConf->Endpoints = etcdEndpoints_; + std::memcpy(etcdConf->Endpoints, endpoint.c_str(), endpoint.size()); + etcdConf->len = endpoint.size(); + conf->GetValueFatalIfFail("etcd.dailtimeoutMs", &etcdConf->DialTimeout); } void SnapShotCloneServer::InitAllSnapshotCloneOptions(void) { InitClientOption(conf_, &(snapshotCloneServerOptions_.clientOptions)); InitSnapshotCloneServerOptions(conf_, &(snapshotCloneServerOptions_.serverOption)); - InitEtcdConf(&(snapshotCloneServerOptions_.etcdConf)); + InitEtcdConf(conf_, &(snapshotCloneServerOptions_.etcdConf)); conf_->GetValueFatalIfFail("etcd.operation.timeoutMs", &(snapshotCloneServerOptions_.etcdClientTimeout)); diff --git a/src/snapshotcloneserver/snapshotclone_server.h b/src/snapshotcloneserver/snapshotclone_server.h index cb9a35d086..47163ddac4 100644 --- a/src/snapshotcloneserver/snapshotclone_server.h +++ b/src/snapshotcloneserver/snapshotclone_server.h @@ -122,7 +122,6 @@ class SnapShotCloneServer { void RunUntilQuit(void); private: - void InitEtcdConf(EtcdConf* etcdConf); bool InitEtcdClient(void); private: @@ -154,12 +153,7 @@ class SnapShotCloneServer { std::shared_ptr cloneServiceManager_; std::shared_ptr service_; std::shared_ptr server_; - - std::string etcdEndpoints_; - std::string etcdUsername_; - std::string etcdPassword_; }; - } // namespace snapshotcloneserver } // namespace curve diff --git a/src/tools/metric_name.h b/src/tools/metric_name.h index 3f85d971a4..d284694aba 100644 --- a/src/tools/metric_name.h +++ b/src/tools/metric_name.h @@ -37,7 +37,7 @@ const char kCurveVersionMetricName[] = "curve_version"; // snapshot clone server metric name const char kSnapshotCloneConfMetricName[] = - "snapshot_clone_server_config_server_address"; + "snapshotcloneserver_config_server_address"; const char kSnapshotCloneStatusMetricName[] = "snapshotcloneserver_status"; const char kSnapshotCloneStatusActive[] = "active"; diff --git a/thirdparties/etcdclient/etcdclient.go b/thirdparties/etcdclient/etcdclient.go index 355e99b162..dc7df6d691 100644 --- a/thirdparties/etcdclient/etcdclient.go +++ b/thirdparties/etcdclient/etcdclient.go @@ -68,11 +68,6 @@ struct EtcdConf { char *Endpoints; int len; int DialTimeout; - int authEnable; - char *username; - int usernameLen; - char *password; - int passwordLen; }; struct Operation { @@ -204,22 +199,16 @@ func GetErrCode(op string, err error) C.enum_EtcdErrCode { } // TODO(lixiaocui): 日志打印看是否需要glog -// //export NewEtcdClientV3 func NewEtcdClientV3(conf C.struct_EtcdConf) C.enum_EtcdErrCode { var err error - cfg := clientv3.Config{ + globalClient, err = clientv3.New(clientv3.Config{ Endpoints: GetEndpoint(C.GoStringN(conf.Endpoints, conf.len)), DialTimeout: time.Duration(int(conf.DialTimeout)) * time.Millisecond, DialOptions: []grpc.DialOption{grpc.WithBlock()}, DialKeepAliveTime: time.Second, DialKeepAliveTimeout: time.Second, - } - if conf.authEnable == 1 { - cfg.Username = C.GoStringN(conf.username, conf.usernameLen) - cfg.Password = C.GoStringN(conf.password, conf.passwordLen) - } - globalClient, err = clientv3.New(cfg) + }) return GetErrCode(EtcdNewClient, err) } @@ -283,7 +272,6 @@ func EtcdClientGet(timeout C.int, key *C.char, } // TODO(lixiaocui): list可能需要有长度限制 -// //export EtcdClientList func EtcdClientList(timeout C.int, startKey, endKey *C.char, startLen, endLen C.int) (C.enum_EtcdErrCode, uint64, int64) { @@ -665,12 +653,12 @@ func EtcdMutexLock(timeout C.int, id C.int64_t) C.enum_EtcdErrCode { //export EtcdMutexUnlock func EtcdMutexUnlock(timeout C.int, id C.int64_t) C.enum_EtcdErrCode { - ctx, cancel := context.WithTimeout(context.Background(), - time.Duration(int(timeout))*time.Millisecond) - defer cancel() + ctx, cancel := context.WithTimeout(context.Background(), + time.Duration(int(timeout))*time.Millisecond) + defer cancel() - err := etcdMutex[clientv3.LeaseID(id)].Unlock(ctx) - return GetErrCode(EtcdUnlock, err) + err := etcdMutex[clientv3.LeaseID(id)].Unlock(ctx) + return GetErrCode(EtcdUnlock, err) } //export DestoryEtcdMutex diff --git a/util/install.sh b/util/install.sh index b33bf00025..bb67318928 100755 --- a/util/install.sh +++ b/util/install.sh @@ -338,11 +338,10 @@ main() { elif [ "$g_stor" == "bs" ]; then install_curvebs install_playground - install_tools-v2 else install_curvefs - install_tools-v2 fi + install_tools-v2 } ############################ MAIN()