VOL-5228 reconciling error handling
Change-Id: Ib558bf79c8ff9419422a70e7f5b1a286fbb24469
diff --git a/rw_core/core/device/agent.go b/rw_core/core/device/agent.go
index aaef7b1..89228e1 100755
--- a/rw_core/core/device/agent.go
+++ b/rw_core/core/device/agent.go
@@ -1572,6 +1572,21 @@
agent.logDeviceUpdate(ctx, nil, nil, requestStatus, err, desc)
break retry
}
+ st, ok := status.FromError(err)
+ if ok {
+ // Decode the error code and error message
+ errorCode := st.Code()
+ if errorCode == codes.AlreadyExists {
+ logger.Warnw(ctx, "device already reconciled", log.Fields{"error": err})
+ err := agent.reconcilingCleanup(ctx)
+ if err != nil {
+ logger.Errorf(ctx, "error during reconcile cleanup", err.Error())
+ }
+ break retry
+
+ }
+
+ }
if err != nil {
agent.logDeviceUpdate(ctx, nil, nil, requestStatus, err, desc)
<-backoffTimer.C