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

osd: add "heap *" admin command #13073

Merged
merged 5 commits into from Apr 10, 2017

Conversation

chardan
Copy link
Contributor

@chardan chardan commented Jan 23, 2017

Extends the OSD admin console with a heap profiling command.

@jecluis
Copy link
Member

jecluis commented Jan 23, 2017

@chardan mentioned one of the commits (I'm guessing the rgw one) mistakenly made it into the branch. He will be rebasing the branch and repushing soon.


[[ $do_test -eq 0 ]] && return 0

admin_socket = "--admin-deamon out/osd.0.asok"
Copy link
Member

Choose a reason for hiding this comment

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

typo: should be daemon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good eyes! Thanks.

Copy link
Member

Choose a reason for hiding this comment

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

this still needs to be fixed it looks like?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

...if at first, you don't succeed... (should be corrected now, thank you).

@jdurgin
Copy link
Member

jdurgin commented Jan 28, 2017

nice cleanup to share the command implementation! looks like it'll need a rebase for the command->admin_command rename

src/osd/OSD.cc Outdated
string cmd;
std::vector<std::string> cmd_vec;

if (false == cmd_getval(&cct, cmdmap, "heapcmd", cmd)) {
Copy link
Member

Choose a reason for hiding this comment

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

usually we don't do yoda conditions - any reason to avoid !cmd_getval(...) here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lol @"yoda conditions". No reason here, and changing it makes it consistent with the rest of the function.

@jdurgin
Copy link
Member

jdurgin commented Jan 30, 2017

The build error in jenkins looks real:

/home/jenkins-build/build/workspace/ceph-pull-requests/src/osd/OSD.cc:1951:14: error: ‘command’ was not declared in this scope
   } else if (command == "dump_objectstore_kv_stats") {
              ^

other than that lgtm.

@chardan
Copy link
Contributor Author

chardan commented Jan 31, 2017

Not sure why I didn't see that build issue locally, but I just did a clean build with this patch.

@jdurgin
Copy link
Member

jdurgin commented Feb 2, 2017

I'm getting the same error as jenkins when building locally - perhaps due to merging with the latest master

@tchaikov tchaikov changed the title Jfw wip 15475 admin heap command osd: add "heap *" admin command Feb 3, 2017
@tchaikov
Copy link
Contributor

tchaikov commented Feb 3, 2017

@chardan could you squash the commits into a single one?

@chardan
Copy link
Contributor Author

chardan commented Feb 3, 2017

@tchaikov Sure-- would you rather see all of them together, or do you mean that you want the "corrections" commits squashed? Thanks!

@tchaikov
Copy link
Contributor

tchaikov commented Feb 3, 2017

@chardan the latter. =) sorry for the confusion!

@liuchang0812
Copy link
Contributor

Hi, it would be better to update commit message and PR' title, likes: osd: cleanup "heap *" asock commands

@chardan chardan force-pushed the jfw-wip-15475-admin_heap_command branch 2 times, most recently from 832f0ae to 8c79cd1 Compare February 3, 2017 20:34
@chardan
Copy link
Contributor Author

chardan commented Feb 3, 2017

@tchaikov: I'm working on figuring out how to do that, but it looks like it is beyond my feeble git-fu at this time. (I believe the problem is the merge commit-- when I "git rebase -i HEAD~2", it's picking up all the individual commits in the merge. I'm not sure what the right way around this is, ideas more than welcomed!)

@tchaikov
Copy link
Contributor

tchaikov commented Feb 4, 2017

@chardan you need to remove the merge commit first, here is how i do this

git rebase -i 5c18dd4~
# 1. remove all commits way down to 8c79cd1 (exclusive) in the editor
# 2. resolve the conflict
# 3. reorder the commits and squash the related ones
# 4. voilà

@jecluis
Copy link
Member

jecluis commented Feb 4, 2017

Personally, I think the commit messages are verbose enough as they are, and do not necessarily need to be changed.

However, I'm with @tchaikov on the commits needing squashing, and I would not mind the commits being properly rebased on top of master instead of having merge commits polluting the branch's history :)

(edit: seems like I didn't refresh the page and the party continued in the mean time; consider above comments with that in mind)

@chardan chardan force-pushed the jfw-wip-15475-admin_heap_command branch from 8c79cd1 to b093bf5 Compare February 4, 2017 20:36
@yuriw
Copy link
Contributor

yuriw commented Feb 5, 2017

test this please

@yuriw
Copy link
Contributor

yuriw commented Feb 5, 2017

@chardan @jdurgin FYI Build failed:

[ 34%] Building CXX object src/CMakeFiles/common-objs.dir/log/Log.cc.o
/home/jenkins-build/build/workspace/ceph-pull-requests/src/osd/OSD.cc: In member function ‘bool OSD::asok_command(std::string, cmdmap_t&, std::string, std::ostream&)’:
/home/jenkins-build/build/workspace/ceph-pull-requests/src/osd/OSD.cc:1958:14: error: ‘command’ was not declared in this scope
} else if (command == "calc_objectstore_db_histogram") {
^
[ 34%] Building CXX object src/osd/CMakeFiles/osd.dir/Watch.cc.o

@@ -1726,7 +1726,7 @@ function test_admin_heap_profiler()

[[ $do_test -eq 0 ]] && return 0

admin_socket = "--admin-deamon out/osd.0.asok"
admin_socket = "--admin-daemon out/osd.0.asok"
Copy link
Contributor

Choose a reason for hiding this comment

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

please squash this change into 48116a6

@@ -1951,9 +1951,9 @@ bool OSD::asok_command(string admin_command, cmdmap_t& cmdmap, string format,
f->dump_bool("success", success);
f->dump_int("value", value);
f->close_section();
} else if (command == "dump_objectstore_kv_stats") {
} else if (admin_command == "dump_objectstore_kv_stats") {
Copy link
Contributor

Choose a reason for hiding this comment

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

and squash this change into 1371e27

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

namespace ceph {
namespace osd_cmds {

int heap(CephContext& cct, cmdmap_t& cmdmap, Formatter& f, std::ostream& os)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit, this helper function should be in an 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.

The reason I've added them to a named namespace is that I foresee moving these into a new source module. One factor is that this having a function that works in both consoles is a different pattern than already exists in the code; they have to be given some sort of name, and I think the namespace helps to make the purpose clear. As more such commands are added, I'm confident the organizational benefit will provide better returns than for this single function.

src/osd/OSD.h Outdated
namespace ceph {
namespace osd_cmds {

int heap(CephContext& cct, cmdmap_t& cmdmap, Formatter& f, std::ostream& os);
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 not necessary to have this declaration in the header file. it's only used in OSD.cc.

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 agree, will do. I think ultimately the "real" right solution is to split these into their own source file away from the other OSD.cc code, but that's a much more significant change.

store->get_db_statistics(f);
} else if (command == "dump_scrubs") {
} else if (admin_command == "dump_scrubs") {
Copy link
Contributor

Choose a reason for hiding this comment

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

@@ -1782,20 +1782,20 @@ class OSDSocketHook : public AdminSocketHook {
OSD *osd;
public:
explicit OSDSocketHook(OSD *o) : osd(o) {}
bool call(std::string command, cmdmap_t& cmdmap, std::string format,
bool call(std::string admin_command, cmdmap_t& cmdmap, std::string format,
Copy link
Contributor

Choose a reason for hiding this comment

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

i don't understand how this helps us to search the admin_command? IIUC, all commands in OSD.cc are admin commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Consider the console commands, around line 5509 or so. It was not obvious to me which of these were "admin" vs. "console" commands at first, and having the above change in would have saved me quite a bit of time. That said, the reason the change is in a separate commit is because it's indeed optional; if there are a lot of strong feelings against it, we don't need to include it, but I know I would have found it helpful.

@chardan
Copy link
Contributor Author

chardan commented Feb 10, 2017

Any next steps or things I should attend to here? Thanks to everyone for the great input!

@chardan chardan force-pushed the jfw-wip-15475-admin_heap_command branch 2 times, most recently from 4511cd7 to 38903e2 Compare March 7, 2017 17:52
@tchaikov
Copy link
Contributor

@chardan needs rebase.

Jesse Williamson added 4 commits March 31, 2017 01:22
Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
@chardan chardan force-pushed the jfw-wip-15475-admin_heap_command branch from 38903e2 to 2823b75 Compare March 31, 2017 08:33
Signed-off-by: Jesse Williamson <jwilliamson@suse.de>
@chardan chardan force-pushed the jfw-wip-15475-admin_heap_command branch from 2823b75 to fc4a4aa Compare April 3, 2017 08:14
@jdurgin
Copy link
Member

jdurgin commented Apr 4, 2017

jenkins: retest this please

@liewegas liewegas merged commit 7e547a1 into ceph:master Apr 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants