From f7a2b50b21d3bbe1fd2cb6bec850b92f0ed9c5c7 Mon Sep 17 00:00:00 2001 From: David Hill Date: Tue, 11 Sep 2018 15:47:25 -0500 Subject: [PATCH] MCOL-1699 - fix iss with adddbroot amazon --- oam/oamcpp/liboamcpp.cpp | 37 +++++++++++++++++++++---------------- procmon/main.cpp | 2 +- procmon/processmonitor.cpp | 4 +++- 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/oam/oamcpp/liboamcpp.cpp b/oam/oamcpp/liboamcpp.cpp index 7483ca239..baa8dbe94 100644 --- a/oam/oamcpp/liboamcpp.cpp +++ b/oam/oamcpp/liboamcpp.cpp @@ -7713,7 +7713,7 @@ namespace oam // run script to get Instance status and IP Address string cmd = InstallDir + "/bin/MCSInstanceCmds.sh getInstance > /tmp/getInstanceInfo_" + name; int status = system(cmd.c_str()); - if (WEXITSTATUS(status) != 0 ) + if (WEXITSTATUS(status) == 1 ) return "failed"; // get Instance Name @@ -7744,7 +7744,7 @@ namespace oam // run script to get Instance status and IP Address string cmd = InstallDir + "/bin/MCSInstanceCmds.sh getType > /tmp/getInstanceType_" + name; int status = system(cmd.c_str()); - if (WEXITSTATUS(status) != 0 ) + if (WEXITSTATUS(status) == 1 ) return "failed"; // get Instance Name @@ -7775,7 +7775,7 @@ namespace oam // run script to get Instance Subnet string cmd = InstallDir + "/bin/MCSInstanceCmds.sh getSubnet > /tmp/getInstanceSubnet_" + name; int status = system(cmd.c_str()); - if (WEXITSTATUS(status) != 0 ) + if (WEXITSTATUS(status) == 1 ) return "failed"; // get Instance Name @@ -7807,7 +7807,7 @@ namespace oam // run script to get Instance status and IP Address string cmd = InstallDir + "/bin/MCSInstanceCmds.sh launchInstance " + IPAddress + " " + type + " " + group + " > /tmp/getInstance_" + name; int status = system(cmd.c_str()); - if (WEXITSTATUS(status) != 0 ) + if (WEXITSTATUS(status) == 1 ) return "failed"; if (checkLogStatus("/tmp/getInstance", "Required") ) @@ -7883,7 +7883,7 @@ namespace oam // run script to get Instance status and IP Address string cmd = InstallDir + "/bin/MCSInstanceCmds.sh startInstance " + instanceName + " > /tmp/startEC2Instance_" + instanceName; int ret = system(cmd.c_str()); - if (WEXITSTATUS(ret) != 0 ) + if (WEXITSTATUS(ret) == 1 ) return false; return true; @@ -7902,7 +7902,7 @@ namespace oam // run script to get Instance status and IP Address string cmd = InstallDir + "/bin/MCSInstanceCmds.sh assignElasticIP " + instanceName + " " + IpAddress + " > /tmp/assignElasticIP_" + instanceName; int ret = system(cmd.c_str()); - if (WEXITSTATUS(ret) != 0 ) + if (WEXITSTATUS(ret) == 1 ) exceptionControl("assignElasticIP", oam::API_FAILURE); return true; @@ -7921,7 +7921,7 @@ namespace oam // run script to get Instance status and IP Address string cmd = InstallDir + "/bin/MCSInstanceCmds.sh deassignElasticIP " + IpAddress + " > /tmp/deassignElasticIP_" + IpAddress; int ret = system(cmd.c_str()); - if (WEXITSTATUS(ret) != 0 ) + if (WEXITSTATUS(ret) == 1 ) exceptionControl("deassignElasticIP", oam::API_FAILURE); return true; @@ -7940,8 +7940,9 @@ namespace oam // run script to get Volume Status string cmd = InstallDir + "/bin/MCSVolumeCmds.sh describe " + volumeName + " > /tmp/getVolumeStatus_" + volumeName; int ret = system(cmd.c_str()); - if (WEXITSTATUS(ret) != 0 ) + if (WEXITSTATUS(ret) == 1 ){ return "failed"; + } // get status string status; @@ -7971,7 +7972,7 @@ namespace oam // run script to get Volume Status string cmd = InstallDir + "/bin/MCSVolumeCmds.sh create " + size + " " + name + " > /tmp/createVolumeStatus_" + name; int ret = system(cmd.c_str()); - if (WEXITSTATUS(ret) != 0 ) + if (WEXITSTATUS(ret) == 1 ) return "failed"; // get status @@ -8016,11 +8017,15 @@ namespace oam string cmd = InstallDir + "/bin/MCSVolumeCmds.sh attach " + volumeName + " " + instanceName + " " + deviceName + " > /tmp/attachVolumeStatus_" + volumeName; ret = system(cmd.c_str()); - if (WEXITSTATUS(ret) == 0 ) + if (WEXITSTATUS(ret) == 1 ) + { + //failing to attach, dettach and retry + writeLog("attachEC2Volume: Attach failed, call detach:" + volumeName + " " + instanceName + " " + deviceName, LOG_TYPE_ERROR ); + + detachEC2Volume(volumeName); + } + else return true; - - //failing to attach, dettach and retry - detachEC2Volume(volumeName); } if (ret == 0 ) @@ -8042,7 +8047,7 @@ namespace oam // run script to attach Volume string cmd = InstallDir + "/bin/MCSVolumeCmds.sh detach " + volumeName + " > /tmp/detachVolumeStatus_" + volumeName; int ret = system(cmd.c_str()); - if (WEXITSTATUS(ret) != 0 ) + if (WEXITSTATUS(ret) == 1 ) return false; return true; @@ -8061,7 +8066,7 @@ namespace oam // run script to delete Volume string cmd = InstallDir + "/bin/MCSVolumeCmds.sh delete " + volumeName + " > /tmp/deleteVolumeStatus_" + volumeName; int ret = system(cmd.c_str()); - if (WEXITSTATUS(ret) != 0 ) + if (WEXITSTATUS(ret) == 1 ) return false; return true; @@ -8080,7 +8085,7 @@ namespace oam // run script to create a tag string cmd = InstallDir + "/bin/MCSVolumeCmds.sh createTag " + resourceName + " " + tagName + " " + tagValue + " > /tmp/createTagStatus_" + resourceName; int ret = system(cmd.c_str()); - if (WEXITSTATUS(ret) != 0 ) + if (WEXITSTATUS(ret) == 1 ) return false; return true; diff --git a/procmon/main.cpp b/procmon/main.cpp index ad05a4f95..d877bdcfe 100644 --- a/procmon/main.cpp +++ b/procmon/main.cpp @@ -210,7 +210,7 @@ int main(int argc, char **argv) } catch(...) {} - if ( cloud == "amazon-ec2" ) { + if ( cloud == "amazon-ec2" || cloud == "amazon-vpc" ) { if(!aMonitor.amazonIPCheck()) { log.writeLog(__LINE__, "ERROR: amazonIPCheck failed, exiting", LOG_TYPE_CRITICAL); sleep(2); diff --git a/procmon/processmonitor.cpp b/procmon/processmonitor.cpp index efa01c449..bf471e62c 100644 --- a/procmon/processmonitor.cpp +++ b/procmon/processmonitor.cpp @@ -5491,7 +5491,6 @@ bool ProcessMonitor::amazonIPCheck() log.writeLog(__LINE__, "Assign Elastic IP Address failed : '" + moduleName + "' / '" + ELIPaddress, LOG_TYPE_ERROR); break; } - break; } @@ -5653,8 +5652,11 @@ bool ProcessMonitor::amazonVolumeCheck(int dbrootID) {} if (oam.attachEC2Volume(volumeName, deviceName, instanceName)) { + log.writeLog(__LINE__, "amazonVolumeCheck function , volume to attached: " + volumeName, LOG_TYPE_DEBUG); + string cmd = "mount " + startup::StartUp::installDir() + "/data" + oam.itoa(dbrootID) + " > /dev/null"; system(cmd.c_str()); + log.writeLog(__LINE__, "amazonVolumeCheck function , volume to mounted: " + volumeName, LOG_TYPE_DEBUG); return true; } else