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/Multiple s3 support #1132

Merged
merged 1 commit into from
Mar 9, 2022
Merged

Conversation

Cyber-SiKu
Copy link
Contributor

@Cyber-SiKu Cyber-SiKu commented Mar 3, 2022

What problem does this PR solve?

Issue Number: close #1119 #1120 #1037 #1038

Problem Summary:

What is changed and how it works?

What's Changed:

  1. client get s3info from mds
  2. metaserver get s3info from mds
  3. mds check s3info before create fs

How it Works:

s3信息流

Side effects(Breaking backward compatibility? Performance regression?):

Check List

  • Relevant documentation/comments is changed or added
  • I acknowledge that all my contributions will be made under the project's license

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/S3 branch 2 times, most recently from 67f336b to 87fe451 Compare March 3, 2022 14:43
@Cyber-SiKu Cyber-SiKu changed the title curvefs/S3 curvefs/Multiple s3 support Mar 4, 2022
@@ -182,6 +183,18 @@ FSStatusCode FsManager::CreateFs(const std::string& fsName, FSType fsType,
}
}

// check s3info
if (detail.has_s3info()) {
auto s3Info = detail.s3info();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto& s3Info = ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const auto& s3Info = ...

fix

S3ClientImpl() : S3Client() {}
virtual ~S3ClientImpl() {}

void SetAdaptor(std::shared_ptr<curve::common::S3Adapter> s3Adapter);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not pass it in constructor ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not pass it in constructor ?

just do it like curvefs/src/client/s3/client_s3.h.
But I think it should be mocked for unit testing

}

