Skip to content

Commit

Permalink
curvefs/fix: addition of the objectPrefix field in the message S3Info…
Browse files Browse the repository at this point in the history
… has caused compatibility issues

Signed-off-by: ilixiaocui <ilixiaocui@163.com>
  • Loading branch information
ilixiaocui committed Jul 10, 2023
1 parent 0cee7f5 commit 4df3e39
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
9 changes: 9 additions & 0 deletions curvefs/src/mds/fs_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}

Expand Down
5 changes: 4 additions & 1 deletion curvefs/test/mds/persist_kvstorage_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -531,6 +535,5 @@ TEST_F(PersistKVStorageTest, TestDelete) {
EXPECT_TRUE(storage.Exist(2));
}
}

} // namespace mds
} // namespace curvefs

0 comments on commit 4df3e39

Please sign in to comment.