[devel] [PATCH 1 of 1] smf: Delete node group if already exist when creating [#2049]
osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc | 76 - 1 files changed, 49 insertions(+), 27 deletions(-) If a node group for admin operation already exist when create is done the existing group shall be deleted so that the new group can be created 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 @@ -57,15 +57,13 @@ #include "smfd.h" #include "osaf_time.h" -#if 0 /*LLDTEST*/ -#include "SmfExecControlHdl.h" -#endif - /* * DEFINITIONS * */ +extern struct ImmutilWrapperProfile immutilWrapperProfile; + /* * TYPE DEFINITIONS * @@ -81,8 +79,6 @@ * */ -#define LLDPROTO1 /* The prototype code */ - // // Class SmfUpgradeStep // Purpose: @@ -3450,7 +3446,6 @@ bool SmfAdminOperation::setNodeGroupPare /// bool SmfAdminOperation::createNodeGroup(SaAmfAdminStateT i_fromState) { - bool rc = true; m_errno = SA_AIS_OK; TRACE_ENTER(); @@ -3537,31 +3532,58 @@ bool SmfAdminOperation::createNodeGroup( // // Create the node group - m_errno = immutil_saImmOmCcbObjectCreate_2( - m_ccbHandle, - className, - , - attrValues); - - if (m_errno != SA_AIS_OK) { - LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s", - __FUNCTION__, nGnodeName, saf_error(m_errno)); - rc = false; - } else { - m_errno = saImmOmCcbApply(m_ccbHandle); - if (m_errno != SA_AIS_OK) { - LOG_NO("%s: saImmOmCcbApply() Fail '%s'", - __FUNCTION__, saf_error(m_errno)); - rc = false; - } - } + bool method_rc = false; +const uint32_t MAX_NO_RETRIES = 2; +uint32_t retry_cnt = 0; +while (++retry_cnt <= MAX_NO_RETRIES) { +// Creating the node group object will fail if a previously +// created node group was for some reason not deleted +// If that's the case (SA_AIS_ERR_EXIST) try to delete the +// node group and try again. +m_errno = immutil_saImmOmCcbObjectCreate_2( +m_ccbHandle, +className, +, +attrValues); +TRACE("%s: immutil_saImmOmCcbObjectCreate_2 %s", +__FUNCTION__, saf_error(m_errno)); + +if (m_errno == SA_AIS_ERR_EXIST) { +// A node group with the same name already exist +// May happen if a previous delete after usage has +// failed +bool rc = deleteNodeGroup(); +if (rc == false) { +LOG_NO("%s: deleteNodeGroup() Fail", + __FUNCTION__); +method_rc = false; +break; +} +continue; +} else if (m_errno != SA_AIS_OK) { +LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s", +__FUNCTION__, nGnodeName, saf_error(m_errno)); +method_rc = false; +break; +} else { +m_errno = saImmOmCcbApply(m_ccbHandle); +if (m_errno != SA_AIS_OK) { +LOG_NO("%s: saImmOmCcbApply() Fail '%s'", +__FUNCTION__, saf_error(m_errno)); +method_rc = false; +} else { +method_rc = true; +} +break; +} +} if (nodeName != NULL) free(nodeName); if (nodeNameList != NULL) free(nodeNameList); - TRACE_LEAVE(); - return rc; + TRACE_LEAVE2("rc %s", method_rc? "Ok":"Fail"); + return method_rc; } /// Delete the SmfSetAdminState instance specific node group -- ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net
Re: [devel] [PATCH 1 of 1] smf: Delete node group if already exist when creating [#2049]
Hi Neel I have updated the patches based on your comments and will send them for re-review today Thanks Lennart > -Original Message- > From: Neelakanta Reddy [mailto:reddy.neelaka...@oracle.com] > Sent: den 27 september 2016 14:25 > To: Lennart Lund; Rafael Odzakow > > Cc: opensaf-devel@lists.sourceforge.net > Subject: Re: [PATCH 1 of 1] smf: Delete node group if already exist when > creating [#2049] > > Hi Leenart, > > returning of ERR_EXIST is very rare, and not as frequent as BAD_HANDLE. > Still, not satisfied with infinite loop, without finite re-trys. > > Ack from me. > > Thanks, > Neel. > > On 2016/09/27 05:14 PM, Lennart Lund wrote: > > Hi Neel > > > > See my comments/answer tagged [Lennart] > > > > Thanks > > Lennart > > > >> -Original Message- > >> From: Neelakanta Reddy [mailto:reddy.neelaka...@oracle.com] > >> Sent: den 27 september 2016 11:21 > >> To: Lennart Lund ; Rafael Odzakow > >> > >> Cc: opensaf-devel@lists.sourceforge.net > >> Subject: Re: [PATCH 1 of 1] smf: Delete node group if already exist when > >> creating [#2049] > >> > >> Hi Lennart, > >> > >> Reviewed the patch. Following are the comments: > >> > >> 1. Do not use infinite loops like while(true), In this case while loop > >> is not required. > > [Lennart] I have chosen to use a loop since > immutil_saImmOmCcbObjectCreate_2() may have to be called more than > once > > See also my answers for ticket #2046. The condition for this loop to > continue is SA_AIS_ERR_EXIST (in #2046 it's SA_AIS_ERR_BAD_HANDLE) > otherwise the mechanism is the same. > > > >> 2. comments inline. > >> > >> Thanks, > >> Neel. > >> > >> > >> On 2016/09/22 08:34 PM, Lennart Lund wrote: > >>>osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc | 51 > >> - > >>>1 files changed, 33 insertions(+), 18 deletions(-) > >>> > >>> > >>> If a node group for admin operation already exist when create is done > the > >>> existing group shall be deleted so that the new group can be created > >>> > >>> 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 > >>> @@ -3537,24 +3537,39 @@ bool > SmfAdminOperation::createNodeGroup( > >>> > >>> // > >>> // Create the node group > >>> - m_errno = immutil_saImmOmCcbObjectCreate_2( > >>> - m_ccbHandle, > >>> - className, > >>> - , > >>> - attrValues); > >>> - > >>> - if (m_errno != SA_AIS_OK) { > >>> - LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s", > >>> - __FUNCTION__, nGnodeName, > >> saf_error(m_errno)); > >>> - rc = false; > >>> - } else { > >>> - m_errno = saImmOmCcbApply(m_ccbHandle); > >>> - if (m_errno != SA_AIS_OK) { > >>> - LOG_NO("%s: saImmOmCcbApply() Fail '%s'", > >>> - __FUNCTION__, saf_error(m_errno)); > >>> - rc = false; > >>> - } > >>> - } > >>> +while (true) { > >>> +m_errno = immutil_saImmOmCcbObjectCreate_2( > >>> +m_ccbHandle, > >>> +className, > >>> +, > >>> +attrValues); > >>> + > >>> +if (m_errno == SA_AIS_ERR_EXIST) { > >>> +// A node group with the same name already exist > >>> +// May happen if delete after usage has failed > >>> +bool rc = deleteNodeGroup(); > >>> +if (rc == false) { > >>> +LOG_NO("%s: deleteNodeGroup() Fail", > >>> + __FUNCTION__); > >>> +break; > >>> +} > >> in the else codition, if deleteNodeGroup is true call > >> immutil_saImmOmCcbObjectCreate_2. In deleteNodeGroup there are > >> retries > >> for deleting. > >> No need to have while loop, > > [Lennart] I have chosen to use a loop instead of a sequence that has a call > of immutil_saImmOmCcbObjectCreate_2() in two places. > > This solution also encapsulates all saImmOmCcbObjectCreate_2 handling > including deleting if needed and the error handling > >>> +continue; > >>> +} > >>> +if (m_errno != SA_AIS_OK) { > >>> +LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail > >>> %s", > >>> +__FUNCTION__, nGnodeName, > >>> saf_error(m_errno)); > >>> +rc = false; > >>> +break; > >>> +} else { > >>> +m_errno = saImmOmCcbApply(m_ccbHandle); > >>> +if (m_errno != SA_AIS_OK) { > >>>
Re: [devel] [PATCH 1 of 1] smf: Delete node group if already exist when creating [#2049]
Hi Leenart, returning of ERR_EXIST is very rare, and not as frequent as BAD_HANDLE. Still, not satisfied with infinite loop, without finite re-trys. Ack from me. Thanks, Neel. On 2016/09/27 05:14 PM, Lennart Lund wrote: > Hi Neel > > See my comments/answer tagged [Lennart] > > Thanks > Lennart > >> -Original Message- >> From: Neelakanta Reddy [mailto:reddy.neelaka...@oracle.com] >> Sent: den 27 september 2016 11:21 >> To: Lennart Lund; Rafael Odzakow >> >> Cc: opensaf-devel@lists.sourceforge.net >> Subject: Re: [PATCH 1 of 1] smf: Delete node group if already exist when >> creating [#2049] >> >> Hi Lennart, >> >> Reviewed the patch. Following are the comments: >> >> 1. Do not use infinite loops like while(true), In this case while loop >> is not required. > [Lennart] I have chosen to use a loop since > immutil_saImmOmCcbObjectCreate_2() may have to be called more than once > See also my answers for ticket #2046. The condition for this loop to continue > is SA_AIS_ERR_EXIST (in #2046 it's SA_AIS_ERR_BAD_HANDLE) otherwise the > mechanism is the same. > >> 2. comments inline. >> >> Thanks, >> Neel. >> >> >> On 2016/09/22 08:34 PM, Lennart Lund wrote: >>>osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc | 51 >> - >>>1 files changed, 33 insertions(+), 18 deletions(-) >>> >>> >>> If a node group for admin operation already exist when create is done the >>> existing group shall be deleted so that the new group can be created >>> >>> 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 >>> @@ -3537,24 +3537,39 @@ bool SmfAdminOperation::createNodeGroup( >>> >>> // >>> // Create the node group >>> - m_errno = immutil_saImmOmCcbObjectCreate_2( >>> - m_ccbHandle, >>> - className, >>> - , >>> - attrValues); >>> - >>> - if (m_errno != SA_AIS_OK) { >>> - LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s", >>> - __FUNCTION__, nGnodeName, >> saf_error(m_errno)); >>> - rc = false; >>> - } else { >>> - m_errno = saImmOmCcbApply(m_ccbHandle); >>> - if (m_errno != SA_AIS_OK) { >>> - LOG_NO("%s: saImmOmCcbApply() Fail '%s'", >>> - __FUNCTION__, saf_error(m_errno)); >>> - rc = false; >>> - } >>> - } >>> +while (true) { >>> +m_errno = immutil_saImmOmCcbObjectCreate_2( >>> +m_ccbHandle, >>> +className, >>> +, >>> +attrValues); >>> + >>> +if (m_errno == SA_AIS_ERR_EXIST) { >>> +// A node group with the same name already exist >>> +// May happen if delete after usage has failed >>> +bool rc = deleteNodeGroup(); >>> +if (rc == false) { >>> +LOG_NO("%s: deleteNodeGroup() Fail", >>> + __FUNCTION__); >>> +break; >>> +} >> in the else codition, if deleteNodeGroup is true call >> immutil_saImmOmCcbObjectCreate_2. In deleteNodeGroup there are >> retries >> for deleting. >> No need to have while loop, > [Lennart] I have chosen to use a loop instead of a sequence that has a call > of immutil_saImmOmCcbObjectCreate_2() in two places. > This solution also encapsulates all saImmOmCcbObjectCreate_2 handling > including deleting if needed and the error handling >>> +continue; >>> +} >>> +if (m_errno != SA_AIS_OK) { >>> +LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail >>> %s", >>> +__FUNCTION__, nGnodeName, >>> saf_error(m_errno)); >>> +rc = false; >>> +break; >>> +} else { >>> +m_errno = saImmOmCcbApply(m_ccbHandle); >>> +if (m_errno != SA_AIS_OK) { >>> +LOG_NO("%s: saImmOmCcbApply() Fail '%s'", >>> +__FUNCTION__, saf_error(m_errno)); >>> +rc = false; >>> +} >>> +break; >>> +} >>> +} >>> >>> if (nodeName != NULL) >>> free(nodeName); -- ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 1 of 1] smf: Delete node group if already exist when creating [#2049]
Hi Neel See my comments/answer tagged [Lennart] Thanks Lennart > -Original Message- > From: Neelakanta Reddy [mailto:reddy.neelaka...@oracle.com] > Sent: den 27 september 2016 11:21 > To: Lennart Lund; Rafael Odzakow > > Cc: opensaf-devel@lists.sourceforge.net > Subject: Re: [PATCH 1 of 1] smf: Delete node group if already exist when > creating [#2049] > > Hi Lennart, > > Reviewed the patch. Following are the comments: > > 1. Do not use infinite loops like while(true), In this case while loop > is not required. [Lennart] I have chosen to use a loop since immutil_saImmOmCcbObjectCreate_2() may have to be called more than once See also my answers for ticket #2046. The condition for this loop to continue is SA_AIS_ERR_EXIST (in #2046 it's SA_AIS_ERR_BAD_HANDLE) otherwise the mechanism is the same. > 2. comments inline. > > Thanks, > Neel. > > > On 2016/09/22 08:34 PM, Lennart Lund wrote: > > osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc | 51 > - > > 1 files changed, 33 insertions(+), 18 deletions(-) > > > > > > If a node group for admin operation already exist when create is done the > > existing group shall be deleted so that the new group can be created > > > > 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 > > @@ -3537,24 +3537,39 @@ bool SmfAdminOperation::createNodeGroup( > > > > // > > // Create the node group > > - m_errno = immutil_saImmOmCcbObjectCreate_2( > > - m_ccbHandle, > > - className, > > - , > > - attrValues); > > - > > - if (m_errno != SA_AIS_OK) { > > - LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s", > > - __FUNCTION__, nGnodeName, > saf_error(m_errno)); > > - rc = false; > > - } else { > > - m_errno = saImmOmCcbApply(m_ccbHandle); > > - if (m_errno != SA_AIS_OK) { > > - LOG_NO("%s: saImmOmCcbApply() Fail '%s'", > > - __FUNCTION__, saf_error(m_errno)); > > - rc = false; > > - } > > - } > > +while (true) { > > +m_errno = immutil_saImmOmCcbObjectCreate_2( > > +m_ccbHandle, > > +className, > > +, > > +attrValues); > > + > > +if (m_errno == SA_AIS_ERR_EXIST) { > > +// A node group with the same name already exist > > +// May happen if delete after usage has failed > > +bool rc = deleteNodeGroup(); > > +if (rc == false) { > > +LOG_NO("%s: deleteNodeGroup() Fail", > > + __FUNCTION__); > > +break; > > +} > in the else codition, if deleteNodeGroup is true call > immutil_saImmOmCcbObjectCreate_2. In deleteNodeGroup there are > retries > for deleting. > No need to have while loop, [Lennart] I have chosen to use a loop instead of a sequence that has a call of immutil_saImmOmCcbObjectCreate_2() in two places. This solution also encapsulates all saImmOmCcbObjectCreate_2 handling including deleting if needed and the error handling > > > +continue; > > +} > > +if (m_errno != SA_AIS_OK) { > > +LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail > > %s", > > +__FUNCTION__, nGnodeName, > > saf_error(m_errno)); > > +rc = false; > > +break; > > +} else { > > +m_errno = saImmOmCcbApply(m_ccbHandle); > > +if (m_errno != SA_AIS_OK) { > > +LOG_NO("%s: saImmOmCcbApply() Fail '%s'", > > +__FUNCTION__, saf_error(m_errno)); > > +rc = false; > > +} > > +break; > > +} > > +} > > > > if (nodeName != NULL) > > free(nodeName); -- ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 1 of 1] smf: Delete node group if already exist when creating [#2049]
Hi Lennart, Reviewed the patch. Following are the comments: 1. Do not use infinite loops like while(true), In this case while loop is not required. 2. comments inline. Thanks, Neel. On 2016/09/22 08:34 PM, Lennart Lund wrote: > osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc | 51 > - > 1 files changed, 33 insertions(+), 18 deletions(-) > > > If a node group for admin operation already exist when create is done the > existing group shall be deleted so that the new group can be created > > 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 > @@ -3537,24 +3537,39 @@ bool SmfAdminOperation::createNodeGroup( > > // > // Create the node group > - m_errno = immutil_saImmOmCcbObjectCreate_2( > - m_ccbHandle, > - className, > - , > - attrValues); > - > - if (m_errno != SA_AIS_OK) { > - LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s", > - __FUNCTION__, nGnodeName, saf_error(m_errno)); > - rc = false; > - } else { > - m_errno = saImmOmCcbApply(m_ccbHandle); > - if (m_errno != SA_AIS_OK) { > - LOG_NO("%s: saImmOmCcbApply() Fail '%s'", > - __FUNCTION__, saf_error(m_errno)); > - rc = false; > - } > - } > +while (true) { > +m_errno = immutil_saImmOmCcbObjectCreate_2( > +m_ccbHandle, > +className, > +, > +attrValues); > + > +if (m_errno == SA_AIS_ERR_EXIST) { > +// A node group with the same name already exist > +// May happen if delete after usage has failed > +bool rc = deleteNodeGroup(); > +if (rc == false) { > +LOG_NO("%s: deleteNodeGroup() Fail", > + __FUNCTION__); > +break; > +} in the else codition, if deleteNodeGroup is true call immutil_saImmOmCcbObjectCreate_2. In deleteNodeGroup there are retries for deleting. No need to have while loop, > +continue; > +} > +if (m_errno != SA_AIS_OK) { > +LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s", > +__FUNCTION__, nGnodeName, > saf_error(m_errno)); > +rc = false; > +break; > +} else { > +m_errno = saImmOmCcbApply(m_ccbHandle); > +if (m_errno != SA_AIS_OK) { > +LOG_NO("%s: saImmOmCcbApply() Fail '%s'", > +__FUNCTION__, saf_error(m_errno)); > +rc = false; > +} > +break; > +} > +} > > if (nodeName != NULL) > free(nodeName); -- ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 1 of 1] smf: Delete node group if already exist when creating [#2049]
ACK, with comments On 09/23/2016 10:55 AM, Lennart Lund wrote: > My own review comments: > > See [Lennart] inline > > /Lennart > >> -Original Message- >> From: Lennart Lund [mailto:lennart.l...@ericsson.com] >> Sent: den 22 september 2016 17:04 >> To: Rafael Odzakow <rafael.odza...@ericsson.com>; >> reddy.neelaka...@oracle.com >> Cc: opensaf-devel@lists.sourceforge.net >> Subject: [devel] [PATCH 1 of 1] smf: Delete node group if already exist when >> creating [#2049] >> >> osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc | 51 >> - >> 1 files changed, 33 insertions(+), 18 deletions(-) >> >> >> If a node group for admin operation already exist when create is done the >> existing group shall be deleted so that the new group can be created >> >> 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 >> @@ -3537,24 +3537,39 @@ bool SmfAdminOperation::createNodeGroup( >> >> // >> // Create the node group >> -m_errno = immutil_saImmOmCcbObjectCreate_2( >> -m_ccbHandle, >> -className, >> -, >> -attrValues); >> - >> -if (m_errno != SA_AIS_OK) { >> -LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s", >> -__FUNCTION__, nGnodeName, >> saf_error(m_errno)); >> -rc = false; >> -} else { >> -m_errno = saImmOmCcbApply(m_ccbHandle); >> -if (m_errno != SA_AIS_OK) { >> -LOG_NO("%s: saImmOmCcbApply() Fail '%s'", >> -__FUNCTION__, saf_error(m_errno)); >> -rc = false; >> -} >> -} >> +while (true) { [rafael] suggestion is to not use while loop, instead call ObjectCreate twice >> +m_errno = immutil_saImmOmCcbObjectCreate_2( >> +m_ccbHandle, >> +className, >> +, >> +attrValues); >> + >> +if (m_errno == SA_AIS_ERR_EXIST) { >> +// A node group with the same name already exist >> +// May happen if delete after usage has failed >> +bool rc = deleteNodeGroup(); > [Lennart] Incorrect scope of rc > >> +if (rc == false) { >> +LOG_NO("%s: deleteNodeGroup() Fail", >> + __FUNCTION__); >> +break; >> +} >> +continue; >> +} >> +if (m_errno != SA_AIS_OK) { >> +LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail >> %s", >> +__FUNCTION__, nGnodeName, >> saf_error(m_errno)); >> +rc = false; >> +break; >> +} else { >> +m_errno = saImmOmCcbApply(m_ccbHandle); >> +if (m_errno != SA_AIS_OK) { >> +LOG_NO("%s: saImmOmCcbApply() Fail '%s'", >> +__FUNCTION__, saf_error(m_errno)); >> +rc = false; >> +} >> +break; >> +} >> +} >> >> if (nodeName != NULL) >> free(nodeName); >> >> -- >> ___ >> Opensaf-devel mailing list >> Opensaf-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/opensaf-devel -- ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
Re: [devel] [PATCH 1 of 1] smf: Delete node group if already exist when creating [#2049]
My own review comments: See [Lennart] inline /Lennart > -Original Message- > From: Lennart Lund [mailto:lennart.l...@ericsson.com] > Sent: den 22 september 2016 17:04 > To: Rafael Odzakow <rafael.odza...@ericsson.com>; > reddy.neelaka...@oracle.com > Cc: opensaf-devel@lists.sourceforge.net > Subject: [devel] [PATCH 1 of 1] smf: Delete node group if already exist when > creating [#2049] > > osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc | 51 > - > 1 files changed, 33 insertions(+), 18 deletions(-) > > > If a node group for admin operation already exist when create is done the > existing group shall be deleted so that the new group can be created > > 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 > @@ -3537,24 +3537,39 @@ bool SmfAdminOperation::createNodeGroup( > > // > // Create the node group > - m_errno = immutil_saImmOmCcbObjectCreate_2( > - m_ccbHandle, > - className, > - , > - attrValues); > - > - if (m_errno != SA_AIS_OK) { > - LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s", > - __FUNCTION__, nGnodeName, > saf_error(m_errno)); > - rc = false; > - } else { > - m_errno = saImmOmCcbApply(m_ccbHandle); > - if (m_errno != SA_AIS_OK) { > - LOG_NO("%s: saImmOmCcbApply() Fail '%s'", > - __FUNCTION__, saf_error(m_errno)); > - rc = false; > - } > - } > +while (true) { > +m_errno = immutil_saImmOmCcbObjectCreate_2( > +m_ccbHandle, > +className, > +, > +attrValues); > + > +if (m_errno == SA_AIS_ERR_EXIST) { > +// A node group with the same name already exist > +// May happen if delete after usage has failed > +bool rc = deleteNodeGroup(); [Lennart] Incorrect scope of rc > +if (rc == false) { > +LOG_NO("%s: deleteNodeGroup() Fail", > + __FUNCTION__); > +break; > +} > +continue; > +} > +if (m_errno != SA_AIS_OK) { > +LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s", > +__FUNCTION__, nGnodeName, > saf_error(m_errno)); > +rc = false; > +break; > +} else { > +m_errno = saImmOmCcbApply(m_ccbHandle); > +if (m_errno != SA_AIS_OK) { > +LOG_NO("%s: saImmOmCcbApply() Fail '%s'", > +__FUNCTION__, saf_error(m_errno)); > +rc = false; > +} > +break; > +} > +} > > if (nodeName != NULL) > free(nodeName); > > -- > ___ > Opensaf-devel mailing list > Opensaf-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/opensaf-devel -- ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel
[devel] [PATCH 1 of 1] smf: Delete node group if already exist when creating [#2049]
osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc | 51 - 1 files changed, 33 insertions(+), 18 deletions(-) If a node group for admin operation already exist when create is done the existing group shall be deleted so that the new group can be created 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 @@ -3537,24 +3537,39 @@ bool SmfAdminOperation::createNodeGroup( // // Create the node group - m_errno = immutil_saImmOmCcbObjectCreate_2( - m_ccbHandle, - className, - , - attrValues); - - if (m_errno != SA_AIS_OK) { - LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s", - __FUNCTION__, nGnodeName, saf_error(m_errno)); - rc = false; - } else { - m_errno = saImmOmCcbApply(m_ccbHandle); - if (m_errno != SA_AIS_OK) { - LOG_NO("%s: saImmOmCcbApply() Fail '%s'", - __FUNCTION__, saf_error(m_errno)); - rc = false; - } - } +while (true) { +m_errno = immutil_saImmOmCcbObjectCreate_2( +m_ccbHandle, +className, +, +attrValues); + +if (m_errno == SA_AIS_ERR_EXIST) { +// A node group with the same name already exist +// May happen if delete after usage has failed +bool rc = deleteNodeGroup(); +if (rc == false) { +LOG_NO("%s: deleteNodeGroup() Fail", + __FUNCTION__); +break; +} +continue; +} +if (m_errno != SA_AIS_OK) { +LOG_NO("%s: saImmOmCcbObjectCreate_2() '%s' Fail %s", +__FUNCTION__, nGnodeName, saf_error(m_errno)); +rc = false; +break; +} else { +m_errno = saImmOmCcbApply(m_ccbHandle); +if (m_errno != SA_AIS_OK) { +LOG_NO("%s: saImmOmCcbApply() Fail '%s'", +__FUNCTION__, saf_error(m_errno)); +rc = false; +} +break; +} +} if (nodeName != NULL) free(nodeName); -- ___ Opensaf-devel mailing list Opensaf-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensaf-devel