osaf/services/saf/smfsv/smfd/SmfUpgradeAction.cc | 4 +-
osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc | 32 ++++++++++++++++++------
osaf/services/saf/smfsv/smfd/SmfUtils.cc | 20 ++++++++++----
osaf/services/saf/smfsv/smfd/SmfUtils.hh | 2 +-
osaf/services/saf/smfsv/smfd/smfd.h | 2 +
5 files changed, 43 insertions(+), 17 deletions(-)
The smfRebootTimeout indicates the timeperiod for which SMF should
wait for a rebooted node to come up as a part of the
SmfUpgradeStep::nodeReboot step. However, currently additional time can get
consumed when waiting for smfnd and eventually not matching the
smfRebootTimeout parameter set by the user. The patch includes the time
spent in getNodeDestination also to calculate the smfRebootTimeout.
diff --git a/osaf/services/saf/smfsv/smfd/SmfUpgradeAction.cc
b/osaf/services/saf/smfsv/smfd/SmfUpgradeAction.cc
--- a/osaf/services/saf/smfsv/smfd/SmfUpgradeAction.cc
+++ b/osaf/services/saf/smfsv/smfd/SmfUpgradeAction.cc
@@ -174,7 +174,7 @@ SmfCliCommandAction::execute(SaImmOiHand
for (it = m_plmExecEnvList.begin(); it != m_plmExecEnvList.end(); ++it)
{
const std::string& n = it->getPrefered();
SmfndNodeDest nodeDest;
- if (!getNodeDestination(n, &nodeDest)) {
+ if (!getNodeDestination(n, &nodeDest, NULL)) {
LOG_ER("SmfCliCommandAction no node destination found
for node %s", n.c_str());
result = SA_AIS_ERR_NOT_EXIST;
goto done;
@@ -221,7 +221,7 @@ SmfCliCommandAction::rollback(const std:
for (it = m_plmExecEnvList.rbegin(); it != m_plmExecEnvList.rend();
it++) {
const std::string& n = it->getPrefered();
SmfndNodeDest nodeDest;
- if (!getNodeDestination(n, &nodeDest)) {
+ if (!getNodeDestination(n, &nodeDest, NULL)) {
LOG_ER("SmfCliCommandAction no node destination found
for node %s", n.c_str());
result = SA_AIS_ERR_NOT_EXIST;
goto done;
diff --git a/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc
b/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc
--- a/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc
+++ b/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc
@@ -1902,7 +1902,7 @@ SmfUpgradeStep::callActivationCmd()
actCommand.c_str(), getSwNode().c_str());
TRACE("Get node destination for %s", getSwNode().c_str());
- if (!getNodeDestination(getSwNode(), &nodeDest)) {
+ if (!getNodeDestination(getSwNode(), &nodeDest, NULL)) {
LOG_NO("no node destination found for node %s",
getSwNode().c_str());
result = false;
goto done;
@@ -2224,6 +2224,7 @@ SmfUpgradeStep::nodeReboot()
std::string cmd; // Command to enter
int interval; // Retry interval
int timeout; // Connection timeout
+ int elapsedTime; // time spent inside getNodeDestination()
int rebootTimeout = smfd_cb->rebootTimeout / 1000000000; //seconds
int cliTimeout = rebootTimeout/2 * 100; // sec to cs
(10 ms)
int localTimeout = 500; // 500 * 10
ms = 5 seconds
@@ -2252,7 +2253,7 @@ SmfUpgradeStep::nodeReboot()
cmd = smfd_cb->smfNodeRebootCmd;
for (listIt = nodeList.begin(); listIt != nodeList.end(); ++listIt) {
- if (!getNodeDestination(*listIt, &nodeDest)) {
+ if (!getNodeDestination(*listIt, &nodeDest, NULL)) {
LOG_NO("SmfUpgradeStep::nodeReboot: no node
destination found for node %s", (*listIt).c_str());
result = false;
goto done;
@@ -2277,12 +2278,23 @@ SmfUpgradeStep::nodeReboot()
//The nodes has been rebooted, wait for the nodes to come UP with
stepped UP counter
timeout = rebootTimeout; //seconds
- interval = 1;
+
+ // It is possible that the rebootTimeout configured via IMM interface
may be less
+ // than the default 10 seconds spent inside getNodeDestination().
+ // To handle this case, we overwride the userconfigured rebootTimeout
+ // with the default value of 10 seconds
+ if (timeout < 10*ONE_SECOND) {
+ LOG_NO("User configured SMF_REBOOT_TIMEOUT_ATTR is less than 10
seconds");
+ LOG_NO("using a default rebootTimeout of 10 seconds for the
nodes to comeup");
+ timeout = 10*ONE_SECOND;
+ }
+
+ interval = 1*ONE_SECOND;
LOG_NO("SmfUpgradeStep::nodeReboot: Waiting to get node destination
with increased UP counter");
while (true) {
for (nodeIt = rebootedNodeList.begin(); nodeIt !=
rebootedNodeList.end();) {
- if(getNodeDestination((*nodeIt).node_name, &nodeDest))
{
+ if(getNodeDestination((*nodeIt).node_name, &nodeDest,
&elapsedTime)) {
/* Check if node UP counter have been stepped
*/
if(nodeDest.nd_up_cntr > (*nodeIt).nd_up_cntr)
{
cmdNodeList.push_back(*nodeIt);
//Save rebooted nodes for next step
@@ -2297,8 +2309,9 @@ SmfUpgradeStep::nodeReboot()
if(true == rebootedNodeList.empty())
break;
- struct timespec time = { interval, 0 };
- osaf_nanosleep(&time);
+ // Adjust timeout with the time spent inside
getNodeDestination().
+ timeout -= elapsedTime;
+
if (timeout <= 0) {
LOG_NO("SmfUpgradeStep::nodeReboot: the following
nodes has not been correctly rebooted");
for (nodeIt = rebootedNodeList.begin(); nodeIt !=
rebootedNodeList.end(); nodeIt++) {
@@ -2308,7 +2321,10 @@ SmfUpgradeStep::nodeReboot()
goto done;
}
- timeout -= interval;
+ struct timespec time = { interval, 0 };
+ osaf_nanosleep(&time);
+
+ timeout -= interval;
}
//Node is UP, wait for node to accept command "true"
@@ -2319,7 +2335,7 @@ SmfUpgradeStep::nodeReboot()
while (true) {
for (nodeIt = cmdNodeList.begin(); nodeIt !=
cmdNodeList.end();) {
- if(getNodeDestination((*nodeIt).node_name, &nodeDest))
{
+ if(getNodeDestination((*nodeIt).node_name, &nodeDest,
NULL)) {
if (smfnd_exec_remote_cmd(cmd.c_str(),
&nodeDest, cliTimeout, 0) == 0) {
nodeIt = cmdNodeList.erase(nodeIt);
//The node have accepted the command
}
diff --git a/osaf/services/saf/smfsv/smfd/SmfUtils.cc
b/osaf/services/saf/smfsv/smfd/SmfUtils.cc
--- a/osaf/services/saf/smfsv/smfd/SmfUtils.cc
+++ b/osaf/services/saf/smfsv/smfd/SmfUtils.cc
@@ -69,7 +69,8 @@ waitForNodeDestination(const std::string
{
int interval = 2; //seconds
int nodetimeout = smfd_cb->rebootTimeout/1000000000; //seconds
- while (!getNodeDestination(i_node, o_nodeDest)) {
+
+ while (!getNodeDestination(i_node, o_nodeDest, NULL)) {
if (nodetimeout > 0) {
TRACE("No destination found, try again wait %d
seconds", interval);
struct timespec sleepTime = { interval, 0 };
@@ -85,13 +86,16 @@ waitForNodeDestination(const std::string
}
bool
-getNodeDestination(const std::string & i_node, SmfndNodeDest* o_nodeDest)
+getNodeDestination(const std::string & i_node, SmfndNodeDest* o_nodeDest, int
*elapsedTime)
{
SmfImmUtils immUtil;
SaImmAttrValuesT_2 **attributes;
TRACE("Find destination for node '%s'", i_node.c_str());
+ if (elapsedTime) // Initialize elapsedTime to zero.
+ *elapsedTime = 0;
+
/* It seems SaAmfNode objects can be stored, but the code
* indicates that SaClmNode's are expected. Anyway an attempt
* to go for it is probably faster that examining IMM classes
@@ -118,15 +122,17 @@ getNodeDestination(const std::string & i
//after a cluster reboot, it could happend the rebooted nodes comes up
before
//the last one is rebooted. This could make the campaign to fail when
the campaign continue.
if (strcmp(className, "SaClmNode") == 0) {
- int timeout = 10;
+ int timeout = 10*ONE_SECOND;
while(smfnd_for_name(i_node.c_str(), o_nodeDest) == false) {
if (timeout <= 0) {
LOG_NO("Failed to get node dest for clm node
%s", i_node.c_str());
return false;
}
- struct timespec time = { 2, 0 };
+ struct timespec time = { 2*ONE_SECOND, 0 };
osaf_nanosleep(&time);
timeout--;
+ if (elapsedTime)
+ *elapsedTime = *elapsedTime + 2*ONE_SECOND;
}
return true;
@@ -140,16 +146,18 @@ getNodeDestination(const std::string & i
}
char *nodeName = strdup(osaf_extended_name_borrow(clmNode));
- int timeout = 10;
+ int timeout = 10*ONE_SECOND;
while(smfnd_for_name(nodeName, o_nodeDest) == false) {
if (timeout <= 0) {
LOG_NO("Failed to get node dest for clm node
%s", nodeName);
free(nodeName);
return false;
}
- struct timespec time = { 2, 0 };
+ struct timespec time = { 2*ONE_SECOND, 0 };
osaf_nanosleep(&time);
timeout--;
+ if (elapsedTime)
+ *elapsedTime = *elapsedTime + 2*ONE_SECOND;
}
free(nodeName);
} else {
diff --git a/osaf/services/saf/smfsv/smfd/SmfUtils.hh
b/osaf/services/saf/smfsv/smfd/SmfUtils.hh
--- a/osaf/services/saf/smfsv/smfd/SmfUtils.hh
+++ b/osaf/services/saf/smfsv/smfd/SmfUtils.hh
@@ -70,7 +70,7 @@ extern "C" {
}
#endif
extern bool waitForNodeDestination(const std::string & i_node, SmfndNodeDest*
o_nodeDest);
-extern bool getNodeDestination(const std::string & i_node, SmfndNodeDest*
o_nodeDest);
+extern bool getNodeDestination(const std::string & i_node, SmfndNodeDest*
o_nodeDest, int *elapsedTime);
extern std::string replaceAllCopy(const std::string& i_haystack, const
std::string& i_needle, const std::string& i_replacement);
///
diff --git a/osaf/services/saf/smfsv/smfd/smfd.h
b/osaf/services/saf/smfsv/smfd/smfd.h
--- a/osaf/services/saf/smfsv/smfd/smfd.h
+++ b/osaf/services/saf/smfsv/smfd/smfd.h
@@ -56,6 +56,8 @@ extern "C" {
#define SMF_CAMPAIGN_OI_NAME "safSmfCampaign"
#define SMF_PROC_OI_NAME_PREFIX "safSmfProc"
+#define ONE_SECOND 1
+
/* ========================================================================
* TYPE DEFINITIONS
* ========================================================================
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel