From: Martin Quinson Date: Fri, 24 Feb 2023 15:07:22 +0000 (+0100) Subject: When the chaos monkey is invoked with nothing to do, it tells a usage message and... X-Git-Tag: v3.34~447 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/979ccd958739ad8e3434a81adea4249743c7daa5?ds=sidebyside When the chaos monkey is invoked with nothing to do, it tells a usage message and kills everything --- diff --git a/src/plugins/chaos_monkey.cpp b/src/plugins/chaos_monkey.cpp index 45f4df6eac..04810ee442 100644 --- a/src/plugins/chaos_monkey.cpp +++ b/src/plugins/chaos_monkey.cpp @@ -29,6 +29,21 @@ static void sg_chaos_monkey_plugin_run() sg4::Engine::on_deadlock_cb([]() { exit(2); }); + if (not cfg_tell && cfg_time < 0 && cfg_host == -1 && cfg_link == -1) { + XBT_CRITICAL( + "You invoked the Chaos Monkey without anything to do.\n" + "Bored, it kills your simulation after this message about how to use it manually (note that the\n" + "simgrid-monkey script can tame the monkey for you if you prefer).\n\n" + "First of all, you need information. Use --cfg=cmonkey/tell:1 to get all information about the existing\n" + "resources and the timestamps of interest in your simulation.\n\n" + "Then, use --cfg=cmonkey/host:0 --cfg=cmonkey/time:0.1 to turn off and on the host #0 at time 0.1s,\n" + "or --cfg=cmonkey/link:22 --cfg=cmonkey/time:0.4 to turn the link #22 off and on again at time 0.4s.\n" + "Only one resource can be rebooted in a given run.\n\n" + "Please read the comments at the beginning of the simgrid-monkey script about how to exhaustively test a\n" + "program resilience.\n"); + exit(1); + } + if (cfg_tell) { XBT_INFO("HOST_COUNT=%zu", hosts.size()); XBT_INFO("LINK_COUNT=%zu", links.size()); @@ -42,7 +57,7 @@ static void sg_chaos_monkey_plugin_run() "If a kill time is given, you must also specify a resource to kill (either a link or an host)"); xbt_assert(host < 0 || link < 0, "Cannot specify both a link and an host to kill"); if (host >= 0) { - auto* h = hosts[host]; + auto* h = hosts.at(host); simgrid::kernel::timer::Timer::set(cfg_time, [h]() { XBT_INFO("Kill host %s", h->get_cname()); h->turn_off(); @@ -53,7 +68,7 @@ static void sg_chaos_monkey_plugin_run() }); } if (link >= 0) { - auto* l = links[link]; + auto* l = links.at(link); simgrid::kernel::timer::Timer::set(cfg_time, [l]() { XBT_INFO("Kill link %s", l->get_cname()); l->turn_off(); @@ -68,9 +83,9 @@ static void sg_chaos_monkey_plugin_run() sg4::Engine::on_simulation_end_cb([]() { XBT_INFO("Chaos Monkey done!"); }); } -// Makes sure that this plugin can be activated from the command line with ``--cfg=plugin:chaos_monkey`` +// Makes sure that this plugin can be activated from the command line with ``--cfg=plugin:cmonkey`` SIMGRID_REGISTER_PLUGIN(cmonkey, "Chaos monkey", []() { - XBT_INFO("Initializing the chaos monkey"); + XBT_INFO("Initializing the chaos monkey."); // delay the initialization until after the parameter are parsed sg4::Engine::on_simulation_start_cb(sg_chaos_monkey_plugin_run);