From mboxrd@z Thu Jan 1 00:00:00 1970 From: kupcevic@sourceware.org Date: 20 Jun 2006 19:37:24 -0000 Subject: [Cluster-devel] conga/ricci common/Time.cpp docs/cluster_api.h ... Message-ID: <20060620193724.10140.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: conga Changes by: kupcevic at sourceware.org 2006-06-20 19:37:23 Modified files: ricci/common : Time.cpp ricci/docs : cluster_api.html ricci/include : Time.h ricci/modules/cluster: ClusterModule.cpp ClusterStatus.cpp ClusterStatus.h Log message: cluster module: add optional cluster_startup/shutdown arguments to start/stop_node functions (cluster startup without fencing / shutdown without bouncing services) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/common/Time.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/docs/cluster_api.html.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/include/Time.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterModule.cpp.diff?cvsroot=cluster&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterStatus.cpp.diff?cvsroot=cluster&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/conga/ricci/modules/cluster/ClusterStatus.h.diff?cvsroot=cluster&r1=1.2&r2=1.3 --- conga/ricci/common/Time.cpp 2006/03/10 17:50:11 1.2 +++ conga/ricci/common/Time.cpp 2006/06/20 19:37:22 1.3 @@ -66,3 +66,11 @@ req.tv_nsec = rem.tv_nsec; } while (nanosleep(&req, &rem) == -1 && errno == EINTR); } + +void +sleep_sec(unsigned char num) +{ + for (unsigned char i=0; iCluster Module - +

Cluster module manages Redhat Cluster Suite. @@ -63,9 +63,10 @@ online="true" uptime="331625" votes="1"/>
<service autostart="true" failed="false" name="dsa" nodename="green" - running="true" time_since_transition="12345"/>
<service autostart="true" - failed="false" name="new_serv" nodename="green" - running="true" time_since_transition="54321"/>
</cluster>

+ running="true" time_since_transition="12345"/>
<service + autostart="true" failed="false" name="new_serv" + nodename="green" running="true" + time_since_transition="54321"/>
</cluster>

On failure:
- No special errors defined, only generic ones might get returned.

@@ -105,26 +106,33 @@

On failure:
- 1 ??? service manager is not running on this managed system
- generic ones

-
  • start_node

    +
  • start_node +

      -

      Start cluster infrastructure and configured services. It is not - an error to start already started node.

      -

      No input variables.

      -

      No output variables.

      +

      Start cluster infrastructure on this node (also, enable daemons' + boot startup).
      It is not an error to start already started + node.

      +

      Input variables:
      - ???cluster_startup??? (boolean) ??? + optional, default ???false???, cluster is starting up (wait for all + to come up, then start services ??? avoid fencing on startup)

      +

      No output variables. +

      On failure:
      - No special errors defined, only generic ones might get returned.

  • stop_node

      -

      Stop cluster infrastructure and configured services. It is not - an error to stop already stopped node. -

      -

      No input variables. -

      +

      Stop cluster infrastructure on this node (also, disable daemons' + boot startup).
      It is not an error to stop already stopped node. +

      +

      Input variables:
      - ???cluster_shutdown??? (boolean) ??? + optional, default ???false???, cluster is shutting down (don't + bounce services around)

      No output variables.

      On failure:
      - No special errors defined, only generic ones - might get returned.

      + might get returned. +

  • fence_node

      @@ -140,4 +148,4 @@



      - + \ No newline at end of file --- conga/ricci/include/Time.h 2006/03/10 17:50:11 1.2 +++ conga/ricci/include/Time.h 2006/06/20 19:37:23 1.3 @@ -35,6 +35,8 @@ // sleep num milliseconds void sleep_mil(unsigned char num); +// sleep num seconds +void sleep_sec(unsigned char num); std::string time_formated(); --- conga/ricci/modules/cluster/ClusterModule.cpp 2006/04/12 15:47:09 1.2 +++ conga/ricci/modules/cluster/ClusterModule.cpp 2006/06/20 19:37:23 1.3 @@ -205,7 +205,16 @@ VarMap start_node(const VarMap& args) { - Cluster::start_node(); + bool cluster_startup = false; + try { + VarMap::const_iterator iter = args.find("cluster_startup"); + if (iter != args.end()) + cluster_startup = iter->second.get_bool(); + } catch ( string e ) { + throw APIerror(e); + } + + Cluster::start_node(cluster_startup); VarMap ret; return ret; @@ -214,7 +223,16 @@ VarMap stop_node(const VarMap& args) { - Cluster::stop_node(); + bool cluster_shutdown = false; + try { + VarMap::const_iterator iter = args.find("cluster_shutdown"); + if (iter != args.end()) + cluster_shutdown = iter->second.get_bool(); + } catch ( string e ) { + throw APIerror(e); + } + + Cluster::stop_node(cluster_shutdown); VarMap ret; return ret; --- conga/ricci/modules/cluster/ClusterStatus.cpp 2006/05/23 17:39:52 1.6 +++ conga/ricci/modules/cluster/ClusterStatus.cpp 2006/06/20 19:37:23 1.7 @@ -25,6 +25,7 @@ #include "Socket.h" #include "Time.h" #include "ClusterConf.h" +#include "Clusvcadm.h" #include "utils.h" #include @@ -105,13 +106,36 @@ void -Cluster::start_node() +Cluster::start_node(bool cluster_startup) { run_initd("ccsd", true, false); if (ClusterConf::is_cman(ClusterConf::get())) - run_initd("cman", true, true); + try { + run_initd("cman", true, true); + } catch ( ... ) { + // try again + run_initd("cman", true, true); + } else run_initd("lock_gulmd", true, true); + + if (cluster_startup) { + // wait for all nodes to join -> avoid fencing + bool all_in = false; + while (all_in == false) { + all_in = true; + XMLObject stat = status(); + for (list::const_iterator iter = stat.children().begin(); + iter != stat.children().end(); + iter++) + if (iter->tag() == "node") + if (iter->get_attr("clustered") == "false") + all_in = false; + if (all_in == false) + sleep_sec(8); + } + } + run_initd("fenced", true, false); run_initd("clvmd", true, false); run_initd("gfs", true, false); @@ -131,8 +155,19 @@ } void -Cluster::stop_node() +Cluster::stop_node(bool cluster_shutdown) { + if (cluster_shutdown) { + // stop all services, so they don't bounce around + XMLObject stat = status(); + for (list::const_iterator iter = stat.children().begin(); + iter != stat.children().end(); + iter++) + if (iter->tag() == "service") + if (iter->get_attr("running") == "true") + Clusvcadm::stop(iter->get_attr("name")); + } + run_initd("rgmanager", false, true); run_initd("gfs", false, false); run_initd("clvmd", false, false); --- conga/ricci/modules/cluster/ClusterStatus.h 2006/03/30 19:53:32 1.2 +++ conga/ricci/modules/cluster/ClusterStatus.h 2006/06/20 19:37:23 1.3 @@ -32,8 +32,8 @@ public: static XMLObject status(); - static void start_node(); - static void stop_node(); + static void start_node(bool cluster_startup = false); + static void stop_node(bool cluster_shutdown = false); };