Skip to content

Commit

Permalink
Adds logging for troubleshooting (to revert)
Browse files Browse the repository at this point in the history
  • Loading branch information
gruyaume committed Dec 12, 2023
1 parent b2eba73 commit 71a0eda
Showing 1 changed file with 17 additions and 33 deletions.
50 changes: 17 additions & 33 deletions factory/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ func compareAndProcessConfigs(smfCfg, newCfg *Configuration) {
}

//compare Userplane
logger.CfgLog.Infof("Existing UP nodes : %+v", smfCfg.UserPlaneInformation.UPNodes)
logger.CfgLog.Infof("New UP nodes : %+v", newCfg.UserPlaneInformation.UPNodes)
match, addUPNodes, modUPNodes, delUPNodes := compareUPNodesConfigs(smfCfg.UserPlaneInformation.UPNodes, newCfg.UserPlaneInformation.UPNodes)

if !match {
Expand Down Expand Up @@ -511,50 +513,32 @@ func compareUPNode(u1, u2 UPNode) bool {

return false
}

func compareUPNodesConfigs(u1, u2 map[string]UPNode) (match bool, add, mod, del map[string]UPNode) {

match = true
add, mod, del = make(map[string]UPNode), make(map[string]UPNode), make(map[string]UPNode)

// Loop two times, first to find slice1 strings not in slice2,
// second loop to find slice2 strings not in slice1
for i := 0; i < 2; i++ {
for name, node1 := range u1 {
found := false
if node2, ok := u2[name]; ok {
if !compareUPNode(node1, node2) {
mod[name] = node2
logger.CfgLog.Infof("UPNode[%v] mismatch", name)
logger.CfgLog.Infof("existing UPNode: %+v", node1)
logger.CfgLog.Infof("received UPNode: %+v", node2)
logger.CfgLog.Infof("compareUPNodesConfigs (0) - User plane nodes to be modified : %+v", mod)
match = false
}
found = true
break
}

// String not found. We add it to return slice
if !found {
// Check for modifications and deletions in u1
for name, node1 := range u1 {
if node2, ok := u2[name]; ok {
if !compareUPNode(node1, node2) {
mod[name] = node2
match = false
if i == 0 {
del[name] = node1

} else {
add[name] = node1
}
}
} else {
del[name] = node1
match = false
}
// Swap the slices, only if it was the first loop
if i == 0 {
u1, u2 = u2, u1
}

// Check for additions in u2
for name, node2 := range u2 {
if _, ok := u1[name]; !ok {
add[name] = node2
match = false
}
}

logger.CfgLog.Infof("compareUPNodesConfigs (1) - User plane nodes to be modified : %+v", mod)
return

}

func compareNetworkSliceInstance(s1, s2 SnssaiInfoItem) (match bool) {
Expand Down

0 comments on commit 71a0eda

Please sign in to comment.