Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
fix (#324)
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 26 Feb 2019 10:28:47 +0000 (11:28 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 26 Feb 2019 11:46:30 +0000 (12:46 +0100)
Throw a HostFailureException when one tries to create (or attach) an
actor an a host that is not on.
If this happens during the parsing of the deployment file, just let it
go.
for MSG, we could die if this happens (we don't for now)

examples/deprecated/msg/platform-failures/platform-failures.tesh
examples/s4u/platform-failures/s4u-platform-failures.tesh
src/msg/msg_process.cpp
src/s4u/s4u_Actor.cpp
src/simix/ActorImpl.cpp
src/surf/sg_platf.cpp

index f8561ea..0dbaee5 100644 (file)
@@ -5,6 +5,7 @@ p Testing a simple master/worker example application handling failures TCP cross
 ! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/platform-failures$EXEEXT --log=xbt_cfg.thres:critical --log=no_loc ${platfdir}/small_platform_failures.xml ${srcdir}/../app-masterworker/app-masterworker_d.xml --cfg=path:${srcdir} --cfg=network/crosstraffic:0 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=surf_cpu.t:verbose
 > [  0.000000] (0:maestro@) Cannot launch actor 'worker' on failed host 'Fafard'
 ! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/platform-failures$EXEEXT --log=xbt_cfg.thres:critical --log=no_loc ${platfdir}/small_platform_failures.xml ${srcdir}/../app-masterworker/app-masterworker_d.xml --cfg=path:${srcdir} --cfg=network/crosstraffic:0 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=surf_cpu.t:verbose
 > [  0.000000] (0:maestro@) Cannot launch actor 'worker' on failed host 'Fafard'
+> [  0.000000] (0:maestro@) Deployment include some initially turned off Hosts, nevermind.
 > [  0.000000] (1:master@Tremblay) Got 5 workers and 20 tasks to process
 > [  0.000000] (1:master@Tremblay) Send a message to worker-0
 > [  0.010309] (1:master@Tremblay) Send to worker-0 completed
 > [  0.000000] (1:master@Tremblay) Got 5 workers and 20 tasks to process
 > [  0.000000] (1:master@Tremblay) Send a message to worker-0
 > [  0.010309] (1:master@Tremblay) Send to worker-0 completed
@@ -112,6 +113,7 @@ p Testing a simple master/worker example application handling failures. TCP cros
 ! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/platform-failures$EXEEXT --log=xbt_cfg.thres:critical --log=no_loc ${platfdir}/small_platform_failures.xml ${srcdir}/../app-masterworker/app-masterworker_d.xml --cfg=path:${srcdir} "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=surf_cpu.t:verbose
 > [  0.000000] (0:maestro@) Cannot launch actor 'worker' on failed host 'Fafard'
 ! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/platform-failures$EXEEXT --log=xbt_cfg.thres:critical --log=no_loc ${platfdir}/small_platform_failures.xml ${srcdir}/../app-masterworker/app-masterworker_d.xml --cfg=path:${srcdir} "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=surf_cpu.t:verbose
 > [  0.000000] (0:maestro@) Cannot launch actor 'worker' on failed host 'Fafard'
+> [  0.000000] (0:maestro@) Deployment include some initially turned off Hosts, nevermind.
 > [  0.000000] (1:master@Tremblay) Got 5 workers and 20 tasks to process
 > [  0.000000] (1:master@Tremblay) Send a message to worker-0
 > [  0.000000] (2:worker@Tremblay) Waiting a message on worker-0
 > [  0.000000] (1:master@Tremblay) Got 5 workers and 20 tasks to process
 > [  0.000000] (1:master@Tremblay) Send a message to worker-0
 > [  0.000000] (2:worker@Tremblay) Waiting a message on worker-0
index 0b757a6..cf6ff66 100644 (file)
@@ -5,6 +5,7 @@ p Testing a simple master/worker example application handling failures TCP cross
 ! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/s4u-platform-failures$EXEEXT --log=xbt_cfg.thres:critical --log=no_loc ${platfdir}/small_platform_failures.xml ${srcdir:=.}/s4u-platform-failures_d.xml --cfg=path:${srcdir} --cfg=network/crosstraffic:0 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=surf_cpu.t:verbose
 > [  0.000000] (0:maestro@) Cannot launch actor 'worker' on failed host 'Fafard'
 ! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/s4u-platform-failures$EXEEXT --log=xbt_cfg.thres:critical --log=no_loc ${platfdir}/small_platform_failures.xml ${srcdir:=.}/s4u-platform-failures_d.xml --cfg=path:${srcdir} --cfg=network/crosstraffic:0 "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=surf_cpu.t:verbose
 > [  0.000000] (0:maestro@) Cannot launch actor 'worker' on failed host 'Fafard'
+> [  0.000000] (0:maestro@) Deployment include some initially turned off Hosts, nevermind.
 > [  0.000000] (1:master@Tremblay) Got 5 workers and 20 tasks to process
 > [  0.000000] (1:master@Tremblay) Send a message to worker-0
 > [  0.010309] (1:master@Tremblay) Send to worker-0 completed
 > [  0.000000] (1:master@Tremblay) Got 5 workers and 20 tasks to process
 > [  0.000000] (1:master@Tremblay) Send a message to worker-0
 > [  0.010309] (1:master@Tremblay) Send to worker-0 completed
@@ -112,6 +113,7 @@ p Testing a simple master/worker example application handling failures. TCP cros
 ! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/s4u-platform-failures$EXEEXT --log=xbt_cfg.thres:critical --log=no_loc ${platfdir}/small_platform_failures.xml ${srcdir:=.}/s4u-platform-failures_d.xml --cfg=path:${srcdir} "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=surf_cpu.t:verbose
 > [  0.000000] (0:maestro@) Cannot launch actor 'worker' on failed host 'Fafard'
 ! output sort 19
 $ $SG_TEST_EXENV ${bindir:=.}/s4u-platform-failures$EXEEXT --log=xbt_cfg.thres:critical --log=no_loc ${platfdir}/small_platform_failures.xml ${srcdir:=.}/s4u-platform-failures_d.xml --cfg=path:${srcdir} "--log=root.fmt:[%10.6r]%e(%i:%P@%h)%e%m%n" --log=surf_cpu.t:verbose
 > [  0.000000] (0:maestro@) Cannot launch actor 'worker' on failed host 'Fafard'
+> [  0.000000] (0:maestro@) Deployment include some initially turned off Hosts, nevermind.
 > [  0.000000] (1:master@Tremblay) Got 5 workers and 20 tasks to process
 > [  0.000000] (1:master@Tremblay) Send a message to worker-0
 > [  0.000000] (2:worker@Tremblay) Waiting a message on worker-0
 > [  0.000000] (1:master@Tremblay) Got 5 workers and 20 tasks to process
 > [  0.000000] (1:master@Tremblay) Send a message to worker-0
 > [  0.000000] (2:worker@Tremblay) Waiting a message on worker-0
index 83fbcdb..0604ec9 100644 (file)
@@ -4,6 +4,7 @@
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "msg_private.hpp"
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 #include "msg_private.hpp"
+#include "simgrid/Exception.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "src/instr/instr_private.hpp"
 #include "src/simix/ActorImpl.hpp"
 #include "simgrid/s4u/Host.hpp"
 #include "src/instr/instr_private.hpp"
 #include "src/simix/ActorImpl.hpp"
@@ -82,20 +83,25 @@ msg_process_t MSG_process_create_with_environment(const char *name, xbt_main_fun
   xbt_dict_free(&properties);
 
   smx_actor_t self    = SIMIX_process_self();
   xbt_dict_free(&properties);
 
   smx_actor_t self    = SIMIX_process_self();
-  smx_actor_t process = simgrid::simix::simcall([name, function, data, host, &props, self] {
-    return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(function), data, host, &props, self)
-        .get();
-  });
+  smx_actor_t actor   = nullptr;
+  try {
+    actor = simgrid::simix::simcall([name, function, data, host, &props, self] {
+      return simgrid::kernel::actor::ActorImpl::create(std::move(name), std::move(function), data, host, &props, self)
+          .get();
+    });
+  } catch (simgrid::HostFailureException const&) {
+    XBT_DEBUG("The warning has already been issued. Do nothing more than catching the exception.");
+  }
 
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
   xbt_free(argv);
 
 
   for (int i = 0; i != argc; ++i)
     xbt_free(argv[i]);
   xbt_free(argv);
 
-  if (process == nullptr)
+  if (actor == nullptr)
     return nullptr;
 
   MSG_process_yield();
     return nullptr;
 
   MSG_process_yield();
-  return process->ciface();
+  return actor->ciface();
 }
 
 /** @brief Returns the user data of a process.
 }
 
 /** @brief Returns the user data of a process.
index 1df4ce5..a6a4495 100644 (file)
@@ -3,6 +3,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "simgrid/Exception.hpp"
 #include "simgrid/actor.h"
 #include "simgrid/s4u/Actor.hpp"
 #include "simgrid/s4u/Exec.hpp"
 #include "simgrid/actor.h"
 #include "simgrid/s4u/Actor.hpp"
 #include "simgrid/s4u/Exec.hpp"
@@ -663,9 +664,13 @@ sg_actor_t sg_actor_attach(const char* name, void* data, sg_host_t host, xbt_dic
   xbt_dict_free(&properties);
 
   /* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
   xbt_dict_free(&properties);
 
   /* Let's create the process: SIMIX may decide to start it right now, even before returning the flow control to us */
-  smx_actor_t actor = simgrid::kernel::actor::ActorImpl::attach(name, data, host, &props).get();
-  if (not actor)
+  smx_actor_t actor = nullptr;
+  try {
+    actor = simgrid::kernel::actor::ActorImpl::attach(name, data, host, &props).get();
+  } catch (simgrid::HostFailureException const&) {
     xbt_die("Could not attach");
     xbt_die("Could not attach");
+  }
+
   simgrid::s4u::this_actor::yield();
   return actor->ciface();
 }
   simgrid::s4u::this_actor::yield();
   return actor->ciface();
 }
index 00e499d..1123281 100644 (file)
@@ -79,6 +79,8 @@ ActorImplPtr ActorImpl::attach(std::string name, void* data, s4u::Host* host,
 
   if (not host->is_on()) {
     XBT_WARN("Cannot launch process '%s' on failed host '%s'", name.c_str(), host->get_cname());
 
   if (not host->is_on()) {
     XBT_WARN("Cannot launch process '%s' on failed host '%s'", name.c_str(), host->get_cname());
+    std::rethrow_exception(
+        std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Cannot attach actor on failed host.")));
     return nullptr;
   }
 
     return nullptr;
   }
 
@@ -450,6 +452,8 @@ ActorImplPtr ActorImpl::create(std::string name, simix::ActorCode code, void* da
 
   if (not host->is_on()) {
     XBT_WARN("Cannot launch actor '%s' on failed host '%s'", name.c_str(), host->get_cname());
 
   if (not host->is_on()) {
     XBT_WARN("Cannot launch actor '%s' on failed host '%s'", name.c_str(), host->get_cname());
+    std::rethrow_exception(
+        std::make_exception_ptr(simgrid::HostFailureException(XBT_THROW_POINT, "Cannot create actor on failed host.")));
     return nullptr;
   }
 
     return nullptr;
   }
 
index 9b6bc75..7d09fa5 100644 (file)
@@ -3,6 +3,7 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
+#include "simgrid/Exception.hpp"
 #include "simgrid/kernel/routing/ClusterZone.hpp"
 #include "simgrid/kernel/routing/DijkstraZone.hpp"
 #include "simgrid/kernel/routing/DragonflyZone.hpp"
 #include "simgrid/kernel/routing/ClusterZone.hpp"
 #include "simgrid/kernel/routing/DijkstraZone.hpp"
 #include "simgrid/kernel/routing/DragonflyZone.hpp"
@@ -463,9 +464,13 @@ void sg_platf_new_actor(simgrid::kernel::routing::ActorCreationArgs* actor)
   } else {                      // start_time <= SIMIX_get_clock()
     XBT_DEBUG("Starting Process %s(%s) right now", arg->name.c_str(), host->get_cname());
 
   } else {                      // start_time <= SIMIX_get_clock()
     XBT_DEBUG("Starting Process %s(%s) right now", arg->name.c_str(), host->get_cname());
 
-    simgrid::kernel::actor::ActorImplPtr actor = simgrid::kernel::actor::ActorImpl::create(
-        arg->name.c_str(), std::move(code), nullptr, host, arg->properties.get(), nullptr);
-
+    simgrid::kernel::actor::ActorImplPtr actor = nullptr;
+    try {
+      actor = simgrid::kernel::actor::ActorImpl::create(arg->name.c_str(), std::move(code), nullptr, host,
+                                                        arg->properties.get(), nullptr);
+    } catch (simgrid::HostFailureException const&) {
+      XBT_WARN("Deployment include some initially turned off Hosts, nevermind.");
+    }
     /* The actor creation will fail if the host is currently dead, but that's fine */
     if (actor != nullptr) {
       if (arg->kill_time >= 0)
     /* The actor creation will fail if the host is currently dead, but that's fine */
     if (actor != nullptr) {
       if (arg->kill_time >= 0)