From f98a2daee9ffa775f347b0974ac15bb357a70ed7 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Fri, 25 Oct 2013 15:16:44 +0200 Subject: [PATCH] feature #1678: Exit oned if a driver cannot be loaded --- include/AuthManager.h | 2 +- include/HookManager.h | 2 +- include/ImageManager.h | 2 +- include/InformationManager.h | 2 +- include/MadManager.h | 38 ++++++++++++++--------------- include/TransferManager.h | 2 +- include/VirtualMachineManager.h | 2 +- share/scripts/one | 4 ++-- src/authm/AuthManager.cc | 6 +++-- src/hm/HookManager.cc | 6 +++-- src/im/InformationManager.cc | 8 ++++++- src/image/ImageManager.cc | 6 +++-- src/nebula/Nebula.cc | 41 ++++++++++++++++++++++++++------ src/tm/TransferManager.cc | 10 ++++---- src/vmm/VirtualMachineManager.cc | 8 ++++++- 15 files changed, 93 insertions(+), 46 deletions(-) diff --git a/include/AuthManager.h b/include/AuthManager.h index d620b38867..04b9391656 100644 --- a/include/AuthManager.h +++ b/include/AuthManager.h @@ -80,7 +80,7 @@ public: * identity will be used. Otherwise the Mad will be loaded through the * sudo application. */ - void load_mads(int uid); + int load_mads(int uid); /** * Gets the thread identification. diff --git a/include/HookManager.h b/include/HookManager.h index 13faa936b9..6d19b36f30 100644 --- a/include/HookManager.h +++ b/include/HookManager.h @@ -58,7 +58,7 @@ public: /** * */ - void load_mads(int uid=0); + int load_mads(int uid=0); /** * diff --git a/include/ImageManager.h b/include/ImageManager.h index d8eb8fcb10..ad29897b0e 100644 --- a/include/ImageManager.h +++ b/include/ImageManager.h @@ -62,7 +62,7 @@ public: * identity will be used. Otherwise the Mad will be loaded through the * sudo application. */ - void load_mads(int uid=0); + int load_mads(int uid=0); /** * Gets the thread identification. diff --git a/include/InformationManager.h b/include/InformationManager.h index cae100c7b1..07a9ed5d50 100644 --- a/include/InformationManager.h +++ b/include/InformationManager.h @@ -69,7 +69,7 @@ public: /** * */ - void load_mads(int uid=0); + int load_mads(int uid=0); /** * diff --git a/include/MadManager.h b/include/MadManager.h index d49d895ee9..5a09a516cd 100644 --- a/include/MadManager.h +++ b/include/MadManager.h @@ -48,14 +48,14 @@ public: * crashes */ static void mad_manager_system_init(); - + /** * Loads Virtual Machine Manager Mads defined in configuration file - * @param uid of the user executing the driver. When uid is 0 the nebula + * @param uid of the user executing the driver. When uid is 0 the nebula * identity will be used. Otherwise the Mad will be loaded through the - * sudo application. + * sudo application. */ - virtual void load_mads(int uid) = 0; + virtual int load_mads(int uid) = 0; /** * Notify the result of an auth request @@ -69,23 +69,23 @@ protected: virtual ~MadManager(); /** - * Vector containing Mad configuration for this Manager, as described in + * Vector containing Mad configuration for this Manager, as described in * the nebula location */ vector mad_conf; - + /** * This function initialize the communication pipes to register new MADs * in the manager, and starts a listener to wait for driver messages. */ virtual int start(); - + /** - * This function closes the communication pipes, stops the listener thread, + * This function closes the communication pipes, stops the listener thread, * and finalize the associated drivers. */ - virtual void stop(); + virtual void stop(); /** * Get a mad @@ -102,8 +102,8 @@ protected: int add(Mad *mad); /** - * This function can be periodically executed to check time_outs on - * request. It will fail requests with an expired timeout and will notify + * This function can be periodically executed to check time_outs on + * request. It will fail requests with an expired timeout and will notify * the clients. */ void check_time_outs_action(); @@ -138,7 +138,7 @@ private: { pthread_mutex_unlock(&mutex); }; - + /** * Function to execute the listener method within a new pthread (requires * C linkage) @@ -156,15 +156,15 @@ private: pthread_t listener_thread; /** - * Communication pipe (read end) to link the Manager and the listener + * Communication pipe (read end) to link the Manager and the listener * thread */ int pipe_r; - + /** - * Communication pipe (write end) to link the Manager and the listener + * Communication pipe (write end) to link the Manager and the listener * thread - */ + */ int pipe_w; /** @@ -172,12 +172,12 @@ private: * Mads responses) */ vector fds; - + /** * The sets of Mads managed by the MadManager */ vector mads; - + /** * Read buffer for the listener. This variable is in the class so it * can be free upon listener thread cancellation. @@ -188,7 +188,7 @@ private: * List of pending requests */ map sync_requests; - + /** * Listener thread implementation. */ diff --git a/include/TransferManager.h b/include/TransferManager.h index 7ec8945e86..9e28e05087 100644 --- a/include/TransferManager.h +++ b/include/TransferManager.h @@ -86,7 +86,7 @@ public: * identity will be used. Otherwise the Mad will be loaded through the * sudo application. */ - void load_mads(int uid); + int load_mads(int uid); /** * Gets the thread identification. diff --git a/include/VirtualMachineManager.h b/include/VirtualMachineManager.h index 90a4d042e9..c53b7d7965 100644 --- a/include/VirtualMachineManager.h +++ b/include/VirtualMachineManager.h @@ -103,7 +103,7 @@ public: * identity will be used. Otherwise the Mad will be loaded through the * sudo application. */ - void load_mads(int uid); + int load_mads(int uid); private: /** diff --git a/share/scripts/one b/share/scripts/one index 9625b64a84..1089f2df00 100755 --- a/share/scripts/one +++ b/share/scripts/one @@ -44,7 +44,7 @@ KILL_9_SECONDS=5 BACKUP="true" #------------------------------------------------------------------------------ -# Function that checks for running daemons +# Function that checks for running daemons #------------------------------------------------------------------------------ setup() { @@ -146,7 +146,7 @@ start() start_sched # Wait for the daemons to warm up - sleep 2 + sleep 3 STARTED="true" diff --git a/src/authm/AuthManager.cc b/src/authm/AuthManager.cc index 954cc36785..91f2401d45 100644 --- a/src/authm/AuthManager.cc +++ b/src/authm/AuthManager.cc @@ -314,7 +314,7 @@ error: /* MAD Loading */ /* ************************************************************************** */ -void AuthManager::load_mads(int uid) +int AuthManager::load_mads(int uid) { ostringstream oss; const VectorAttribute * vattr = 0; @@ -334,7 +334,7 @@ void AuthManager::load_mads(int uid) if ( vattr == 0 ) { NebulaLog::log("AuM",Log::ERROR,"Failed to load Auth. Manager driver."); - return; + return -1; } VectorAttribute auth_conf("AUTH_MAD",vattr->value()); @@ -375,4 +375,6 @@ void AuthManager::load_mads(int uid) NebulaLog::log("AuM",Log::INFO,oss); } + + return rc; } diff --git a/src/hm/HookManager.cc b/src/hm/HookManager.cc index 6c2310d515..4810fbb23f 100644 --- a/src/hm/HookManager.cc +++ b/src/hm/HookManager.cc @@ -45,7 +45,7 @@ extern "C" void * hm_action_loop(void *arg) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -void HookManager::load_mads(int uid) +int HookManager::load_mads(int uid) { HookManagerDriver * hm_mad; ostringstream oss; @@ -62,7 +62,7 @@ void HookManager::load_mads(int uid) if ( vattr == 0 ) { NebulaLog::log("HKM",Log::INFO,"Failed to load Hook Manager driver."); - return; + return -1; } VectorAttribute hook_conf("HOOK_MAD",vattr->value()); @@ -80,6 +80,8 @@ void HookManager::load_mads(int uid) NebulaLog::log("HKM",Log::INFO,oss); } + + return rc; } /* -------------------------------------------------------------------------- */ diff --git a/src/im/InformationManager.cc b/src/im/InformationManager.cc index 80513a1bd6..90971e4611 100644 --- a/src/im/InformationManager.cc +++ b/src/im/InformationManager.cc @@ -52,7 +52,7 @@ extern "C" void * im_action_loop(void *arg) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -void InformationManager::load_mads(int uid) +int InformationManager::load_mads(int uid) { InformationManagerDriver * im_mad; unsigned int i; @@ -82,7 +82,13 @@ void InformationManager::load_mads(int uid) NebulaLog::log("InM",Log::INFO,oss); } + else + { + return -1; + } } + + return 0; } /* -------------------------------------------------------------------------- */ diff --git a/src/image/ImageManager.cc b/src/image/ImageManager.cc index 35881d62db..b77185e9f0 100644 --- a/src/image/ImageManager.cc +++ b/src/image/ImageManager.cc @@ -47,7 +47,7 @@ extern "C" void * image_action_loop(void *arg) /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -void ImageManager::load_mads(int uid) +int ImageManager::load_mads(int uid) { ImageManagerDriver * imagem_mad; ostringstream oss; @@ -64,7 +64,7 @@ void ImageManager::load_mads(int uid) if ( vattr == 0 ) { NebulaLog::log("ImM",Log::INFO,"Failed to load Image Manager driver."); - return; + return -1; } VectorAttribute image_conf("IMAGE_MAD",vattr->value()); @@ -82,6 +82,8 @@ void ImageManager::load_mads(int uid) NebulaLog::log("ImM",Log::INFO,oss); } + + return rc; } /* -------------------------------------------------------------------------- */ diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index 66a03d9494..cbba76f372 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -874,18 +874,41 @@ void Nebula::start(bool bootstrap_only) // Load mads // ----------------------------------------------------------- - sleep(2); + sleep(1); - vmm->load_mads(0); + rc = 0; - im->load_mads(0); - tm->load_mads(0); - hm->load_mads(0); - imagem->load_mads(0); + if (vmm->load_mads(0) != 0) + { + goto error_mad; + } + + if (im->load_mads(0) != 0) + { + goto error_mad; + } + + if (tm->load_mads(0) != 0) + { + goto error_mad; + } + + if (hm->load_mads(0) != 0) + { + goto error_mad; + } + + if (imagem->load_mads(0) != 0) + { + goto error_mad; + } if ( authm != 0 ) { - authm->load_mads(0); + if (authm->load_mads(0) != 0) + { + goto error_mad; + } } // ---- Request Manager ---- @@ -964,5 +987,9 @@ void Nebula::start(bool bootstrap_only) xmlCleanupParser(); NebulaLog::log("ONE", Log::INFO, "All modules finalized, exiting.\n"); + +error_mad: + NebulaLog::log("ONE", Log::ERROR, "Could not load driver"); + throw runtime_error("Could not load an OpenNebula driver"); } diff --git a/src/tm/TransferManager.cc b/src/tm/TransferManager.cc index 618ba9cc6d..c769ad045b 100644 --- a/src/tm/TransferManager.cc +++ b/src/tm/TransferManager.cc @@ -260,7 +260,7 @@ void TransferManager::do_action(const string &action, void * arg) (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid); } else - { + { epilog_delete_previous_action(vid); } @@ -272,7 +272,7 @@ void TransferManager::do_action(const string &action, void * arg) (nd.get_lcm())->trigger(LifeCycleManager::EPILOG_SUCCESS,vid); } else - { + { epilog_delete_both_action(vid); } } @@ -1905,7 +1905,7 @@ void TransferManager::migrate_transfer_command( /* MAD Loading */ /* ************************************************************************** */ -void TransferManager::load_mads(int uid) +int TransferManager::load_mads(int uid) { ostringstream oss; @@ -1927,7 +1927,7 @@ void TransferManager::load_mads(int uid) if ( vattr == 0 ) { NebulaLog::log("TM",Log::ERROR,"Failed to load Transfer Manager driver."); - return; + return -1; } VectorAttribute tm_conf("TM_MAD",vattr->value()); @@ -1947,4 +1947,6 @@ void TransferManager::load_mads(int uid) NebulaLog::log("TM",Log::INFO,oss); } + + return rc; } diff --git a/src/vmm/VirtualMachineManager.cc b/src/vmm/VirtualMachineManager.cc index fced901afa..99832cd3ea 100644 --- a/src/vmm/VirtualMachineManager.cc +++ b/src/vmm/VirtualMachineManager.cc @@ -2194,7 +2194,7 @@ error_common: /* MAD Loading */ /* ************************************************************************** */ -void VirtualMachineManager::load_mads(int uid) +int VirtualMachineManager::load_mads(int uid) { unsigned int i; ostringstream oss; @@ -2263,5 +2263,11 @@ void VirtualMachineManager::load_mads(int uid) NebulaLog::log("VMM",Log::INFO,oss); } + else + { + return rc; + } } + + return 0; }