vol-2427 openolt-adapter should not ignore indication when OLT is transitioning from admin down to admin up
Admin state of the device is changed to up just before the reenable call
if reenable fails the admin state is put back to down and returned
Change-Id: Ic19c5da6dfbeb68396d86611f96cfe741c3f2ad5
diff --git a/adaptercore/device_handler.go b/adaptercore/device_handler.go
index fcf625f..36bb01a 100644
--- a/adaptercore/device_handler.go
+++ b/adaptercore/device_handler.go
@@ -327,7 +327,7 @@
// When OLT is admin down, ignore all indications.
if adminState == "down" {
- log.Infow("olt is admin down, ignore indication", log.Fields{})
+ log.Infow("olt is admin down, ignore indication", log.Fields{"indication": indication})
continue
}
dh.handleIndication(indication)
@@ -1175,16 +1175,19 @@
//Device Port-State: ACTIVE
//Device Oper-State: ACTIVE
func (dh *DeviceHandler) ReenableDevice(device *voltha.Device) error {
- if _, err := dh.Client.ReenableOlt(context.Background(), new(oop.Empty)); err != nil {
- if e, ok := status.FromError(err); ok && e.Code() == codes.Internal {
- log.Errorw("Failed to reenable olt ", log.Fields{"err": err})
- return err
- }
- }
-
dh.lockDevice.Lock()
dh.adminState = "up"
dh.lockDevice.Unlock()
+
+ if _, err := dh.Client.ReenableOlt(context.Background(), new(oop.Empty)); err != nil {
+ if e, ok := status.FromError(err); ok && e.Code() == codes.Internal {
+ log.Errorw("Failed to reenable olt ", log.Fields{"err": err})
+ dh.lockDevice.Lock()
+ dh.adminState = "down"
+ dh.lockDevice.Unlock()
+ return err
+ }
+ }
log.Debug("olt-reenabled")
cloned := proto.Clone(device).(*voltha.Device)