Hi Alex, Robert Thanks for the review,

see comments inline:

----- [email protected] wrote:

> Hi Mathi,
> 
> My comments:
> 
> -I agree with Alex about zeroing the "elapsedTime".

Okay. Not sure when the zeroing got removed in one of the iterations of the 
patch that i was working on.

> 
> -I think you should give a solution for the problem which you wrote as
> a comment in the code(instead of a question):
> // In this case, Should we overwride the userconfigured rebootTimeout
> // with the default value of 10 seconds?

Well, i wanted to get the agreement of reviewers on the solution that i 
have suggested as a part of the comment! :-)

Looks like there is no disagreement here, i will make it to default to 10 
seconds
in the next version of the patch.

> 
> -I would use some constant or variable for the wait time ("2") at
> getNodeDestination():

Well, these magic numbers are in many places in the code. Perhaps we need a 
specific
stab at them. Anyways, To keep the ticket's context, will define a constant
for this part of the code highlighted below.

Thanks,
Mathi.

> struct timespec time = { 2, 0 };
> osaf_nanosleep(&time);
> timeout--;
> if (elapsedTime)
> *elapsedTime = *elapsedTime + 2;
> 
> Br,
> 
> Robert
> 
> 
> On 04/07/2015 08:42 PM, Alex Jones wrote:
> 
> 
> Hi Mathi,
> 
>       I am also interested in this fix, since I am seeing this problem.
> 
>       I tested it out, and I see one problem (easily fixed).
> 
>       Before calling getNodeDestination(), and passing in elapsedTime, you
> need to set it to zero each time.  Otherwise, elapsedTime gets larger
> and larger.  Maybe it makes the most sense to just set it to zero at
> the top of getNodeDestination() if it is passed in, instead of
> requiring the user to make sure it is zero each time
> getNodeDestination() is called?
> 
>       See the comment below in the code.
> 
> Alex
> 
> 
> ------------------------------
> 
> Message: 4
> Date: Tue, 07 Apr 2015 19:45:51 +0530
> From: [email protected] Subject: [devel] [PATCH 1 of 1] smfd:
> adjust smfRebootTimeout to
>       include time spent in getNodeDestination [#1272]
> To: [email protected] , [email protected] Cc:
> [email protected] Message-ID:
> <fa6f359eec6cd610d9b0.1428416151@ubuntu>
> Content-Type: text/plain; charset="us-ascii"
> 
>  osaf/services/saf/smfsv/smfd/SmfUpgradeAction.cc |   4 ++--
>  osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc   |  24
> +++++++++++++++++-------
>  osaf/services/saf/smfsv/smfd/SmfUtils.cc         |   9 +++++++--
>  osaf/services/saf/smfsv/smfd/SmfUtils.hh         |   2 +-
>  4 files changed, 27 insertions(+), 12 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;
> @@ -2282,7 +2283,7 @@ SmfUpgradeStep::nodeReboot()
> 
>       while (true) {
>                  for (nodeIt = rebootedNodeList.begin(); nodeIt !=
> rebootedNodeList.end();) { [Alex] elapsedTime = 0; -                  
>      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 +2298,14 @@ SmfUpgradeStep::nodeReboot()
>                  if(true == rebootedNodeList.empty())
>                       break;
> 
> -                struct timespec time = { interval, 0 };
> -                osaf_nanosleep(&time);
> +               // Time spent in getNodeDestination. It is possible
> that the rebootTimeout
> +               // configured via IMM interface may be less than the
> default 10 seconds spent
> +               // inside getNodeDestination().
> +               // In this case, Should we overwride the
> userconfigured rebootTimeout
> +               // with the default value of 10 seconds?
> +
> +                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 +2315,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 +2329,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,7 +86,7 @@ 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;
> @@ -127,6 +128,8 @@ getNodeDestination(const std::string & i
>                          struct timespec time = { 2, 0 };
>                          osaf_nanosleep(&time);
>                          timeout--;
> +                        if (elapsedTime)
> +                                *elapsedTime = *elapsedTime + 2;
>                  }
>                  return true;
> 
> @@ -150,6 +153,8 @@ getNodeDestination(const std::string & i
>                          struct timespec time = { 2, 0 };
>                          osaf_nanosleep(&time);
>                          timeout--;
> +                        if (elapsedTime)
> +                                *elapsedTime = *elapsedTime + 2;
>                  }
>                  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);
> 
>  ///

------------------------------------------------------------------------------
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

Reply via email to