VOL-4053: Fix Reenable of OLT following disable OLT and adapter restart.

- Allow event DeviceDownInd in state deviceStateConnected.
  When the device is disabled it is in state deviceStateDown. When the
  adapter is restarted in this state, the adapter comes back from restart
  and establishes connection to OLT device and moves to deviceStateConnected.
  However given the device was disabled prior to adapter going for
  restart, it triggers a disable again for the device. The OLT
  is already disabled, but acknowledges the disable command with
  an down indication which translates to DeviceDownInd event
  in the device FSM at adapter. Now this event should be allowed
  in the FSM.

Change-Id: I0cbe81f6d393ab6ceca5fa9f847fa4a4acb5f198
diff --git a/VERSION b/VERSION
index 619b537..6e253cc 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-3.3.3
+3.3.4-dev
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index fdb0859..96d67b7 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -364,12 +364,6 @@
 	if err != nil {
 		return err
 	}
-	/* get device state */
-	device, err := dh.coreProxy.GetDevice(ctx, dh.device.Id, dh.device.Id)
-	if err != nil || device == nil {
-		/*TODO: needs to handle error scenarios */
-		return olterrors.NewErrNotFound("device", log.Fields{"device-id": dh.device.Id}, err)
-	}
 
 	// Create an exponential backoff around re-enabling indications. The
 	// maximum elapsed time for the back off is set to 0 so that we will
@@ -445,7 +439,7 @@
 			// Reset backoff if we have a successful receive
 			indicationBackoff.Reset()
 			// When OLT is admin down, ignore all indications.
-			if device.AdminState == voltha.AdminState_DISABLED && !isIndicationAllowedDuringOltAdminDown(indication) {
+			if dh.device.AdminState == voltha.AdminState_DISABLED && !isIndicationAllowedDuringOltAdminDown(indication) {
 				logger.Debugw(ctx, "olt-is-admin-down, ignore indication",
 					log.Fields{"indication": indication,
 						"device-id": dh.device.Id})
@@ -461,7 +455,7 @@
 }
 
 func (dh *DeviceHandler) startOpenOltIndicationStream(ctx context.Context) (oop.Openolt_EnableIndicationClient, error) {
-
+	logger.Infow(ctx, "enabling read indications", log.Fields{"device-id": dh.device.Id})
 	indications, err := dh.Client.EnableIndication(ctx, new(oop.Empty))
 	if err != nil {
 		return nil, olterrors.NewErrCommunication("indication-read-failure", log.Fields{"device-id": dh.device.Id}, err).Log()
@@ -469,7 +463,7 @@
 	if indications == nil {
 		return nil, olterrors.NewErrInvalidValue(log.Fields{"indications": nil, "device-id": dh.device.Id}, nil).Log()
 	}
-
+	logger.Infow(ctx, "read indication started successfully", log.Fields{"device-id": dh.device.Id})
 	return indications, nil
 }
 
@@ -508,7 +502,7 @@
 	case *oop.Indication_OltInd:
 		span, ctx := log.CreateChildSpan(ctx, "olt-indication", log.Fields{"device-id": dh.device.Id})
 		defer span.Finish()
-
+		logger.Infow(ctx, "received olt indication", log.Fields{"device-id": dh.device.Id, "olt-ind": indication.GetOltInd()})
 		if err := dh.handleOltIndication(ctx, indication.GetOltInd()); err != nil {
 			_ = olterrors.NewErrAdapter("handle-indication-error", log.Fields{"type": "olt", "device-id": dh.device.Id}, err).Log()
 		}
diff --git a/internal/pkg/core/olt_state_transitions.go b/internal/pkg/core/olt_state_transitions.go
index cad7d65..e67bd43 100644
--- a/internal/pkg/core/olt_state_transitions.go
+++ b/internal/pkg/core/olt_state_transitions.go
@@ -118,7 +118,7 @@
 	// If olt DOWN indication comes then do sate down
 	transitionMap.transitions[DeviceDownInd] =
 		Transition{
-			previousState: []DeviceState{deviceStateUp},
+			previousState: []DeviceState{deviceStateUp, deviceStateConnected},
 			currentState:  deviceStateDown,
 			before:        []TransitionHandler{dh.doStateDown}}
 
diff --git a/internal/pkg/core/olt_state_transitions_test.go b/internal/pkg/core/olt_state_transitions_test.go
index 9c2be8d..492c80a 100644
--- a/internal/pkg/core/olt_state_transitions_test.go
+++ b/internal/pkg/core/olt_state_transitions_test.go
@@ -151,6 +151,8 @@
 			true},
 		{"isValidTransition-2", fields{getTranisitions(), deviceStateDown}, args{GrpcConnected},
 			false},
+		{"isValidTransition-3", fields{getTranisitions(), deviceStateConnected}, args{DeviceDownInd},
+			false},
 	}
 	for _, tt := range tests {
 		t.Run(tt.name, func(t *testing.T) {