Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

curvefs/client: rm create fs in init #899

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions curvefs/conf/client.conf
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ diskCache.maxUsableSpaceBytes=107374182400
# the max time system command can run
diskCache.cmdTimeoutSec=300
# directory of disk cache
diskCache.cacheDir=/mnt/curvefs_cache # __ANSIBLE_TEMPLATE__ /mnt/curvefs_disk_cache/{{ 99999999 | random | to_uuid | upper }} __ANSIBLE_TEMPLATE__ __CURVEADM_TEMPLATE__ /usr/local/curvefs/client/data/cache __CURVEADM_TEMPLATE__
diskCache.cacheDir=/mnt/curvefs_cache # __CURVEADM_TEMPLATE__ /curvefs/client/data/cache __CURVEADM_TEMPLATE__ __ANSIBLE_TEMPLATE__ /mnt/curvefs_disk_cache/{{ 99999999 | random | to_uuid | upper }} __ANSIBLE_TEMPLATE__

#### common
client.common.logDir=/data/logs/curvefs # __CURVEADM_TEMPLATE__ /usr/local/curvefs/client/logs __CURVEADM_TEMPLATE__
client.common.logDir=/data/logs/curvefs # __CURVEADM_TEMPLATE__ /curvefs/client/logs __CURVEADM_TEMPLATE__
# we have loglevel: {0,3,6,9}
# as the number increases, it becomes more and more detailed
client.loglevel=0
Expand Down
2 changes: 1 addition & 1 deletion curvefs/conf/etcd.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This is the configuration file for the etcd server.

# Human-readable name for this member.
name: # __CURVEADM_TEMPLATE__ etcd${service_sequence} __CURVEADM_TEMPLATE__ __ANSIBLE_TEMPLATE__ {{ inventory_hostname }} __ANSIBLE_TEMPLATE__
name: # __CURVEADM_TEMPLATE__ etcd${service_host_sequence}${service_replica_sequence} __CURVEADM_TEMPLATE__ __ANSIBLE_TEMPLATE__ {{ inventory_hostname }} __ANSIBLE_TEMPLATE__

# Path to the data directory.
data-dir: # __CURVEADM_TEMPLATE__ ${prefix}/data __CURVEADM_TEMPLATE__ __ANSIBLE_TEMPLATE__ {{ curvefs_etcd_data_dir }} __ANSIBLE_TEMPLATE__
Expand Down
4 changes: 2 additions & 2 deletions curvefs/conf/tools.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
mdsAddr=127.0.0.1:6700 # __CURVEADM_TEMPLATE__ ${cluster_mds_addr} __CURVEADM_TEMPLATE__ __ANSIBLE_TEMPLATE__ {{ groups.mds | join_peer(hostvars, "mds_listen_port") }} __ANSIBLE_TEMPLATE__
mdsDummyAddr=127.0.0.1:7700 # __CURVEADM_TEMPLATE__ ${cluster_mds_dummy_addr} __CURVEADM_TEMPLATE__ __ANSIBLE_TEMPLATE__ {{ groups.mds | join_peer(hostvars, "mds_listen_dummy_port") }} __ANSIBLE_TEMPLATE__
# rpc timeout
rpcTimeoutMs=500
rpcTimeoutMs=5000
rpcRetryTimes=5
# topo file path
topoFilePath=curvefs/test/tools/topo_example.json # __CURVEADM_TEMPLATE__ /usr/local/curvefs/tools/conf/topology.json __CURVEADM_TEMPLATE__ __ANSIBLE_TEMPLATE__ {{ project_root_dest }}/conf/topology.json __ANSIBLE_TEMPLATE__
topoFilePath=curvefs/test/tools/topo_example.json # __CURVEADM_TEMPLATE__ /curvefs/tools/conf/topology.json __CURVEADM_TEMPLATE__ __ANSIBLE_TEMPLATE__ {{ project_root_dest }}/conf/topology.json __ANSIBLE_TEMPLATE__
# metaserver
metaserverAddr=127.0.0.1:6701 # __CURVEADM_TEMPLATE__ ${cluster_metaserver_addr} __CURVEADM_TEMPLATE__ __ANSIBLE_TEMPLATE__ {{ groups.metaserver | join_peer(hostvars, "metaserver_listen_port") }} __ANSIBLE_TEMPLATE__
# etcd
Expand Down
4 changes: 2 additions & 2 deletions curvefs/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM opencurvedocker/curve-base:debian9
ENV TZ=Asia/Shanghai
RUN mkdir -p /usr/local/curvefs /etc/curvefs /core
COPY curvefs /usr/local/curvefs
RUN mkdir -p /curvefs /etc/curvefs /core
COPY curvefs /curvefs
COPY entrypoint.sh /
COPY curvefs/tools/sbin/curvefs_tool /usr/bin
RUN chmod a+x /entrypoint.sh
Expand Down
2 changes: 1 addition & 1 deletion curvefs/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function get_options() {
}

