From 4df3e39293adc6e39c591ec50c930e21047f99ee Mon Sep 17 00:00:00 2001 From: ilixiaocui Date: Mon, 10 Jul 2023 14:15:14 +0800 Subject: [PATCH] curvefs/fix: addition of the objectPrefix field in the message S3Info has caused compatibility issues Signed-off-by: ilixiaocui --- curvefs/src/mds/fs_storage.cpp | 9 +++++++++ curvefs/test/mds/persist_kvstorage_test.cpp | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/curvefs/src/mds/fs_storage.cpp b/curvefs/src/mds/fs_storage.cpp index 5e9d41e106..b5148d6e4a 100644 --- a/curvefs/src/mds/fs_storage.cpp +++ b/curvefs/src/mds/fs_storage.cpp @@ -359,6 +359,15 @@ bool PersisKVStorage::LoadAllFs() { idToName_.emplace(fsInfo.fsid(), fsInfo.fsname()); + // For compatibility when upgrading, the new field 'optional + // objectPrefix` in message `S3Info` needs to be set to the default + // value + if (fsInfo.fstype() == FSType::TYPE_S3) { + if (!fsInfo.detail().s3info().has_objectprefix()) { + fsInfo.mutable_detail()->mutable_s3info()->set_objectprefix(0); + } + } + fs_.emplace(fsInfo.fsname(), std::move(fsInfo)); } diff --git a/curvefs/test/mds/persist_kvstorage_test.cpp b/curvefs/test/mds/persist_kvstorage_test.cpp index 6f83766cc3..c5d25b0760 100644 --- a/curvefs/test/mds/persist_kvstorage_test.cpp +++ b/curvefs/test/mds/persist_kvstorage_test.cpp @@ -170,6 +170,10 @@ TEST_F(PersistKVStorageTest, TestInit) { EXPECT_FALSE(storage.Exist(3)); EXPECT_FALSE(storage.Exist("foo")); + + FsInfoWrapper wrapper; + EXPECT_EQ(FSStatusCode::OK, storage.Get("world", &wrapper)); + EXPECT_TRUE(wrapper.GetFsDetail().s3info().has_objectprefix()); } } @@ -531,6 +535,5 @@ TEST_F(PersistKVStorageTest, TestDelete) { EXPECT_TRUE(storage.Exist(2)); } } - } // namespace mds } // namespace curvefs