VOL-4147
Add support of setting operation state to RECONCILE_FAILED from adapters

Change-Id: I419517fc741abb5d625862740c91e291f02df89f
diff --git a/rw_core/core/device/agent.go b/rw_core/core/device/agent.go
index 22ed4c4..c2705e9 100755
--- a/rw_core/core/device/agent.go
+++ b/rw_core/core/device/agent.go
@@ -416,7 +416,7 @@
 	if !agent.proceedWithRequestNoLock() {
 		agent.requestQueue.RequestComplete()
 
-		desc = fmt.Sprintf("deviceId:%s, Device deletion or reconciling is in progress.", agent.deviceID)
+		desc = fmt.Sprintf("deviceId:%s, Cannot complete operation as Device deletion/reconciling is in progress or reconcile failed.", agent.deviceID)
 		return status.Error(codes.FailedPrecondition, desc)
 	}
 	// First figure out which adapter will handle this device type.  We do it at this stage as allow devices to be
@@ -588,8 +588,8 @@
 
 	if !agent.proceedWithRequestNoLock() {
 		agent.requestQueue.RequestComplete()
-		desc = fmt.Sprintf("deviceId:%s, Device deletion or reconciling is in progress.", agent.deviceID)
-		return status.Errorf(codes.FailedPrecondition, "deviceId:%s, Device reconciling is in progress.", agent.deviceID)
+		desc = fmt.Sprintf("deviceId:%s,Cannot complete operation as Device deletion/reconciling is in progress or reconcile failed.", agent.deviceID)
+		return status.Errorf(codes.FailedPrecondition, desc)
 	}
 
 	// Update the Admin State and operational state before sending the request out
@@ -634,8 +634,8 @@
 
 	device := agent.getDeviceReadOnlyWithoutLock()
 	if !agent.proceedWithRequestNoLock() {
-		desc = fmt.Sprintf("deviceId:%s, Device delection or reconciling is in progress.", agent.deviceID)
-		return status.Errorf(codes.FailedPrecondition, "deviceId:%s, Device reconciling is in progress.", agent.deviceID)
+		desc = fmt.Sprintf("deviceId:%s, Cannot complete operation as Device deletion/reconciling is in progress or reconcile failed.", agent.deviceID)
+		return status.Errorf(codes.FailedPrecondition, desc)
 	}
 	subCtx, cancel := context.WithTimeout(log.WithSpanFromContext(context.Background(), ctx), agent.defaultTimeout)
 	subCtx = coreutils.WithRPCMetadataFromContext(subCtx, ctx)
@@ -719,9 +719,9 @@
 		return err
 	}
 
-	if agent.isReconcileInProgress() {
+	if agent.isInReconcileState() {
 		agent.requestQueue.RequestComplete()
-		desc = fmt.Sprintf("deviceId:%s, Device Reconciling is in progress", agent.deviceID)
+		desc = fmt.Sprintf("deviceId:%s, Cannot complete operation as Reconciling is in progress or failed", agent.deviceID)
 		return status.Error(codes.FailedPrecondition, desc)
 	}
 
@@ -1264,7 +1264,7 @@
 
 // The device lock MUST be held by the caller.
 func (agent *Agent) proceedWithRequestNoLock() bool {
-	return !agent.isDeletionInProgress() && !agent.isReconcileInProgress()
+	return !agent.isDeletionInProgress() && !agent.isInReconcileState()
 }
 
 func (agent *Agent) stopReconcile() {
@@ -1287,7 +1287,7 @@
 
 	if !agent.proceedWithRequestNoLock() {
 		agent.requestQueue.RequestComplete()
-		desc = fmt.Sprintf("Either device is in deletion or reconcile is already in progress for device : %s", device.Id)
+		desc = fmt.Sprintf("Cannot complete operation as Device deletion/reconciling is in progress or reconcile failed for device : %s", device.Id)
 		logger.Errorf(ctx, desc)
 		agent.logDeviceUpdate(ctx, "Reconciling", nil, nil, operStatus, &desc)
 		return