function prepare() {
g_prefix="/usr/local/curvefs/$g_role"
g_prefix="/curvefs/$g_role"
conf_path="$g_prefix/conf/$g_role.conf"

case $g_role in
Expand Down
12 changes: 3 additions & 9 deletions curvefs/src/client/fuse_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,9 @@ CURVEFS_ERROR FuseClient::FuseOpInit(void *userdata,
FSStatusCode ret = mdsClient_->GetFsInfo(fsName, &fsInfo);
if (ret != FSStatusCode::OK) {
if (FSStatusCode::NOT_FOUND == ret) {
LOG(INFO) << "The fsName not exist, try to CreateFs"
<< ", fsName = " << fsName;

CURVEFS_ERROR ret2 = CreateFs(userdata, &fsInfo);
if (ret2 != CURVEFS_ERROR::OK) {
LOG(ERROR) << "CreateFs failed, ret = " << ret2
<< ", fsName = " << fsName;
return ret2;
}
LOG(ERROR) << "The fsName not exist, try to CreateFs"
<< ", fsName = " << fsName;
return CURVEFS_ERROR::NOTEXIST;
} else {
LOG(ERROR) << "GetFsInfo failed, FSStatusCode = " << ret
<< ", FSStatusCode_Name = "
Expand Down
3 changes: 3 additions & 0 deletions curvefs/src/mds/mds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,9 @@ void MDS::StartDummyServer() {
status_.expose("curvefs_mds_status");
status_.set_value("follower");

// set mds version in metric
curve::common::ExposeCurveVersion();

LOG_IF(FATAL, 0 != brpc::StartDummyServerAt(options_.dummyPort))
<< "Start dummy server failed";
}
Expand Down
11 changes: 8 additions & 3 deletions curvefs/src/tools/create/curvefs_create_fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ DECLARE_string(s3_endpoint);
DECLARE_string(s3_bucket_name);
DECLARE_uint64(s3_blocksize);
DECLARE_uint64(s3_chunksize);
DECLARE_uint32(rpcTimeoutMs);

namespace curvefs {
namespace tools {
Expand All @@ -61,7 +62,8 @@ void CreateFsTool::PrintHelp() {
<< " -s3_bucket_name=" << FLAGS_s3_bucket_name
<< " -s3_blocksize=" << FLAGS_s3_blocksize
<< " -s3_chunkSize=" << FLAGS_s3_chunksize
<< "] [-mdsAddr=" << FLAGS_mdsAddr << "]" << std::endl;
<< "] [-mdsAddr=" << FLAGS_mdsAddr << "]"
<< "[-rpcTimeoutMs= " << FLAGS_rpcTimeoutMs << "]" << std::endl;
}

void CreateFsTool::AddUpdateFlags() {
Expand All @@ -79,6 +81,7 @@ void CreateFsTool::AddUpdateFlags() {
AddUpdateFlagsFunc(curvefs::tools::SetS3_bucket_name);
AddUpdateFlagsFunc(curvefs::tools::SetS3_blocksize);
AddUpdateFlagsFunc(curvefs::tools::SetS3_chunksize);
AddUpdateFlagsFunc(curvefs::tools::SetRpcTimeoutMs);
}

int CreateFsTool::Init() {
Expand Down Expand Up @@ -125,6 +128,7 @@ int CreateFsTool::Init() {
}

AddRequest(request);
controller_->set_timeout_ms(FLAGS_rpcTimeoutMs);
return ret;
}

Expand All @@ -136,8 +140,9 @@ bool CreateFsTool::AfterSendRequestToHost(const std::string& host) {
<< ", error text: " << controller_->ErrorText()
<< std::endl;
ret = false;
} else if (response_->statuscode() == mds::FSStatusCode::OK) {
// create success
} else if (response_->statuscode() == mds::FSStatusCode::OK ||
response_->statuscode() == mds::FSStatusCode::FS_EXIST) {
// create success or fs exist
std::cout << "create fs success." << std::endl;
if (response_->has_fsinfo()) {
auto const& fsInfo = response_->fsinfo();
Expand Down
2 changes: 1 addition & 1 deletion curvefs/src/tools/curvefs_tool_define.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const char kMetaserverStatusUri[] = "/vars/pid";
const char kEtcdVersionUri[] = "/version";
const char kEtcdStatusUri[] = "/v2/stats/self";
const char kEtcdClusterVersionKey[] = "etcdcluster";
const char kVersionKey[] = "curvefs_version";
const char kVersionKey[] = "curve_version";
const char kMdsStatusKey[] = "curvefs_mds_status";
const char kEtcdStateKey[] = "state";
const char kHostLeaderValue[] = "leader";
Expand Down
3 changes: 2 additions & 1 deletion curvefs/src/tools/curvefs_tool_metric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ int MetricClient::GetKeyValueFromString(const std::string& str,
std::string* value) {
auto pos = str.find(":");
if (pos == std::string::npos) {
std::cout << "parse response attachment fail!" << std::endl;
std::cerr << "parse " << key << " fail! it should be like: *:*." A / 1
<< std::endl;
return -1;
}
*value = str.substr(pos + 1);
Expand Down
2 changes: 2 additions & 0 deletions curvefs/src/tools/delete/curvefs_delete_fs_tool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ bool DeleteFsTool::AfterSendRequestToHost(const std::string& host) {
} else if (response_->statuscode() != curvefs::mds::FSStatusCode::OK) {
std::cerr << "delete fs from mds: " << host
<< " failed. errorcode= " << response_->statuscode()
<< ", errorname= "
<< mds::FSStatusCode_Name(response_->statuscode())
<< std::endl;
} else {
std::cout << "delete fs " << FLAGS_fsName << " success." << std::endl;
Expand Down
4 changes: 4 additions & 0 deletions curvefs/src/tools/list/curvefs_fsinfo_list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ bool FsInfoListTool::AfterSendRequestToHost(const std::string& host) {
<< " failed, errorcode= " << controller_->ErrorCode()
<< ", error text " << controller_->ErrorText() << "\n";
} else if (show_) {
if (response_->fsinfo().empty()) {
std::cout << "no fs in cluster." << std::endl;
}

for (auto const& i : response_->fsinfo()) {
std::cout << i.DebugString() << std::endl;
}
Expand Down
32 changes: 2 additions & 30 deletions curvefs/test/client/test_fuse_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,29 +188,12 @@ TEST_F(TestFuseVolumeClient, FuseOpInit_when_fs_not_exist) {
EXPECT_CALL(*mdsClient_, GetFsInfo(fsName, _))
.WillOnce(Return(FSStatusCode::NOT_FOUND));

EXPECT_CALL(*blockDeviceClient_, Stat(volName, user, _))
.WillOnce(Return(CURVEFS_ERROR::OK));

EXPECT_CALL(*mdsClient_, CreateFs(_, _, _))
.WillOnce(Return(FSStatusCode::OK));

FsInfo fsInfoExp;
fsInfoExp.set_fsid(100);
fsInfoExp.set_fsname(fsName);
EXPECT_CALL(*mdsClient_, MountFs(fsName, _, _))
.WillOnce(DoAll(SetArgPointee<2>(fsInfoExp), Return(FSStatusCode::OK)));

EXPECT_CALL(*blockDeviceClient_, Open(volName, user))
.WillOnce(Return(CURVEFS_ERROR::OK));

CURVEFS_ERROR ret = client_->FuseOpInit(&mOpts, nullptr);
ASSERT_EQ(CURVEFS_ERROR::OK, ret);

auto fsInfo = client_->GetFsInfo();
ASSERT_NE(fsInfo, nullptr);

ASSERT_EQ(fsInfo->fsid(), fsInfoExp.fsid());
ASSERT_EQ(fsInfo->fsname(), fsInfoExp.fsname());
ASSERT_EQ(CURVEFS_ERROR::NOTEXIST, ret);
}

TEST_F(TestFuseVolumeClient, FuseOpDestroy) {
Expand Down Expand Up @@ -1718,23 +1701,12 @@ TEST_F(TestFuseS3Client, FuseOpInit_when_fs_not_exist) {
EXPECT_CALL(*mdsClient_, GetFsInfo(fsName, _))
.WillOnce(Return(FSStatusCode::NOT_FOUND));

EXPECT_CALL(*mdsClient_, CreateFsS3(_, _, _))
.WillOnce(Return(FSStatusCode::OK));

FsInfo fsInfoExp;
fsInfoExp.set_fsid(100);
fsInfoExp.set_fsname(fsName);
EXPECT_CALL(*mdsClient_, MountFs(fsName, _, _))
.WillOnce(DoAll(SetArgPointee<2>(fsInfoExp), Return(FSStatusCode::OK)));

CURVEFS_ERROR ret = client_->FuseOpInit(&mOpts, nullptr);
ASSERT_EQ(CURVEFS_ERROR::OK, ret);

auto fsInfo = client_->GetFsInfo();
ASSERT_NE(fsInfo, nullptr);

ASSERT_EQ(fsInfo->fsid(), fsInfoExp.fsid());
ASSERT_EQ(fsInfo->fsname(), fsInfoExp.fsname());
ASSERT_EQ(CURVEFS_ERROR::NOTEXIST, ret);
}

TEST_F(TestFuseS3Client, FuseOpDestroy) {
Expand Down