From dbbfb84ea4ade250b2630faae00fb16308233d13 Mon Sep 17 00:00:00 2001 From: Ben Thompson Date: Thu, 7 Sep 2017 14:59:47 -0500 Subject: [PATCH] removeModule fixes, check for glusterd in postConfigure, fix glusterUnassign failure logging. --- oamapps/mcsadmin/mcsadmin.cpp | 113 +++++++++++++++++++----- oamapps/postConfigure/postConfigure.cpp | 21 ++++- procmon/processmonitor.cpp | 4 +- 3 files changed, 110 insertions(+), 28 deletions(-) diff --git a/oamapps/mcsadmin/mcsadmin.cpp b/oamapps/mcsadmin/mcsadmin.cpp index 8d9cd55c3..61b210241 100644 --- a/oamapps/mcsadmin/mcsadmin.cpp +++ b/oamapps/mcsadmin/mcsadmin.cpp @@ -4084,6 +4084,18 @@ int processCommand(string* arguments) case 34: // unassignDbrootPmConfig parameters: dbroot-list reside-pm { + string DataRedundancyConfig = "n"; + try { + oam.getSystemConfig( "DataRedundancyConfig", DataRedundancyConfig); + } + catch(...) + {} + + if (DataRedundancyConfig == "y") { + cout << endl << "**** unassignDbrootPmConfig : command not supported on Data Redundancy configured system. " << endl; + break; + } + if ( localModule != parentOAMModule ) { // exit out since not on active module cout << endl << "**** unassignDbrootPmConfig Failed : Can only run command on Active OAM Parent Module (" << parentOAMModule << ")." << endl; @@ -4153,6 +4165,18 @@ int processCommand(string* arguments) case 35: // assignDbrootPmConfig parameters: pm dbroot-list { + string DataRedundancyConfig = "n"; + try { + oam.getSystemConfig( "DataRedundancyConfig", DataRedundancyConfig); + } + catch(...) + {} + + if (DataRedundancyConfig == "y") { + cout << endl << "**** assignDbrootPmConfig : command not supported on Data Redundancy configured system. " << endl; + break; + } + if ( localModule != parentOAMModule ) { // exit out since not on active module cout << endl << "**** assignDbrootPmConfig Failed : Can only run command on Active OAM Parent Module (" << parentOAMModule << ")." << endl; @@ -5877,6 +5901,30 @@ int processCommand(string* arguments) // check for module status and if any dbroots still assigned for( ; pt != endpt ; pt++) { + // check module status + try{ + bool degraded; + int opState; + oam.getModuleStatus((*pt).DeviceName, opState, degraded); + + if (opState == oam::MAN_OFFLINE || + opState == oam::MAN_DISABLED || + opState == oam::FAILED) + { + + } + else + { + cout << "**** removeModule Failed : " << (*pt).DeviceName << " is not MAN_OFFLINE, DISABLED, or FAILED state."; + quit = true; + cout << endl; + break; + } + } + catch (exception& ex) + {} + + // check dbrootlist should be empty on non data redundancy setups and remove dbroots if dataredundancy removal check passes if ( moduleType == "pm" ) { // check for dbroots assigned DBRootConfigList dbrootConfigList; @@ -5892,9 +5940,10 @@ int processCommand(string* arguments) cout << endl; break; } - else if (DataRedundancyConfig == "y") + else if (DataRedundancyConfig == "y" && !dbrootConfigList.empty()) { bool PMlistError = true; + cout << "Removing DBRoot(s)" << endl; DBRootConfigList::iterator dbrootListPt = dbrootConfigList.begin(); for( ; dbrootListPt != dbrootConfigList.end() ; dbrootListPt++) { @@ -5945,7 +5994,10 @@ int processCommand(string* arguments) { try { - oam.removeDbroot(dbrootConfigList); + if (!dbrootConfigList.empty()) + { + oam.removeDbroot(dbrootConfigList); + } cout << endl << " Successful Removal of DBRoots " << endl << endl; } @@ -5957,27 +6009,6 @@ int processCommand(string* arguments) } } } - - // check module status - try{ - bool degraded; - int opState; - oam.getModuleStatus((*pt).DeviceName, opState, degraded); - - if (opState == oam::MAN_OFFLINE || - opState == oam::MAN_DISABLED || - opState == oam::FAILED) - continue; - else - { - cout << "**** removeModule Failed : " << (*pt).DeviceName << " is not MAN_OFFLINE, DISABLED, or FAILED state."; - quit = true; - cout << endl; - break; - } - } - catch (exception& ex) - {} } if (quit) { @@ -6842,6 +6873,15 @@ int processCommand(string* arguments) case 65: // alterSystem-disableModule { + + string DataRedundancyConfig = "n"; + int DataRedundancyCopies; + try { + oam.getSystemConfig( "DataRedundancyConfig", DataRedundancyConfig); + } + catch(...) + {} + if ( SingleServerInstall == "y" ) { // exit out since not on single-server install cout << endl << "**** alterSystem-disableModule Failed : not support on a Single-Server type installs " << endl; @@ -6929,12 +6969,37 @@ int processCommand(string* arguments) catch(...) {} - if ( !dbrootConfigList.empty() ) { + if ( !dbrootConfigList.empty() && DataRedundancyConfig == "n") { cout << endl << "**** alterSystem-disableModule Failed : " << (*pt).DeviceName << " has dbroots still assigned and will not be disabled. Please run movePmDbrootConfig or unassignDbrootPmConfig."; quit = true; cout << endl; break; } + else if (!dbrootConfigList.empty() && DataRedundancyConfig == "y") + { + //check if dbroot requested to be removed is empty and dboot #1 is requested to be removed + DBRootConfigList::iterator pt = dbrootConfigList.begin(); + for( ; pt != dbrootConfigList.end() ; pt++) + { + int dbrootID = *pt; + + //check if dbroot is empty + bool isEmpty = false; + string errMsg; + try + { + BRM::DBRM dbrm; + if ( dbrm.isDBRootEmpty(dbrootID, isEmpty, errMsg) != 0) + { + cout << endl << "**** alterSystem-disableModule Failed : Data Redundancy detected DBRoots must be empty to be disabled. Remove data from DBRoot #" << oam.itoa(dbrootID) << " to continue."<< endl; + cout << "ERROR: isDBRootEmpty API error, dbroot #" << oam.itoa(dbrootID) << " :" << errMsg << endl; + quit = true; + } + } + catch (...) + {} + } + } } if (quit) { diff --git a/oamapps/postConfigure/postConfigure.cpp b/oamapps/postConfigure/postConfigure.cpp index b63d83986..e02d20b66 100644 --- a/oamapps/postConfigure/postConfigure.cpp +++ b/oamapps/postConfigure/postConfigure.cpp @@ -4510,7 +4510,9 @@ bool storageSetup(bool amazonInstall) { cout << " 'DataRedundancy' - This is specified when gluster is installed and you want" << endl; cout << " the DBRoot directories to be controlled by ColumnStore Data Redundancy." << endl; - cout << " High Availability Server Failover is Supported in this mode." << endl << endl; + cout << " High Availability Server Failover is Supported in this mode." << endl; + cout << " NOTE: glusterd service must be running and enabled on all PMs." << endl << endl; + } if ( hadoopInstalled == "y" ) @@ -4797,6 +4799,14 @@ bool storageSetup(bool amazonInstall) // if gluster if ( storageType == "3" ) { + string command = "stat /var/run/glusterd.pid > /dev/null 2>&1"; + int status = system(command.c_str()); + if (WEXITSTATUS(status) != 0 ) + { + cout << "ERROR: No glusterd process detected. " << endl; + cout << " Start and enable glusterd on all PMs and run postConfigure again." << endl; + return false; + } DataRedundancy = true; sysConfig->setConfig(InstallSection, "DataRedundancyConfig", "y"); sysConfig->setConfig("PrimitiveServers", "DirectIO", "n"); @@ -5891,7 +5901,14 @@ bool glusterSetup(string password) { } } sleep(5); - command = "gluster peer status >> /tmp/glusterCommands.txt 2>&1"; + if (rootUser) + { + command = "gluster peer status >> /tmp/glusterCommands.txt 2>&1"; + } + else + { + command = "sudo gluster peer status >> /tmp/glusterCommands.txt 2>&1"; + } status = system(command.c_str()); if (WEXITSTATUS(status) != 0 ) { diff --git a/procmon/processmonitor.cpp b/procmon/processmonitor.cpp index 9dcb7fad3..36231c431 100644 --- a/procmon/processmonitor.cpp +++ b/procmon/processmonitor.cpp @@ -5871,7 +5871,7 @@ int ProcessMonitor::checkDataMount() } } - if ( dbrootList.size() == 0 ) { + if ( dbrootList.size() == 0 && DataRedundancyConfig != "y") { log.writeLog(__LINE__, "No dbroots are configured in Columnstore.xml file", LOG_TYPE_WARNING); return API_INVALID_PARAMETER; } @@ -6184,7 +6184,7 @@ int ProcessMonitor::glusterUnassign(std::string dbrootID) int size = in.tellg(); if ( size != 0 ) { - if (!oam.checkLogStatus("/tmp/glusterAssign.txt", "not mounted")) { + if (!oam.checkLogStatus("/tmp/glusterUnassign.txt", "not mounted")) { log.writeLog(__LINE__, "glusterUnassign failed.", LOG_TYPE_ERROR); system("mv -f /tmp/glusterUnassign.txt /tmp/glusterUnassign_failed.txt"); return oam::API_FAILURE;