XVOL-1689 : ONU stays in DISCOVERED state
VOL-1586 : Possible race condition in openolt python adapter during onu discovery
1) gets Device in response of ChildDeviceDetected.
This avoids race and also removes the need for GetChildDevice.
2)Puts the Device Id into cache to use in future requests,
especially avoid the fail when calling GetChildDevice
in onuIndication because of race.
Change-Id: I60944a6ee0e2ffad80a31ef93f72b55b0b136284
diff --git a/vendor/github.com/opencord/voltha-go/db/model/non_persisted_revision.go b/vendor/github.com/opencord/voltha-go/db/model/non_persisted_revision.go
index 6075b3f..297a740 100644
--- a/vendor/github.com/opencord/voltha-go/db/model/non_persisted_revision.go
+++ b/vendor/github.com/opencord/voltha-go/db/model/non_persisted_revision.go
@@ -55,7 +55,6 @@
Branch *Branch
WeakRef string
Name string
- discarded bool
lastUpdate time.Time
}
@@ -66,14 +65,9 @@
r.Config = NewDataRevision(root, data)
r.Children = children
r.Hash = r.hashContent()
- r.discarded = false
return r
}
-func (npr *NonPersistedRevision) IsDiscarded() bool {
- return npr.discarded
-}
-
func (npr *NonPersistedRevision) SetConfig(config *DataRevision) {
npr.mutex.Lock()
defer npr.mutex.Unlock()
@@ -356,14 +350,33 @@
if nameExists {
// Check if the data has changed or not
if existingChildren[nameIndex].GetData().(proto.Message).String() != newChild.GetData().(proto.Message).String() {
+ log.Debugw("replacing-existing-child", log.Fields{
+ "old-hash": existingChildren[nameIndex].GetHash(),
+ "old-data": existingChildren[nameIndex].GetData(),
+ "new-hash": newChild.GetHash(),
+ "new-data": newChild.GetData(),
+ })
+
// replace entry
newChild.GetNode().Root = existingChildren[nameIndex].GetNode().Root
updatedChildren = append(updatedChildren, newChild)
} else {
+ log.Debugw("keeping-existing-child", log.Fields{
+ "old-hash": existingChildren[nameIndex].GetHash(),
+ "old-data": existingChildren[nameIndex].GetData(),
+ "new-hash": newChild.GetHash(),
+ "new-data": newChild.GetData(),
+ })
+
// keep existing entry
updatedChildren = append(updatedChildren, existingChildren[nameIndex])
}
} else {
+ log.Debugw("adding-unknown-child", log.Fields{
+ "hash": newChild.GetHash(),
+ "data": newChild.GetData(),
+ })
+
// new entry ... just add it
updatedChildren = append(updatedChildren, newChild)
}
@@ -413,7 +426,6 @@
// Drop is used to indicate when a revision is no longer required
func (npr *NonPersistedRevision) Drop(txid string, includeConfig bool) {
log.Debugw("dropping-revision", log.Fields{"hash": npr.GetHash(), "name": npr.GetName()})
- npr.discarded = true
}
// ChildDrop will remove a child entry matching the provided parameters from the current revision
@@ -458,6 +470,6 @@
// stub ... required by interface
}
-func (pr *NonPersistedRevision) StorageDrop(txid string, includeConfig bool) {
+func (npr *NonPersistedRevision) StorageDrop(txid string, includeConfig bool) {
// stub ... required by interface
}