A change confirm updates the network element multiple times
If a commit gets triggered the network element is updated two times. First through the callback
function of a change (defined within the ChangeMNE
method [1] of the NetworkElementServer
) and after that through the NetworkElementServer
's Commit method [2].
In more detail: applyDiff
[3] method shares some code duplication of the Commit
method [2]. In both of them the diff of a change is created and is pushed into the network elements model. After that both methods update the store entry of the network element.
Description
The duplicated code mentioned:
// Set all the changes within the network elements model
networkElement, err := n.mneService.Get(store.Query{ID: ch.AssociatedDeviceID()})
if err != nil {
return err
}
diff, err := networkElement.GetPlugin().Diff(ch.PreviousState(), ch.IntendedState())
if err != nil {
return err
}
for _, update := range diff.GetUpdate() {
if err := networkElement.GetPlugin().SetNode(update.GetPath(), update.GetVal()); err != nil {
return err
}
}
for _, deletePath := range diff.GetDelete() {
if err := networkElement.GetPlugin().DeleteNode(deletePath); err != nil {
return err
}
}
// update the network element
return n.mneService.Update(networkElement)
Expected Behavior
A network element is updated only once.
Actual Behavior
A network element is updated twice -> change is processed twice instead of once.
Possible Fix
Remove the duplicated change processing in Commit
or applyDiff
.
Steps to Reproduce
Context
Your Environment
- Version used:
- Environment name and version (e.g. go v1.16.3 on FreeBSD 13.0-current):
- Server type and version:
- Operating System and version: