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
rbd: show info about mirror daemon instance in image mirror status output #24717
Conversation
trociny
commented
Oct 23, 2018
- References tracker ticket
- Updates documentation if necessary
- Includes tests for new functionality or reproducer for bug
@dillaman Displaying info about rbd-mirror daemon instance in 'mirror status' output looks very useful to me, especially when we can run now multiple instances in A-P or A-A mode. This information is already stored by OSDs, the problem is though how to get it without breaking API. The current implementations breaks it by adding Another question is what and how we would want to output. The output in the current implementation looks like below:
|
@trociny I'm on the fence about whether or not the displaying the Ceph entity name is helpful. Since the global id is auto-generated upon connection, it doesn't provide much value. The IP address (sans nonce) can at least help narrow down the host -- but you have multiple daemons running on the same host in a container, it's only a partial solution. However, if the global id is combined w/ the output from As for breaking both the cls and C/C++ API, I think this needs to be prevented at all costs. The entity can at least be safely added to the |
@dillaman Excellent idea about using id from For the C/C++ APIs, yes I had some ideas how it could be solved, the question actually was what from this list of possible solutions you like more (hate less)? Because I am not very happy with adding Ok I think I like the most what I assume you propose in (3), that is add new methods to API to retrieve
And so there will be new cls methods to store/retrieve this info. Both cls and API mirror_image_status methods and structures remain unchanged. |
Good point since each
I'd vote for option (3).
I was originally just thinking just the former and skip the latter -- but I can see how adding this to the dashboard for all images could be nice. |
949b812
to
5791d44
Compare
@dillaman updated.
|
Again, why not just add the |
src/tools/rbd/action/MirrorImage.cc
Outdated
<< " last_update: " << last_update << std::endl; | ||
<< " description: " << status.description << "\n"; | ||
if (!service_description.empty()) { | ||
std::cout << " service: " << service_description << "\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: is the indent correct here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was intentionally incorrect but to make the " service: " filed exactly under " description: ", so I can be sure it has correct number of spaces (and will do if we will change this in future). But if you don't like this I will change.
src/tools/rbd/action/MirrorImage.cc
Outdated
@@ -292,15 +313,20 @@ int execute_status(const po::variables_map &vm, | |||
formatter->dump_string("global_id", status.info.global_id); | |||
formatter->dump_string("state", state); | |||
formatter->dump_string("description", status.description); | |||
formatter->dump_string("daemon_service_id", service_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: if you have the service details, perhaps open a new object section?
src/tools/rbd/action/MirrorPool.cc
Outdated
@@ -624,6 +649,9 @@ class StatusImageRequest : public ImageRequestBase { | |||
m_formatter->dump_string("state", state); | |||
m_formatter->dump_string("description", | |||
m_mirror_image_status.description); | |||
m_formatter->dump_string("daemon_service_id", service_id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: ditto here
src/tools/rbd/action/MirrorPool.cc
Outdated
<< " last_update: " << last_update << std::endl; | ||
<< m_mirror_image_status.description << "\n"; | ||
if (!service_description.empty()) { | ||
std::cout << " service: " << service_description << "\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: indent correct?
src/tools/rbd/Utils.cc
Outdated
continue; | ||
} | ||
auto &service_id = it.first; | ||
auto &daemon_metada = it.second.get_obj()["metadata"].get_obj(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: typo on daemon_metada
src/include/rbd/librbd.hpp
Outdated
int aio_mirror_image_promote(bool force, RBD::AioCompletion *c); | ||
int aio_mirror_image_demote(RBD::AioCompletion *c); | ||
int aio_mirror_image_get_info(mirror_image_info_t *mirror_image_info, | ||
size_t info_size, RBD::AioCompletion *c); | ||
int aio_mirror_image_get_status(mirror_image_status_t *mirror_image_status, | ||
size_t status_size, RBD::AioCompletion *c); | ||
int aio_mirror_image_get_service_id(std::string *service_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: doesn't seem to be needed/used right now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I was using this initially for rbd mirror pool status
, in StatusImageRequest
until I realized that I could just call mirror_image_service_id_list
once and pass the list to StatusImageRequest
.
Ok. I will remove those.
src/include/rbd/librbd.h
Outdated
@@ -974,6 +986,10 @@ CEPH_RBD_API int rbd_aio_mirror_image_get_status(rbd_image_t image, | |||
rbd_mirror_image_status_t *mirror_image_status, | |||
size_t status_size, | |||
rbd_completion_t c); | |||
CEPH_RBD_API int rbd_aio_mirror_image_get_service_id(rbd_image_t image, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: doesn't seem to be needed/used right now?
src/librbd/api/Mirror.cc
Outdated
@@ -134,6 +136,135 @@ struct C_ImageGetStatus : public C_ImageGetInfo { | |||
} | |||
}; | |||
|
|||
int map_instance_id_to_service_id(librados::IoCtx& io_ctx, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I really like the idea of each API call issuing a service status
dump to the mgr. The rbd CLI can do this one and the dashboard will have all this data available in-memory. Therefore, perhaps the API should just return the daemon's pool instance id and leave it up to the caller to map it back to a service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't like this much too but wanted the API methods to do as mach as possible so we would not duplicate this in cli and dashboard. But after your argument about dashboard already having this data available in-memory I tend to agree, so I will change this just to return the daemon's pool instance id.
src/librbd/api/Mirror.cc
Outdated
json_spirit::mValue status_json_root; | ||
if (json_spirit::read(status_json_str, status_json_root)) { | ||
auto& status = status_json_root.get_obj(); | ||
for (auto &iter : status) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The dict key should be the pool id, so you can just skip right to the pool's json
status if it exists.
Because I was still not sure if we wanted separate cls methods to retrieve Ok it looks like you don't want new cls methods and just want to extend |
So, now, after we have decided just to extend |
I am fine w/ a new cls method -- I just don't like the overloading of the existing method return parameters if it can be avoided. Adding two new methods certainly avoids the ugliness of the on-disk vs on-wire structs. |
647ecd0
to
908d6b3
Compare
@dillaman updated Note, in python bindings I added |
@trociny Since the CLI additions can only be tested when rbd-mirror daemon is running, can you also add a small test case to |
908d6b3
to
74d4ef8
Compare
@dillaman I was running mirror [1], c_api [2], python [3], and cls [4] tests on teuthology. No issues with the code (or updated qa tests) found, though stress testing "service status" mgr command relieved an issue in ceph-mgr processing the command [5]. It looks like a race when a rbd-mirror daemon is stopping and "service status" command is run at that time. I am planning to work on it. [1] http://pulpito.ceph.com/trociny-2018-10-30_14:49:18-rbd-wip-mgolub-testing-distro-basic-smithi/ |
74d4ef8
to
2f50721
Compare
Signed-off-by: Mykola Golub <mgolub@suse.com>
Signed-off-by: Mykola Golub <mgolub@suse.com>
Signed-off-by: Mykola Golub <mgolub@suse.com>
2f50721
to
15377d3
Compare
@dillaman thanks, fixed. The teuthology (--filter mirror) run: http://pulpito.ceph.com/trociny-2018-11-03_17:03:25-rbd-wip-mgolub-testing-distro-basic-smithi/ |
src/tools/rbd/action/MirrorImage.cc
Outdated
|
||
if (status.up) { | ||
r = image.mirror_image_get_instance_id(&instance_id); | ||
if (r < 0 && r != -ENOENT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: one last thing, this should probably filter our -EOPNOTSUPP
to avoid the case where older OSDs are being used. If the OSDs' don't support this new cls method, don't include the status.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dillaman I am not sure about this. With the current code it will print the error (warning) but still will output the status. So the user will be informed that the information is not full and will know the reason of this. It differs from -ENOENT
case, because it means that information was not stored (does not exist), while for -EOPNOTSUPP
it means that it may be their but we can't obtain it.
But I don't have strong opinion here and will change it if you still think it is better to suppress the error message in this case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If a special-case were to be added for -EOPNOTSUPP
, a more friendly message could be provided like rbd: newer release of Ceph OSDs required to map image to rbd-mirror daemon instance
(or similar)
while (true) { | ||
std::map<std::string, std::string> ids; | ||
r = rbd.mirror_image_instance_id_list(io_ctx, start_image_id, 1024, &ids); | ||
if (r < 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: same comment here
It is particularly useful when running multiple rbd-mirror instances in Active-Passive or Active-Active mode. Signed-off-by: Mykola Golub <mgolub@suse.com>
15377d3
to
7d2ffd9
Compare
@dillaman updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm