ACK
On 09/29/2016 02:45 PM, Lennart Lund wrote:
> osaf/services/saf/smfsv/smfd/SmfUpgradeStep.cc | 93
> ++++++++++++++++++-------
> osaf/services/saf/smfsv/smfd/SmfUpgradeStep.hh | 3 +-
> 2 files changed, 67 insertions(+), 29 deletions(-)
>
>
> Fix the deleteNodeGroup() method must be so that if the delete operation fails
> with bad handles new handles are created so that the node group can be deleted
>
> 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
> @@ -2823,7 +2823,7 @@ SmfAdminOperation::SmfAdminOperation(std
> // and an immediate return is done
> // The public methods shall return fail if m_creation_fail is true
>
> - bool rc = getAllImmHandles();
> + bool rc = initAllImmHandles();
> if (rc == false) {
> LOG_NO("%s: getAllImmHandles Fail", __FUNCTION__);
> m_creation_fail = true;
> @@ -2860,11 +2860,7 @@ SmfAdminOperation::SmfAdminOperation(std
>
> SmfAdminOperation::~SmfAdminOperation()
> {
> - // This frees all IMM handles that's based on the omHandle and
> - // give up admin ownership of Amf Cluster object
> - if (m_omHandle != 0) {
> - (void)immutil_saImmOmFinalize(m_omHandle);
> - }
> + finalizeAllImmHandles();
> }
>
> ///
> @@ -3079,7 +3075,7 @@ bool SmfAdminOperation::restart()
> /// Get all needed IMM handles. Updates corresponding member variables
> /// Return false if fail
> ///
> -bool SmfAdminOperation::getAllImmHandles()
> +bool SmfAdminOperation::initAllImmHandles()
> {
> SaAisErrorT ais_rc = SA_AIS_ERR_TRY_AGAIN;
> int timeout_try_cnt = 6;
> @@ -3156,6 +3152,15 @@ bool SmfAdminOperation::getAllImmHandles
> return rc;
> }
>
> +// Free all IMM handles that's based on the omHandle and
> +// give up admin ownership of Amf Cluster object
> +void SmfAdminOperation::finalizeAllImmHandles() {
> + if (m_omHandle != 0) {
> + (void)immutil_saImmOmFinalize(m_omHandle);
> + }
> +
> +}
> +
> /// Check if the AIS return is considered a campaign error
> /// Do not Fail if any of the following AIS codes
> ///
> @@ -3552,6 +3557,8 @@ bool SmfAdminOperation::createNodeGroup(
> // A node group with the same name already exist
> // May happen if a previous delete after usage has
> // failed
> + LOG_NO("%s: saImmOmCcbObjectCreate_2 Fail %s",
> + __FUNCTION__, saf_error(m_errno));
> bool rc = deleteNodeGroup();
> if (rc == false) {
> LOG_NO("%s: deleteNodeGroup() Fail",
> @@ -3591,8 +3598,7 @@ bool SmfAdminOperation::createNodeGroup(
> ///
> bool SmfAdminOperation::deleteNodeGroup()
> {
> - bool rc = true;
> - m_errno = SA_AIS_OK;
> + SaAisErrorT ais_rc = SA_AIS_OK;
>
> TRACE_ENTER();
> std::string nodeGroupName_s =
> @@ -3602,25 +3608,53 @@ bool SmfAdminOperation::deleteNodeGroup(
> &nodeGroupName);
>
> TRACE("\t Deleting nodeGroup '%s'", nodeGroupName_s.c_str());
> -
> - m_errno = immutil_saImmOmCcbObjectDelete(m_ccbHandle,
> - &nodeGroupName);
> - if (m_errno != SA_AIS_OK) {
> - LOG_NO("%s: saImmOmCcbObjectDelete '%s' Fail %s",
> - __FUNCTION__, nodeGroupName_s.c_str(),
> - 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;
> - }
> - }
> -
> - TRACE_LEAVE();
> - return rc;
> + bool method_rc = false;
> + const uint32_t MAX_NO_RETRIES = 2;
> + uint32_t retry_cnt = 0;
> + while (++retry_cnt <= MAX_NO_RETRIES) {
> + // Handles including ccb handle may have been invalidated by
> + // IMM resulting in SA_AIS_ERR_BAD_HANDLE response on the
> + // delete object request.
> + // If that's the case: Try to create new handles and try
> again
> + ais_rc = immutil_saImmOmCcbObjectDelete(m_ccbHandle,
> + &nodeGroupName);
> + TRACE("%s: immutil_saImmOmCcbObjectDelete %s",
> + __FUNCTION__, saf_error(m_errno));
> +
> + if (ais_rc == SA_AIS_ERR_BAD_HANDLE) {
> + LOG_NO("%s: saImmOmCcbObjectDelete Fail %s",
> + __FUNCTION__, saf_error(m_errno));
> + finalizeAllImmHandles();
> + bool rc = initAllImmHandles();
> + if (rc == false) {
> + LOG_NO("%s: getAllImmHandles() Fail",
> + __FUNCTION__);
> + method_rc = false;
> + break;
> + }
> + continue;
> + } else if (ais_rc != SA_AIS_OK) {
> + LOG_NO("%s: saImmOmCcbObjectDelete() '%s' Fail %s",
> + __FUNCTION__, nodeGroupName_s.c_str(),
> + saf_error(ais_rc));
> + method_rc = false;
> + break;
> + } else {
> + ais_rc = saImmOmCcbApply(m_ccbHandle);
> + if (ais_rc != SA_AIS_OK) {
> + LOG_NO("%s: saImmOmCcbApply() Fail '%s'",
> + __FUNCTION__, saf_error(ais_rc));
> + method_rc = false;
> + } else {
> + method_rc = true;
> + }
> + break;
> + }
> + }
> +
> + TRACE_LEAVE2("rc %s, ais_rc %s", method_rc? "Ok":"Fail",
> + saf_error(ais_rc));
> + return method_rc;
> }
>
> /// Request given admin operation to the SmfSetAdminState instance node
> group
> @@ -3655,6 +3689,9 @@ bool SmfAdminOperation::nodeGroupAdminOp
> &nodeGroupName, 0, adminOp, params,
> &oi_rc, smfd_cb->adminOpTimeout);
>
> + if (m_errno == SA_AIS_OK && oi_rc == SA_AIS_OK)
> + break;
> +
> if (retry <= 0) {
> LOG_NO("Fail to invoke admin operation, too many OI "
> "TRY_AGAIN, giving up. %s", __FUNCTION__);
> diff --git a/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.hh
> b/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.hh
> --- a/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.hh
> +++ b/osaf/services/saf/smfsv/smfd/SmfUpgradeStep.hh
> @@ -851,7 +851,8 @@ class SmfAdminOperation {
> bool restart();
>
> private:
> - bool getAllImmHandles();
> + bool initAllImmHandles();
> + void finalizeAllImmHandles();
> bool isRestartError(SaAisErrorT ais_rc);
>
> // Result in m_nodeList and m_suList
------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel