Skip to content

Commit

Permalink
cache: Fix Delete Handling
Browse files Browse the repository at this point in the history
We can't rely on the Delete field of RowUpdate2 being non-nil as
ovsdb-server sends a {"delete": null} which the Go JSON parser makes
equivalent to nil.

Signed-off-by: Dave Tucker <[email protected]>
  • Loading branch information
dave-tucker committed Oct 12, 2021
1 parent ba06477 commit c107630
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
9 changes: 5 additions & 4 deletions cache/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,10 +606,11 @@ func (t *TableCache) Populate2(tableUpdates ovsdb.TableUpdates2) {
t.eventProcessor.AddEvent(updateEvent, table, existing, modified)
}
case row.Delete != nil:
m, err := t.CreateModel(table, row.Delete, uuid)
if err != nil {
panic(err)
}
fallthrough
default:
// If everything else is nil (including Delete because it's a key with
// no value on the wire), then process a delete
m := tCache.Row(uuid)
if err := tCache.Delete(uuid); err != nil {
panic(err)
}
Expand Down
3 changes: 2 additions & 1 deletion server/transact.go
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,8 @@ func (o *OvsdbServer) Delete(database, table string, where []ovsdb.Condition) (o
panic(err)
}
tableUpdate.AddRowUpdate(uuid.(string), &ovsdb.RowUpdate2{
Delete: &oldRow,
Delete: &ovsdb.Row{},
Old: &oldRow,
})
}
return ovsdb.OperationResult{
Expand Down
6 changes: 6 additions & 0 deletions test/ovs/ovs_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,12 @@ func (suite *OVSIntegrationSuite) TestInsertAndDeleteTransactIntegration() {
}
suite.T().Fatal(err)
}

require.Eventually(suite.T(), func() bool {
br := &bridgeType{UUID: bridgeUUID}
err := suite.client.Get(br)
return err != nil
}, 2*time.Second, 500*time.Millisecond)
}

func (suite *OVSIntegrationSuite) TestTableSchemaValidationIntegration() {
Expand Down

0 comments on commit c107630

Please sign in to comment.