Skip to content

Commit

Permalink
Stop sending topRoot directly to opflex-server
Browse files Browse the repository at this point in the history
topRoot did not have all children and was causing stats to be
removed on the opflex-server. Instead of sending topRoot, just
send the child Unis that gbp-server populates

Signed-off-by: Tom Flynn <tom.flynn@gmail.com>
  • Loading branch information
tomflynn committed Apr 3, 2021
1 parent e141d91 commit 33ec9b9
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 23 deletions.
6 changes: 3 additions & 3 deletions pkg/gbpserver/gbp.go
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,9 @@ func getSnapShot(vtep string) []*GBPObject {

var keys []string
for k := range moMap {
keys = append(keys, k)
if len(k) > 1 { // skip topRoot
keys = append(keys, k)
}
}

sort.Strings(keys)
Expand Down Expand Up @@ -759,8 +761,6 @@ func DoAll() {
}

saveDBToFile()

// fmt.Printf("policy.json: %s", policyJson)
}
func invToCommon(vtep string) map[string]*gbpCommonMo {
moMap := make(map[string]*gbpCommonMo)
Expand Down
2 changes: 0 additions & 2 deletions pkg/gbpserver/gbp_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,6 @@ func CreateRoot(config *GBPServerConfig) {
}

rootChildren := []string{
"RelatorUniverse",
"GbpeVMUniverse",
"DomainConfig",
"InvUniverse",
"PolicyUniverse",
Expand Down
2 changes: 1 addition & 1 deletion pkg/gbpserver/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (gw *gbpWatch) ListObjects(v *Version, ss GBP_ListObjectsServer) error {
for _, url := range urls {
if strings.Contains(url, "InvRemoteInventoryEp") {
moList = append(moList, getInvSubTree(url, peerVtep)...)
} else {
} else if len(url) > 1 { // skip topRoot
moList = append(moList, getMoSubTree(url)...)
}
}
Expand Down
7 changes: 6 additions & 1 deletion pkg/gbpserver/integ_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,8 +828,13 @@ func verifyPolicy(t *testing.T, moMap map[string]*GBPObject) {
t.Fatal(err)
}

assert.Equal(t, len(moList), len(moMap))
// we explicitly remove topRoot from map returned to clients
assert.Equal(t, len(moList)-1, len(moMap))
for _, m := range moList {
if len(m.Uri) > 1 {
// skip topRoot
continue
}
n, found := moMap[m.Uri]
if !found {
t.Fatal(fmt.Errorf("Object %s not found in received policy", m.Uri))
Expand Down
16 changes: 0 additions & 16 deletions pkg/gbpserver/testPolicy.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
"subject": "DmtreeRoot",
"uri": "/",
"children": [
"/RelatorUniverse/",
"/GbpeVMUniverse/",
"/DomainConfig/",
"/InvUniverse/",
"/PolicyUniverse/"
Expand Down Expand Up @@ -53,13 +51,6 @@
"parent_uri": "/DomainConfig/",
"parent_relation": "DomainConfigToRemoteEndpointInventoryRSrc"
},
{
"subject": "GbpeVMUniverse",
"uri": "/GbpeVMUniverse/",
"parent_subject": "DmtreeRoot",
"parent_uri": "/",
"parent_relation": "GbpeVMUniverse"
},
{
"subject": "InvUniverse",
"uri": "/InvUniverse/",
Expand Down Expand Up @@ -2159,12 +2150,5 @@
"data": 6443
}
]
},
{
"subject": "RelatorUniverse",
"uri": "/RelatorUniverse/",
"parent_subject": "DmtreeRoot",
"parent_uri": "/",
"parent_relation": "RelatorUniverse"
}
]

0 comments on commit 33ec9b9

Please sign in to comment.