From d8e419cfae96cfa3c01919623d70494c0d6f8d28 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Fri, 17 Apr 2020 16:48:29 +0800 Subject: [PATCH] vpcagent: ovn: use cmp() --- pkg/vpcagent/ovn/keeper.go | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) diff --git a/pkg/vpcagent/ovn/keeper.go b/pkg/vpcagent/ovn/keeper.go index 469853bc2d..235c84953e 100644 --- a/pkg/vpcagent/ovn/keeper.go +++ b/pkg/vpcagent/ovn/keeper.go @@ -175,33 +175,15 @@ func (keeper *OVNNorthboundKeeper) ClaimNetwork(ctx context.Context, network *ag args []string ocVersion = fmt.Sprintf("%s.%d", network.UpdatedAt, network.UpdateVersion) ) - irows := []ovnutil.IRow{ + allFound, args := cmp(&keeper.DB, ocVersion, lsnet, lrnetp, lsnetp, lsnetmp, dhcpopts, - } - { - irowsFound := make([]ovnutil.IRow, 0, len(irows)) - for _, irow := range irows { - irowFound := keeper.DB.FindOneMatchNonZeros(irow) - if irowFound != nil { - irowsFound = append(irowsFound, irowFound) - } - } - // mark them anyway even if not all found, to avoid the destroy - // call at sweep stage - for _, irowFound := range irowsFound { - irowFound.OvnSetExternalIds(externalKeyOcVersion, ocVersion) - } - if len(irowsFound) == len(irows) { - return nil - } - args := ovnutil.OvnNbctlArgsDestroy(irowsFound) - if len(args) > 0 { - keeper.cli.Must(ctx, "ClaimNetwork cleanup", args) - } + ) + if allFound { + return nil } args = append(args, ovnCreateArgs(lsnet, "lsnet")...) args = append(args, ovnCreateArgs(lrnetp, "lrnetp")...)