From c107630b8d144df3e3ab9630932f316b0bb3c17c Mon Sep 17 00:00:00 2001 From: Dave Tucker Date: Tue, 12 Oct 2021 19:59:23 +0100 Subject: [PATCH] cache: Fix Delete Handling 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 --- cache/cache.go | 9 +++++---- server/transact.go | 3 ++- test/ovs/ovs_integration_test.go | 6 ++++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cache/cache.go b/cache/cache.go index e32e5d7a..e4c444cb 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -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) } diff --git a/server/transact.go b/server/transact.go index 27169026..5fc9b598 100644 --- a/server/transact.go +++ b/server/transact.go @@ -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{ diff --git a/test/ovs/ovs_integration_test.go b/test/ovs/ovs_integration_test.go index 06796de0..1bf20d95 100644 --- a/test/ovs/ovs_integration_test.go +++ b/test/ovs/ovs_integration_test.go @@ -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() {