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

[curve/tools-v2]: add list chunkserver #2036

Closed
Cyber-SiKu opened this issue Nov 4, 2022 · 9 comments
Closed

[curve/tools-v2]: add list chunkserver #2036

Cyber-SiKu opened this issue Nov 4, 2022 · 9 comments
Assignees
Labels

Comments

@Cyber-SiKu
Copy link
Contributor

Cyber-SiKu commented Nov 4, 2022

Is your feature request related to a problem? (你需要的功能是否与某个问题有关?)

we'd like to support list chunkserver command in curve tool

  • The implementation of the old tool is here:
    int StatusTool::ChunkServerListCmd() {
    std::vector<ChunkServerInfo> chunkservers;
    int res = mdsClient_->ListChunkServersInCluster(&chunkservers);
    if (res != 0) {
    std::cout << "ListChunkserversInCluster fail!" << std::endl;
    return -1;
    }
    std::cout << "curve chunkserver list: " << std::endl;
    uint64_t total = 0;
    uint64_t online = 0;
    uint64_t offline = 0;
    uint64_t unstable = 0;
    uint64_t pendding = 0;
    uint64_t retired = 0;
    uint64_t penddingCopyset = 0;
    for (auto& chunkserver : chunkservers) {
    auto csId = chunkserver.chunkserverid();
    std::vector<CopysetInfo> copysets;
    int ret = mdsClient_->GetCopySetsInChunkServer(csId, &copysets);
    if (ret != 0) {
    std::cout << "GetCopySetsInChunkServer fail, chunkserver id = "
    << csId;
    return -1;
    }
    double unhealthyRatio = 0.0;
    if (FLAGS_checkCSAlive) {
    // 发RPC重置online状态
    std::string csAddr = chunkserver.hostip()
    + ":" + std::to_string(chunkserver.port());
    bool isOnline = copysetCheckCore_->CheckChunkServerOnline(csAddr);
    if (isOnline) {
    chunkserver.set_onlinestate(OnlineState::ONLINE);
    } else {
    chunkserver.set_onlinestate(OnlineState::OFFLINE);
    }
    }
    if (chunkserver.onlinestate() != OnlineState::ONLINE) {
    if (chunkserver.onlinestate() == OnlineState::OFFLINE) {
    offline++;
    }
    if (chunkserver.onlinestate() == OnlineState::UNSTABLE) {
    unstable++;
    }
    unhealthyRatio = 1;
    } else {
    if (FLAGS_offline) {
    continue;
    }
    if (FLAGS_checkHealth) {
    copysetCheckCore_->CheckCopysetsOnChunkServer(csId);
    const auto& statistics =
    copysetCheckCore_->GetCopysetStatistics();
    unhealthyRatio = statistics.unhealthyRatio;
    if (FLAGS_unhealthy && unhealthyRatio == 0) {
    continue;
    }
    }
    online++;
    }
    if (chunkserver.status() == ChunkServerStatus::PENDDING) {
    pendding++;
    penddingCopyset += copysets.size();
    }
    if (chunkserver.status() == ChunkServerStatus::RETIRED) {
    retired++;
    }
    total++;
    std::cout << "chunkServerID = " << csId
    << ", diskType = " << chunkserver.disktype()
    << ", hostIP = " << chunkserver.hostip()
    << ", port = " << chunkserver.port()
    << ", rwStatus = "
    << ChunkServerStatus_Name(chunkserver.status())
    << ", diskState = "
    << DiskState_Name(chunkserver.diskstatus())
    << ", onlineState = "
    << OnlineState_Name(chunkserver.onlinestate())
    << ", copysetNum = " << copysets.size()
    << ", mountPoint = " << chunkserver.mountpoint()
    << ", diskCapacity = " << chunkserver.diskcapacity()
    / curve::mds::kGB << " GB"
    << ", diskUsed = " << chunkserver.diskused()
    / curve::mds::kGB << " GB";
    if (FLAGS_checkHealth) {
    std::cout << ", unhealthyCopysetRatio = "
    << unhealthyRatio * 100 << "%";
    }
    if (chunkserver.has_externalip()) {
    std::cout << ", externalIP = " << chunkserver.externalip();
    }
    std::cout << std::endl;
    }
    std::cout << "total: " << total << ", online: " << online;
    if (!FLAGS_checkCSAlive) {
    std::cout <<", unstable: " << unstable;
    }
    std::cout << ", offline: " << offline << std::endl;
    std::cout << "pendding: " << pendding
    << ", penddingCopyset: " << penddingCopyset
    << ", retired:" << retired << std::endl;
    return 0;
    }
  • The old command input and out put:
  curve_ops_tool chunkserver-list 
  output:
curve chunkserver list: 
chunkServerID = 54, diskType = nvme, hostIP = ***.***.***.***, port = 8217, rwStatus = READWRITE, diskState = DISKNORMAL, onlineState = ONLINE, copysetNum = 100, mountPoint = local:///curvebs/chunkserver/data, diskCapacity = 732 GB, diskUsed = 623 GB, unhealthyCopysetRatio = 0%, externalIP = ***.***.***.***
...
chunkServerID = 5, diskType = nvme, hostIP = ***.***.***.***, port = 8209, rwStatus = READWRITE, diskState = DISKNORMAL, onlineState = ONLINE, copysetNum = 100, mountPoint = local:///curvebs/chunkserver/data, diskCapacity = 732 GB, diskUsed = 623 GB, unhealthyCopysetRatio = 0%, externalIP = ***.***.***.***
total: 54, online: 54, unstable: 0, offline: 0
pendding: 0, penddingCopyset: 0, retired:0

Refer to tool develop guide to get start, and paste the result of the command in pr.

Build compilation environment:https://github.com/opencurve/curve/blob/master/docs/cn/build_and_run.md

Describe the solution you'd like (描述你期望的解决方法)

Add subcommand chunkserver to curve bs list.

Describe alternatives you've considered (描述你想到的折衷方案)

Additional context/screenshots (更多上下文/截图)

@Cyber-SiKu Cyber-SiKu added the enhancement improve feature label Nov 4, 2022
@Cyber-SiKu Cyber-SiKu added good first issue Good for newcomers and removed enhancement improve feature labels Nov 4, 2022
@Cyber-SiKu Cyber-SiKu assigned Cyber-SiKu and unassigned cw123 Nov 4, 2022
@Cyber-SiKu Cyber-SiKu added curvebs tools Tool improvements labels Nov 4, 2022
@zhanghuidinah
Copy link
Member

/assign @leonatone

@ilixiaocui
Copy link
Contributor

Please note that the code submission deadline for this developer activity is December 3rd :)
@leonatone

@wuhongsong
Copy link
Contributor

@leonatone you are welcome to continue the work if you are free,

@ilixiaocui
Copy link
Contributor

cc @leonatone Since you haven't responded for a long time, this issue is reopened to others who is interested.

@wuhongsong
Copy link
Contributor

@Cyber-SiKu

@aspirer aspirer changed the title [curve/toos-v2]: add list chunkserver [curve/tools-v2]: add list chunkserver Feb 20, 2023
@Sindweller
Copy link
Contributor

please assign this to me😄

@Cyber-SiKu
Copy link
Contributor Author

@Sindweller Are you still going on?

@Sindweller
Copy link
Contributor

@Sindweller Are you still going on?

Sorry for the delay, I would done it this week.

@zhanghuidinah
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants