VOL-3896: ONU fails to activate again if ONU is deleted after OLT disable
- When OLT is disabled the local cache of child devices are cleared in openolt adapter.
If ONU delete were triggered post OLT disable, the openolt adapter does not
have relevant information (esp. ONU serial number) in Child_device_lost API
call to pass down to OLT agent to delete the ONU context. The local cache too is void
of this information as it was cleared on OLT disable.
A possible fix is to pass down the entire ONU Device struct in Child_device_lost
API which contains all the relevant information to clear the ONU context on the OLT.
Change-Id: I76e28a0a46c1c82b25c859160466abfff693ed09
diff --git a/go.mod b/go.mod
index 088297b..dfdb9f5 100644
--- a/go.mod
+++ b/go.mod
@@ -7,7 +7,7 @@
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.3.2
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4
- github.com/opencord/voltha-lib-go/v4 v4.0.12
+ github.com/opencord/voltha-lib-go/v4 v4.1.0
github.com/opencord/voltha-protos/v4 v4.0.14
go.etcd.io/etcd v0.0.0-20190930204107-236ac2a90522
google.golang.org/grpc v1.25.1
diff --git a/go.sum b/go.sum
index 3a78239..bb852d3 100644
--- a/go.sum
+++ b/go.sum
@@ -142,8 +142,8 @@
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.2 h1:3mYCb7aPxS/RU7TI1y4rkEn1oKmPRjNJLNEXgw7MH2I=
github.com/onsi/gomega v1.4.2/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
-github.com/opencord/voltha-lib-go/v4 v4.0.12 h1:hKE9UqVF9NHmwieWOlzdHM119NF5U5YaOyEvwlabwI8=
-github.com/opencord/voltha-lib-go/v4 v4.0.12/go.mod h1:K7lDkSkJ97EyfvX8fQtBmBvpj7n6MmwnAtD8Jz79HcQ=
+github.com/opencord/voltha-lib-go/v4 v4.1.0 h1:Ba6w5bv36oYrzqfK96f42+hSEMkukwIjpdBWPztLY1g=
+github.com/opencord/voltha-lib-go/v4 v4.1.0/go.mod h1:K7lDkSkJ97EyfvX8fQtBmBvpj7n6MmwnAtD8Jz79HcQ=
github.com/opencord/voltha-protos/v4 v4.0.12 h1:x8drb8inaUByjVLFbXSiQwRTU//dfde0MKIHyKb1JMw=
github.com/opencord/voltha-protos/v4 v4.0.12/go.mod h1:W/OIFIyvFh/C0vchRUuarIsMylEhzCRM9pNxLvkPtKc=
github.com/opencord/voltha-protos/v4 v4.0.14 h1:5Zofvc3E+us/3N0HYEqGdVc2yuEoyaFDs8Rd/C4+ELE=
diff --git a/internal/pkg/core/device_handler.go b/internal/pkg/core/device_handler.go
index ec5bf84..1e86007 100644
--- a/internal/pkg/core/device_handler.go
+++ b/internal/pkg/core/device_handler.go
@@ -2146,25 +2146,18 @@
}
// ChildDeviceLost deletes ONU and clears pon resources related to it.
-func (dh *DeviceHandler) ChildDeviceLost(ctx context.Context, pPortNo uint32, onuID uint32) error {
+func (dh *DeviceHandler) ChildDeviceLost(ctx context.Context, pPortNo uint32, onuID uint32, onuSn string) error {
logger.Debugw(ctx, "child-device-lost", log.Fields{"parent-device-id": dh.device.Id})
intfID := PortNoToIntfID(pPortNo, voltha.Port_PON_OLT)
onuKey := dh.formOnuKey(intfID, onuID)
- onuDevice, ok := dh.onus.Load(onuKey)
- if !ok {
- return olterrors.NewErrAdapter("failed-to-load-onu-details",
- log.Fields{
- "device-id": dh.device.Id,
- "onu-id": onuID,
- "intf-id": intfID}, nil).Log()
- }
+
var sn *oop.SerialNumber
var err error
- if sn, err = dh.deStringifySerialNumber(onuDevice.(*OnuDevice).serialNumber); err != nil {
+ if sn, err = dh.deStringifySerialNumber(onuSn); err != nil {
return olterrors.NewErrAdapter("failed-to-destringify-serial-number",
log.Fields{
"devicer-id": dh.device.Id,
- "serial-number": onuDevice.(*OnuDevice).serialNumber}, err).Log()
+ "serial-number": onuSn}, err).Log()
}
onu := &oop.Onu{IntfId: intfID, OnuId: onuID, SerialNumber: sn}
@@ -2187,7 +2180,7 @@
"error": err})
} else {
for i, onu := range onuGemData {
- if onu.OnuID == onuID && onu.SerialNumber == onuDevice.(*OnuDevice).serialNumber {
+ if onu.OnuID == onuID && onu.SerialNumber == onuSn {
logger.Debugw(ctx, "onu-data", log.Fields{"onu": onu})
if err := dh.clearUNIData(ctx, &onu); err != nil {
logger.Warnw(ctx, "failed-to-clear-uni-data-for-onu", log.Fields{
@@ -2217,7 +2210,7 @@
}
}
dh.onus.Delete(onuKey)
- dh.discOnus.Delete(onuDevice.(*OnuDevice).serialNumber)
+ dh.discOnus.Delete(onuSn)
return nil
}
diff --git a/internal/pkg/core/openolt.go b/internal/pkg/core/openolt.go
index eebed78..a590846 100644
--- a/internal/pkg/core/openolt.go
+++ b/internal/pkg/core/openolt.go
@@ -350,12 +350,12 @@
}
//Child_device_lost deletes the ONU and its references from PONResources
-func (oo *OpenOLT) Child_device_lost(ctx context.Context, deviceID string, pPortNo uint32, onuID uint32) error {
- logger.Infow(ctx, "Child-device-lost", log.Fields{"parent-device-id": deviceID})
- if handler := oo.getDeviceHandler(deviceID); handler != nil {
- return handler.ChildDeviceLost(ctx, pPortNo, onuID)
+func (oo *OpenOLT) Child_device_lost(ctx context.Context, childDevice *voltha.Device) error {
+ logger.Infow(ctx, "Child-device-lost", log.Fields{"parent-device-id": childDevice.ParentId, "child-device-id": childDevice.Id})
+ if handler := oo.getDeviceHandler(childDevice.ParentId); handler != nil {
+ return handler.ChildDeviceLost(ctx, childDevice.ParentPortNo, childDevice.ProxyAddress.OnuId, childDevice.SerialNumber)
}
- return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": deviceID}, nil).Log()
+ return olterrors.NewErrNotFound("device-handler", log.Fields{"device-id": childDevice.ParentId}, nil).Log()
}
//Start_omci_test not implemented
diff --git a/vendor/github.com/opencord/voltha-lib-go/v4/pkg/adapters/common/request_handler.go b/vendor/github.com/opencord/voltha-lib-go/v4/pkg/adapters/common/request_handler.go
index 459cac5..5a333c7 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v4/pkg/adapters/common/request_handler.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v4/pkg/adapters/common/request_handler.go
@@ -708,30 +708,17 @@
}
func (rhp *RequestHandlerProxy) Child_device_lost(ctx context.Context, args []*ic.Argument) error {
- if len(args) < 4 {
+ if len(args) < 2 {
logger.Warn(ctx, "invalid-number-of-args", log.Fields{"args": args})
return errors.New("invalid-number-of-args")
}
-
- pDeviceId := &ic.StrType{}
- pPortNo := &ic.IntType{}
- onuID := &ic.IntType{}
+ childDevice := &voltha.Device{}
fromTopic := &ic.StrType{}
for _, arg := range args {
switch arg.Key {
- case "pDeviceId":
- if err := ptypes.UnmarshalAny(arg.Value, pDeviceId); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-parent-deviceId", log.Fields{"error": err})
- return err
- }
- case "pPortNo":
- if err := ptypes.UnmarshalAny(arg.Value, pPortNo); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-port", log.Fields{"error": err})
- return err
- }
- case "onuID":
- if err := ptypes.UnmarshalAny(arg.Value, onuID); err != nil {
- logger.Warnw(ctx, "cannot-unmarshal-transaction-ID", log.Fields{"error": err})
+ case "childDevice":
+ if err := ptypes.UnmarshalAny(arg.Value, childDevice); err != nil {
+ logger.Warnw(ctx, "cannot-unmarshal-child-device", log.Fields{"error": err})
return err
}
case kafka.FromTopic:
@@ -742,9 +729,9 @@
}
}
//Update the core reference for that device
- rhp.coreProxy.UpdateCoreReference(pDeviceId.Val, fromTopic.Val)
+ rhp.coreProxy.UpdateCoreReference(childDevice.ParentId, fromTopic.Val)
//Invoke the Child_device_lost API on the adapter
- if err := rhp.adapter.Child_device_lost(ctx, pDeviceId.Val, uint32(pPortNo.Val), uint32(onuID.Val)); err != nil {
+ if err := rhp.adapter.Child_device_lost(ctx, childDevice); err != nil {
return status.Errorf(codes.NotFound, "%s", err.Error())
}
return nil
diff --git a/vendor/github.com/opencord/voltha-lib-go/v4/pkg/adapters/iAdapter.go b/vendor/github.com/opencord/voltha-lib-go/v4/pkg/adapters/iAdapter.go
index dfc3778..92a33e7 100644
--- a/vendor/github.com/opencord/voltha-lib-go/v4/pkg/adapters/iAdapter.go
+++ b/vendor/github.com/opencord/voltha-lib-go/v4/pkg/adapters/iAdapter.go
@@ -53,7 +53,7 @@
Revert_image_update(ctx context.Context, device *voltha.Device, request *voltha.ImageDownload) (*voltha.ImageDownload, error)
Enable_port(ctx context.Context, deviceId string, port *voltha.Port) error
Disable_port(ctx context.Context, deviceId string, port *voltha.Port) error
- Child_device_lost(ctx context.Context, parentDeviceId string, parentPortNo uint32, onuID uint32) error
+ Child_device_lost(ctx context.Context, childDevice *voltha.Device) error
Start_omci_test(ctx context.Context, device *voltha.Device, request *voltha.OmciTestRequest) (*voltha.TestResponse, error)
Get_ext_value(ctx context.Context, deviceId string, device *voltha.Device, valueflag voltha.ValueType_Type) (*voltha.ReturnValues, error)
Single_get_value_request(ctx context.Context, request extension.SingleGetValueRequest) (*extension.SingleGetValueResponse, error)
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 1c5edf9..7e4c2b9 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -52,7 +52,7 @@
# github.com/jcmturner/gofork v1.0.0
github.com/jcmturner/gofork/encoding/asn1
github.com/jcmturner/gofork/x/crypto/pbkdf2
-# github.com/opencord/voltha-lib-go/v4 v4.0.12
+# github.com/opencord/voltha-lib-go/v4 v4.1.0
github.com/opencord/voltha-lib-go/v4/pkg/adapters
github.com/opencord/voltha-lib-go/v4/pkg/adapters/adapterif
github.com/opencord/voltha-lib-go/v4/pkg/adapters/common