void FuseOpInit(void *userdata, struct fuse_conn_info *conn) {
CURVEFS_ERROR ret = g_ClientInstance->FuseOpInit(userdata, conn);
if (ret != CURVEFS_ERROR::OK) {
LOG(FATAL) << "FuseOpInit failed, ret = " << ret;
LOG(ERROR) << "FuseOpInit failed, ret = " << ret;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change log level to ERROR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why change log level to ERROR?

fix

@@ -90,7 +94,30 @@ int InitGlog(const char *confPath, const char *argv0) {
return 0;
}

int InitFuseClient(const char *confPath, const char *fsType) {
int GetFsInfo(const char *fsName, std::shared_ptr<FsInfo> fsInfo) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

static or put this function into anonymous namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

put this function into anonymous namespace

fix

Comment on lines 149 to 155
} else if (fsTypeStr == "s3") {
g_ClientInstance = new FuseS3Client();
// set fsS3Option
const auto& s3Info = fsInfo->detail().s3info();
::curve::common::FsS3Option fsS3Option;
::curvefs::client::common::S3Info2FsS3Option(s3Info, &fsS3Option);
SetFuseClientS3Option(g_fuseClientOption, fsS3Option);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you just put these in fuse_s3_client ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you just put these in fuse_s3_client ?

good,idea! fix

Comment on lines 98 to 109
#### s3
# the max size that fuse send
s3.fuseMaxSize=131072
s3.pagesize=65536
# prefetch blocks that disk cache use
s3.prefetchBlocks=1
# prefetch threads
s3.prefetchExecQueueNum=1
# start sleep when mem cache use ratio is greater than nearfullRatio,
# sleep time increase follow with mem cache use raito, baseSleepUs is baseline.
s3.nearfullRatio=70
s3.baseSleepUs=500
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these fields are useless.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these fields are useless.

this for init but i will try for delete this

::curve::client::RPCExcutorRetryPolicy rpcexcutor_;
::curve::client::MetaServerOption mdsOpt_;

MDSClientMetric mdsClientMetric_;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metric is also unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

metric is also unnecessary

fix

@@ -36,6 +36,9 @@ class S3Client {
virtual void Init(const curve::common::S3AdapterOption& option) = 0;
virtual int Delete(const std::string& name) = 0;
virtual int DeleteBatch(const std::list<std::string>& nameList) = 0;
virtual void Reinit(const std::string& ak, const std::string& sk,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a superset of s3client in mds_s3.h, you should reduce duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a superset of s3client in mds_s3.h, you should reduce duplication.

this is different from mds_s3, mds_s3 work for check s3 info available, this work for delete s3 object.
There is no inheritance relationship between these two s3.

Comment on lines 90 to 98
struct FsS3Option {
// should get from mds
std::string ak;
std::string sk;
std::string s3Address;
std::string bucketName;
uint64_t blockSize;
uint64_t chunkSize;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't put this option in here, I think s3 adapter is just put object to s3 or get object from s3, it shouldn't care about what is fs option.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't put this option in here, I think s3 adapter is just put object to s3 or get object from s3, it shouldn't care about what is fs option.

this just for init, maybe the name is not well ,it should be like S3InfoOption?

uint64_t chunkSize;
};

void InitS3AdaptorOptionExceptFsS3Option(Configuration* conf,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

fix

s3Client_->Reinit(s3Info.ak(), s3Info.sk(), s3Info.endpoint(),
s3Info.bucketname());
if (!s3Client_->BucketExist()) {
LOG(ERROR) << "s3info for fs is not available, s3info is "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output should be aligned and add fsName.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Output should be aligned and add fsName.

fix

@@ -150,9 +151,17 @@ void MDS::Init() {
FsManagerOption fsManagerOption;
InitFsManagerOptions(&fsManagerOption);

auto s3Client = std::make_shared<S3ClientImpl>();
s3Client->SetAdaptor(std::make_shared<curve::common::S3Adapter>());
s3Client_ = s3Client;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto s3Client = std::make_shared();
s3Client->SetAdaptor(std::make_sharedcurve::common::S3Adapter());
s3Client_ = s3Client;

s3Client_ = std::make_shared();
s3Client_->SetAdaptor(std::make_sharedcurve::common::S3Adapter());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

auto s3Client = std::make_shared(); s3Client->SetAdaptor(std::make_sharedcurve::common::S3Adapter()); s3Client_ = s3Client;

s3Client_ = std::make_shared(); s3Client_->SetAdaptor(std::make_sharedcurve::common::S3Adapter());

fix


namespace curvefs {
namespace mds {
class S3Client {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class S3Client in mds can use S3Adapter replace directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class S3Client in mds can use S3Adapter replace directly.

This s3client doesn't need so many functions, just for check s3info available.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class S3Client in mds can use S3Adapter replace directly.

This s3client doesn't need so many functions, just for check s3info available.

I means the S3Client doesn't need, it just a simple wrapper of S3Adaper.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class S3Client in mds can use S3Adapter replace directly.

This s3client doesn't need so many functions, just for check s3info available.

I means the S3Client doesn't need, it just a simple wrapper of S3Adaper.

Compared with using the S3 Adaptor directly, the client seems to be able to better indicate the s3 functions used by mds, or the role of s3 in mds.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The class S3Client in mds can use S3Adapter replace directly.

This s3client doesn't need so many functions, just for check s3info available.

I means the S3Client doesn't need, it just a simple wrapper of S3Adaper.

fix

using ::curvefs::mds::GetFsInfoResponse;
using ::curvefs::client::rpcclient::MDSBaseClient;

class MdsClient {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can reuse MdsClient in client, put the MdsClient to common or some other ways?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can reuse MdsClient in client, put the MdsClient to common or some other ways?

This mdsclient doesn't need so many functions

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can reuse MdsClient in client, put the MdsClient to common or some other ways?

This mdsclient doesn't need so many functions

Yes, but mdsclient is everywhere in client, mds, metaserver. That is similar to S3 info is everywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can reuse MdsClient in client, put the MdsClient to common or some other ways?

This mdsclient doesn't need so many functions

Yes, but mdsclient is everywhere in client, mds, metaserver. That is similar to S3 info is everywhere.

ok, fix

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/S3 branch 3 times, most recently from bb1691e to 0856091 Compare March 4, 2022 15:17
Comment on lines 36 to 38
virtual void Init(const curve::common::S3AdapterOption& option) = 0;
virtual int Delete(const std::string& name) = 0;
virtual int DeleteBatch(const std::list<std::string>& nameList) = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why we have this S3Client because it's just a wrapper of S3Adapter, and what it does is forward the function call to S3Adapter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering why we have this S3Client because it's just a wrapper of S3Adapter, and what it does is forward the function call to S3Adapter.

yep

@Cyber-SiKu Cyber-SiKu force-pushed the curvefs/S3 branch 4 times, most recently from dd8dd50 to 377a147 Compare March 8, 2022 06:02
1. client get s3Info from mds by fsId, and use s3Info to set s3Adapter;
2. metaserver get s3info from mds by fsId, and use s3Info to set
s3Adaptor;
3. mds check s3info available by check bucketName before create fs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support multiple s3
3 participants