From 9e12506b08b0f7c62ad152b5e641cca62923ba04 Mon Sep 17 00:00:00 2001 From: astoycos Date: Thu, 2 Dec 2021 16:54:27 -0500 Subject: [PATCH 1/7] Convert OVN Meter + Meter_Band ops to libovsdb Convert the creation/ configuration of the OVN meter and meter_band objects for the acl-logging feature to libovdb Signed-off-by: astoycos --- go-controller/pkg/ovn/libovsdbops/meter.go | 70 ++++++++++++++++++++++ go-controller/pkg/ovn/libovsdbops/model.go | 21 +++++++ go-controller/pkg/ovn/master.go | 54 ++++++++++------- go-controller/pkg/types/const.go | 3 + 4 files changed, 127 insertions(+), 21 deletions(-) create mode 100644 go-controller/pkg/ovn/libovsdbops/meter.go diff --git a/go-controller/pkg/ovn/libovsdbops/meter.go b/go-controller/pkg/ovn/libovsdbops/meter.go new file mode 100644 index 00000000000..8a4b521cc6d --- /dev/null +++ b/go-controller/pkg/ovn/libovsdbops/meter.go @@ -0,0 +1,70 @@ +package libovsdbops + +import ( + "context" + "fmt" + + libovsdbclient "github.com/ovn-org/libovsdb/client" + + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" +) + +// FindMeterByName finds an ovn meter by name, will return `errNotFound` if it does not exist +func FindMeterByName(nbClient libovsdbclient.Client, name string) (*nbdb.Meter, error) { + searched := &nbdb.Meter{ + Name: name, + } + + ctx, cancel := context.WithTimeout(context.Background(), types.OVSDBTimeout) + defer cancel() + err := nbClient.Get(ctx, searched) + if err != nil { + return nil, err + } + + return searched, nil +} + +// UpdateMeterFairness updates the `fair` column of an ovn Meter +func UpdateMeterFairness(nbClient libovsdbclient.Client, meter *nbdb.Meter, fairness bool) error { + meter.Fair = &fairness + + opModel := OperationModel{ + Model: meter, + OnModelUpdates: []interface{}{ + &meter.Fair, + }, + ErrNotFound: true, + } + + m := NewModelClient(nbClient) + if _, err := m.CreateOrUpdate(opModel); err != nil { + return fmt.Errorf("error while updating Meter Fairness to: %v error %v", fairness, err) + } + + return nil +} + +// CreateMeterWithBand simulates the ovn-nbctl operation performed by the `meter-add` command. i.e create the Meter +// and accompanying meter_band, and add the meterband to the meter only call this if the meter does not exist +func CreateMeterWithBand(nbClient libovsdbclient.Client, meter *nbdb.Meter, meterBand *nbdb.MeterBand) error { + opModels := []OperationModel{ + { + Model: meterBand, + DoAfter: func() { + meter.Bands = []string{meterBand.UUID} + }, + }, + { + Model: meter, + }, + } + + m := NewModelClient(nbClient) + if _, err := m.CreateOrUpdate(opModels...); err != nil { + return fmt.Errorf("error while creating Meter_Band %+v and Meter %+v error %v", meterBand, meter, err) + } + + return nil +} diff --git a/go-controller/pkg/ovn/libovsdbops/model.go b/go-controller/pkg/ovn/libovsdbops/model.go index ee9fc429bfc..684644bc035 100644 --- a/go-controller/pkg/ovn/libovsdbops/model.go +++ b/go-controller/pkg/ovn/libovsdbops/model.go @@ -41,6 +41,10 @@ func getUUID(model model.Model) string { return t.UUID case *nbdb.NBGlobal: return t.UUID + case *nbdb.MeterBand: + return t.UUID + case *nbdb.Meter: + return t.UUID case *sbdb.Chassis: return t.UUID case *sbdb.MACBinding: @@ -82,6 +86,10 @@ func setUUID(model model.Model, uuid string) { t.UUID = uuid case *nbdb.NBGlobal: t.UUID = uuid + case *nbdb.MeterBand: + t.UUID = uuid + case *nbdb.Meter: + t.UUID = uuid case *sbdb.Chassis: t.UUID = uuid case *sbdb.MACBinding: @@ -161,6 +169,15 @@ func copyIndexes(model model.Model) model.Model { return &nbdb.NBGlobal{ UUID: t.UUID, } + case *nbdb.MeterBand: + return &nbdb.MeterBand{ + UUID: t.UUID, + } + case *nbdb.Meter: + return &nbdb.Meter{ + UUID: t.UUID, + Name: t.Name, + } case *sbdb.Chassis: return &sbdb.Chassis{ UUID: t.UUID, @@ -208,6 +225,10 @@ func getListFromModel(model model.Model) interface{} { return &[]nbdb.PortGroup{} case *nbdb.NBGlobal: return &[]nbdb.NBGlobal{} + case *nbdb.MeterBand: + return &[]nbdb.MeterBand{} + case *nbdb.Meter: + return &[]nbdb.Meter{} case *sbdb.Chassis: return &[]sbdb.Chassis{} case *sbdb.MACBinding: diff --git a/go-controller/pkg/ovn/master.go b/go-controller/pkg/ovn/master.go index 9ba918fe949..d9a00d6123c 100644 --- a/go-controller/pkg/ovn/master.go +++ b/go-controller/pkg/ovn/master.go @@ -6,7 +6,6 @@ import ( "net" "os" "reflect" - "strconv" "strings" "sync" "time" @@ -264,27 +263,40 @@ func (oc *Controller) StartClusterMaster(masterNodeName string) error { } } - if stdout, _, err := util.RunOVNNbctl("--data=bare", "--format=csv", "--no-headings", "--columns=_uuid,fair", - "find", "meter", "name="+types.OvnACLLoggingMeter); err == nil { - if stdout != "" { - columns := strings.Split(stdout, ",") - uuid := columns[0] - fair := columns[1] - if fair == "false" { - // fair metering ensures that instead of sharing one meter across several entities - // each entity will be rate-limited on its own - if _, _, err := util.RunOVNNbctl("set", "meter", uuid, "fair=true"); err != nil { - klog.Warningf("Failed to enable 'fair' metering for %s meter: %v", types.OvnACLLoggingMeter, err) - } - } - } else { - dropRate := strconv.Itoa(config.Logging.ACLLoggingRateLimit) - if _, _, err := util.RunOVNNbctl("--fair", "meter-add", types.OvnACLLoggingMeter, "drop", dropRate, "pktps"); err != nil { - klog.Warningf("ACL logging support enabled, however acl-logging meter could not be created: %v. "+ - "Disabling ACL logging support", err) - oc.aclLoggingEnabled = false - } + meterFairness := true + + // This always needs to be looked up in two transactions because there's no way to lookup + // a meter's meter_band + aclLogMeterPtr, err := libovsdbops.FindMeterByName(oc.nbClient, types.OvnACLLoggingMeter) + if err != nil && err != libovsdbclient.ErrNotFound { + // Log error but don't stop master setup + klog.Errorf("ACL logging support enabled, however failed to find acl-logging meter err: %v"+ + "Disabling ACL logging support", err) + oc.aclLoggingEnabled = false + } + + // if meter exists update its fairness, otherwise create it + if aclLogMeterPtr != nil { + if err := libovsdbops.UpdateMeterFairness(oc.nbClient, aclLogMeterPtr, meterFairness); err != nil { + klog.Warningf("Failed to enable 'fair' metering for %s meter: %v", types.OvnACLLoggingMeter, err) + } + } else { + meterBand := &nbdb.MeterBand{ + Action: types.MeterAction, + Rate: config.Logging.ACLLoggingRateLimit, + } + meter := &nbdb.Meter{ + Name: types.OvnACLLoggingMeter, + Fair: &meterFairness, + Unit: types.PacketsPerSecond, } + + if err := libovsdbops.CreateMeterWithBand(oc.nbClient, meter, meterBand); err != nil { + klog.Warningf("ACL logging support enabled, however acl-logging meter could not be created: %v. "+ + "Disabling ACL logging support", err) + oc.aclLoggingEnabled = false + } + } // FIXME: When https://github.com/ovn-org/libovsdb/issues/235 is fixed, diff --git a/go-controller/pkg/types/const.go b/go-controller/pkg/types/const.go index cd9996116d9..cb3a7edbcbe 100644 --- a/go-controller/pkg/types/const.go +++ b/go-controller/pkg/types/const.go @@ -93,7 +93,10 @@ const ( RouteAdvertisementICMPType = 134 NeighborAdvertisementICMPType = 136 + // ACL logging constants OvnACLLoggingMeter = "acl-logging" + PacketsPerSecond = "pktps" + MeterAction = "drop" // OVN-K8S Address Sets Names HybridRoutePolicyPrefix = "hybrid-route-pods-" From 95729a637f14d8ac33f59eefff91be14e38f1c15 Mon Sep 17 00:00:00 2001 From: astoycos Date: Thu, 2 Dec 2021 16:56:01 -0500 Subject: [PATCH 2/7] set NB_Global options with libovsdb Set the `controller_event` option on the nb_global table to `true` with libovsdb Signed-off-by: astoycos --- go-controller/pkg/ovn/controller/services/repair.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/go-controller/pkg/ovn/controller/services/repair.go b/go-controller/pkg/ovn/controller/services/repair.go index 5d173ae538f..02affe27bbb 100644 --- a/go-controller/pkg/ovn/controller/services/repair.go +++ b/go-controller/pkg/ovn/controller/services/repair.go @@ -10,7 +10,6 @@ import ( globalconfig "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" ovnlb "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/loadbalancer" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util" apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/labels" @@ -68,8 +67,7 @@ func (r *repair) runBeforeSync() { // Ensure unidling is enabled if globalconfig.Kubernetes.OVNEmptyLbEvents { - _, _, err := util.RunOVNNbctl("set", "nb_global", ".", "options:controller_event=true") - if err != nil { + if err := libovsdbops.UpdateNBGlobalOptions(r.nbClient, map[string]string{"controller_event": "true"}); err != nil { klog.Error("Unable to enable controller events. Unidling not possible") } } From d47a3fc8309163683a47e6848285b725443cc6d7 Mon Sep 17 00:00:00 2001 From: astoycos Date: Mon, 13 Dec 2021 11:38:17 -0500 Subject: [PATCH 3/7] Remove final nbctl calls from HO code Convert all remaining nbctl calls from the hybridOverlay package Update unit test accordingly Signed-off-by: astoycos --- .../hybrid-overlay/pkg/controller/master.go | 10 +-- .../pkg/controller/master_test.go | 88 ++++++++++--------- .../hybrid-overlay/pkg/controller/out.txt | 0 .../ovn/libovsdbops/logical_switch_port.go | 73 +++++++++++++++ .../pkg/ovn/libovsdbops/nb_global.go | 4 +- go-controller/pkg/ovn/libovsdbops/switch.go | 1 + 6 files changed, 128 insertions(+), 48 deletions(-) create mode 100644 go-controller/hybrid-overlay/pkg/controller/out.txt create mode 100644 go-controller/pkg/ovn/libovsdbops/logical_switch_port.go diff --git a/go-controller/hybrid-overlay/pkg/controller/master.go b/go-controller/hybrid-overlay/pkg/controller/master.go index 98ae94e9c57..fdd642f7898 100644 --- a/go-controller/hybrid-overlay/pkg/controller/master.go +++ b/go-controller/hybrid-overlay/pkg/controller/master.go @@ -227,13 +227,11 @@ func (m *MasterController) handleOverlayPort(node *kapi.Node, annotator kube.Ann if !lspOK { klog.Infof("Creating / updating node %s hybrid overlay port with mac %s", node.Name, portMAC.String()) - var stderr string // create / update lsps - _, stderr, err = util.RunOVNNbctl("--", "--may-exist", "lsp-add", node.Name, portName, - "--", "lsp-set-addresses", portName, portMAC.String()) + err := libovsdbops.CreateLSPOrMutateMac(m.nbClient, node.Name, portName, portMAC.String()) if err != nil { return fmt.Errorf("failed to add hybrid overlay port for node %s"+ - ", stderr:%s: %v", node.Name, stderr, err) + ", err: %v", node.Name, err) } for _, subnet := range subnets { if err := util.UpdateNodeSwitchExcludeIPs(m.nbClient, node.Name, subnet); err != nil { @@ -255,7 +253,9 @@ func (m *MasterController) handleOverlayPort(node *kapi.Node, annotator kube.Ann func (m *MasterController) deleteOverlayPort(node *kapi.Node) { klog.Infof("Removing node %s hybrid overlay port", node.Name) portName := util.GetHybridOverlayPortName(node.Name) - _, _, _ = util.RunOVNNbctl("--", "--if-exists", "lsp-del", portName) + if err := libovsdbops.LSPDelete(m.nbClient, portName); err != nil { + klog.Errorf("Failed deleting hybrind overlay port for node %s err: %v", node.Name, err) + } } // AddNode handles node additions diff --git a/go-controller/hybrid-overlay/pkg/controller/master_test.go b/go-controller/hybrid-overlay/pkg/controller/master_test.go index 4047a43c187..79f139ae151 100644 --- a/go-controller/hybrid-overlay/pkg/controller/master_test.go +++ b/go-controller/hybrid-overlay/pkg/controller/master_test.go @@ -17,6 +17,7 @@ import ( "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/informer" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/kube" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" ovntest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing" libovsdbtest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing/libovsdb" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" @@ -193,17 +194,11 @@ var _ = Describe("Hybrid SDN Master Operations", func() { Name: types.OVNClusterRouter, Policies: []string{"reroute-policy-UUID"}, }, - &nbdb.LogicalSwitchPort{ - Name: types.HybridOverlayPrefix + nodeName, - UUID: types.HybridOverlayPrefix + nodeName + "-UUID", - }, } - // Pre-add the HO port until the ovn-nbctl lsp-add commands are converted to libovsdb nodeSwitch := &nbdb.LogicalSwitch{ - Name: nodeName, - UUID: nodeName + "-UUID", - Ports: []string{types.HybridOverlayPrefix + nodeName + "-UUID"}, + Name: nodeName, + UUID: nodeName + "-UUID", } initialExpectedDB := append(expectedDatabaseState, nodeSwitch) @@ -226,20 +221,14 @@ var _ = Describe("Hybrid SDN Master Operations", func() { ) Expect(err).NotTo(HaveOccurred()) - // #1 node add - fexec.AddFakeCmdsNoOutputNoError([]string{ - // Setting the mac on the lsp - "ovn-nbctl --timeout=15 -- " + - "--may-exist lsp-add node1 int-node1 -- " + - "lsp-set-addresses int-node1 " + nodeHOMAC, - }) - // #2 comes because we set the ho dr gw mac annotation in #1 - fexec.AddFakeCmdsNoOutputNoError([]string{ - // Setting the mac on the lsp - "ovn-nbctl --timeout=15 -- " + - "--may-exist lsp-add node1 int-node1 -- " + - "lsp-set-addresses int-node1 " + nodeHOMAC, - }) + // Make the expected LSP is created and added to the node + expectedLSP := &nbdb.LogicalSwitchPort{ + UUID: libovsdbops.BuildNamedUUID(), + Name: types.HybridOverlayPrefix + nodeName, + Addresses: []string{nodeHOMAC}, + } + + nodeSwitch.Ports = []string{expectedLSP.UUID} f.Start(stopChan) wg.Add(1) @@ -259,29 +248,22 @@ var _ = Describe("Hybrid SDN Master Operations", func() { nodeSwitch.OtherConfig = map[string]string{"exclude_ips": "10.1.2.2"} - expectedDatabaseState = append(expectedDatabaseState, nodeSwitch) + expectedDatabaseState = append(expectedDatabaseState, nodeSwitch, expectedLSP) Eventually(fexec.CalledMatchesExpected, 2).Should(BeTrue(), fexec.ErrorDesc) Eventually(libovsdbOvnNBClient).Should(libovsdbtest.HaveDataIgnoringUUIDs(expectedDatabaseState)) - // Test that deleting the node cleans up the OVN objects - fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovn-nbctl --timeout=15 -- --if-exists lsp-del int-node1", - }) - err = fakeClient.CoreV1().Nodes().Delete(context.TODO(), nodeName, *metav1.NewDeleteOptions(0)) Expect(err).NotTo(HaveOccurred()) Eventually(fexec.CalledMatchesExpected, 2).Should(BeTrue(), fexec.ErrorDesc) + + // In a real db, deleting the LSP would remove the reference here, but in our testing ovsdb server it does not + // nodeSwitch.Ports = []string{} expectedDatabaseState = []libovsdbtest.TestData{ &nbdb.LogicalRouter{ Name: types.OVNClusterRouter, }, - // This will be deleted once the nbctl commands for lsps are converted - &nbdb.LogicalSwitchPort{ - Name: types.HybridOverlayPrefix + nodeName, - UUID: types.HybridOverlayPrefix + nodeName + "-uuid", - }, nodeSwitch, } Eventually(libovsdbOvnNBClient).Should(libovsdbtest.HaveDataIgnoringUUIDs(expectedDatabaseState)) @@ -405,7 +387,8 @@ var _ = Describe("Hybrid SDN Master Operations", func() { f := informers.NewSharedInformerFactory(fakeClient, informer.DefaultResyncInterval) dynAdd := nodeHOMAC + " " + nodeHOIP - expectedDatabaseState := []libovsdbtest.TestData{ + lspUUID := libovsdbops.BuildNamedUUID() + initialDatabaseState := []libovsdbtest.TestData{ &nbdb.LogicalRouterPolicy{ Priority: 1002, ExternalIDs: map[string]string{ @@ -421,17 +404,19 @@ var _ = Describe("Hybrid SDN Master Operations", func() { Policies: []string{"reroute-policy-UUID"}, }, &nbdb.LogicalSwitchPort{ + UUID: lspUUID, Name: "int-" + nodeName, Addresses: []string{nodeHOMAC, nodeHOIP}, DynamicAddresses: &dynAdd, }, &nbdb.LogicalSwitch{ - Name: nodeName, - UUID: nodeName + "-UUID", + Name: nodeName, + UUID: nodeName + "-UUID", + Ports: []string{lspUUID}, }, } dbSetup := libovsdbtest.TestSetup{ - NBData: expectedDatabaseState, + NBData: initialDatabaseState, } var libovsdbOvnNBClient libovsdbclient.Client libovsdbOvnNBClient, libovsdbCleanup, err = libovsdbtest.NewNBTestHarness(dbSetup, nil) @@ -456,11 +441,8 @@ var _ = Describe("Hybrid SDN Master Operations", func() { f.WaitForCacheSync(stopChan) Eventually(fexec.CalledMatchesExpected, 2).Should(BeTrue(), fexec.ErrorDesc) - Eventually(libovsdbOvnNBClient).Should(libovsdbtest.HaveDataIgnoringUUIDs(expectedDatabaseState)) + Eventually(libovsdbOvnNBClient).Should(libovsdbtest.HaveDataIgnoringUUIDs(initialDatabaseState)) - fexec.AddFakeCmdsNoOutputNoError([]string{ - "ovn-nbctl --timeout=15 -- --if-exists lsp-del int-node1", - }) k := &kube.Kube{KClient: fakeClient} updatedNode, err := k.GetNode(nodeName) Expect(err).NotTo(HaveOccurred()) @@ -478,6 +460,30 @@ var _ = Describe("Hybrid SDN Master Operations", func() { return updatedNode.Annotations, nil }, 5).ShouldNot(HaveKey(hotypes.HybridOverlayDRMAC)) + expectedDatabaseState := []libovsdbtest.TestData{ + &nbdb.LogicalRouterPolicy{ + Priority: 1002, + ExternalIDs: map[string]string{ + "name": "hybrid-subnet-node1", + }, + Action: nbdb.LogicalRouterPolicyActionReroute, + Nexthops: []string{nodeHOIP}, + Match: "inport == \"rtos-node1\" && ip4.dst == 11.1.0.0/16", + UUID: "reroute-policy-UUID", + }, + &nbdb.LogicalRouter{ + Name: types.OVNClusterRouter, + Policies: []string{"reroute-policy-UUID"}, + }, + &nbdb.LogicalSwitch{ + Name: nodeName, + UUID: nodeName + "-UUID", + // CI server doesn't clean this up even though the LSP has been deleted, will + // be garbage collected in real scenario + Ports: []string{lspUUID}, + }, + } + Eventually(fexec.CalledMatchesExpected, 2).Should(BeTrue(), fexec.ErrorDesc) Eventually(libovsdbOvnNBClient).Should(libovsdbtest.HaveDataIgnoringUUIDs(expectedDatabaseState)) return nil diff --git a/go-controller/hybrid-overlay/pkg/controller/out.txt b/go-controller/hybrid-overlay/pkg/controller/out.txt new file mode 100644 index 00000000000..e69de29bb2d diff --git a/go-controller/pkg/ovn/libovsdbops/logical_switch_port.go b/go-controller/pkg/ovn/libovsdbops/logical_switch_port.go new file mode 100644 index 00000000000..eddb807105d --- /dev/null +++ b/go-controller/pkg/ovn/libovsdbops/logical_switch_port.go @@ -0,0 +1,73 @@ +package libovsdbops + +import ( + "fmt" + + libovsdbclient "github.com/ovn-org/libovsdb/client" + + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" +) + +// CreateLSPOrMutateMac creates a given LSP or mutates its MAC address and adds it to a logical Switch +func CreateLSPOrMutateMac(nbClient libovsdbclient.Client, nodeName, portName, portMAC string) error { + existingNodeSwitch := &nbdb.LogicalSwitch{ + Name: nodeName, + } + + existingLSP := []nbdb.LogicalSwitchPort{} + + newLSP := &nbdb.LogicalSwitchPort{ + Name: portName, + Addresses: []string{portMAC}, + } + + opModels := []OperationModel{ + // For LSP's Name is a valid index, so no predicate is needed + { + Model: newLSP, + ExistingResult: &existingLSP, + OnModelMutations: []interface{}{ + newLSP.Addresses, + }, + DoAfter: func() { + // Bulkop is false, so we won't get here if len existingLSP > 1 + if len(existingLSP) == 1 { + existingNodeSwitch.Ports = []string{existingLSP[0].UUID} + } else { + existingNodeSwitch.Ports = []string{newLSP.UUID} + } + }, + }, + { + Model: existingNodeSwitch, + ModelPredicate: func(ls *nbdb.LogicalSwitch) bool { return ls.Name == nodeName }, + OnModelMutations: []interface{}{ + &existingNodeSwitch.Ports, + }, + ErrNotFound: true, + }, + } + + m := NewModelClient(nbClient) + if _, err := m.CreateOrUpdate(opModels...); err != nil { + return fmt.Errorf("failed to create or Mutate LSP %v and add it to Node %s , error: %v", newLSP, nodeName, err) + } + + return nil +} + +// LSPDelete performs an idepotent delete of the LSP provided by it's name +func LSPDelete(nbClient libovsdbclient.Client, LSPName string) error { + opModel := OperationModel{ + Model: &nbdb.LogicalSwitchPort{ + Name: LSPName, + }, + } + + m := NewModelClient(nbClient) + if err := m.Delete(opModel); err != nil { + return fmt.Errorf("failed to delete LSP %s, error: %v", LSPName, err) + } + + return nil +} diff --git a/go-controller/pkg/ovn/libovsdbops/nb_global.go b/go-controller/pkg/ovn/libovsdbops/nb_global.go index a89080934c6..d3a82278382 100644 --- a/go-controller/pkg/ovn/libovsdbops/nb_global.go +++ b/go-controller/pkg/ovn/libovsdbops/nb_global.go @@ -11,7 +11,7 @@ import ( ) // findNBGlobal returns the NBGlobal table entry -func findNBGlobal(nbClient libovsdbclient.Client) (*nbdb.NBGlobal, error) { +func FindNBGlobal(nbClient libovsdbclient.Client) (*nbdb.NBGlobal, error) { nbGlobal := []nbdb.NBGlobal{} ctx, cancel := context.WithTimeout(context.Background(), types.OVSDBTimeout) defer cancel() @@ -35,7 +35,7 @@ func findNBGlobal(nbClient libovsdbclient.Client) (*nbdb.NBGlobal, error) { func UpdateNBGlobalOptions(nbClient libovsdbclient.Client, options map[string]string) error { // find the nbGlobal table's UUID, we don't have any other way to reliably look this table entry since it can // only be indexed by UUID - nbGlobal, err := findNBGlobal(nbClient) + nbGlobal, err := FindNBGlobal(nbClient) if err != nil { return err } diff --git a/go-controller/pkg/ovn/libovsdbops/switch.go b/go-controller/pkg/ovn/libovsdbops/switch.go index 7a0876495b3..7d96b7bc79c 100644 --- a/go-controller/pkg/ovn/libovsdbops/switch.go +++ b/go-controller/pkg/ovn/libovsdbops/switch.go @@ -90,6 +90,7 @@ func FindSwitchesWithOtherConfig(nbClient libovsdbclient.Client) ([]nbdb.Logical return switches, nil } +// FindPerNodeJoinSwitches finds the legacy join switches when they were deployed per node func FindPerNodeJoinSwitches(nbClient libovsdbclient.Client) ([]nbdb.LogicalSwitch, error) { // Get the legacy node join switches -> join_ joinSwitchSearch := func(item *nbdb.LogicalSwitch) bool { From 1b94cbb795af5817c7258109642d185bb3c3f07d Mon Sep 17 00:00:00 2001 From: astoycos Date: Tue, 7 Dec 2021 15:47:44 -0500 Subject: [PATCH 4/7] Remove final sbctl calls from Hybrid Overlay Remove the final sbctl calls regarding mac_bindings from the hybrid overlay code and convert to libovsdb Ensure we index mac_binding by both possible options, the `logical_port` OR `ip` columns Signed-off-by: astoycos --- .../hybrid-overlay/pkg/controller/master.go | 3 +- go-controller/pkg/ovn/libovsdbops/datapath.go | 44 ++++++++++++++ .../pkg/ovn/libovsdbops/mac_binding.go | 29 +++++++++ go-controller/pkg/ovn/libovsdbops/model.go | 5 +- go-controller/pkg/util/ovn.go | 59 +++++-------------- 5 files changed, 92 insertions(+), 48 deletions(-) create mode 100644 go-controller/pkg/ovn/libovsdbops/datapath.go create mode 100644 go-controller/pkg/ovn/libovsdbops/mac_binding.go diff --git a/go-controller/hybrid-overlay/pkg/controller/master.go b/go-controller/hybrid-overlay/pkg/controller/master.go index fdd642f7898..97373c32124 100644 --- a/go-controller/hybrid-overlay/pkg/controller/master.go +++ b/go-controller/hybrid-overlay/pkg/controller/master.go @@ -32,6 +32,7 @@ type MasterController struct { nodeEventHandler informer.EventHandler modelClient libovsdbops.ModelClient nbClient client.Client + sbClient client.Client } // NewMaster a new master controller that listens for node events @@ -374,7 +375,7 @@ func (m *MasterController) setupHybridLRPolicySharedGw(nodeSubnets []*net.IPNet, if len(logicalRouterPolicyRes) == 0 { logicalPort := ovntypes.RouterToSwitchPrefix + nodeName - if err := util.CreateMACBinding(logicalPort, ovntypes.OVNClusterRouter, portMac, drIP); err != nil { + if err := util.CreateMACBinding(m.sbClient, logicalPort, ovntypes.OVNClusterRouter, portMac, drIP); err != nil { return fmt.Errorf("failed to create MAC Binding for hybrid overlay: %v", err) } } diff --git a/go-controller/pkg/ovn/libovsdbops/datapath.go b/go-controller/pkg/ovn/libovsdbops/datapath.go new file mode 100644 index 00000000000..427bad8818d --- /dev/null +++ b/go-controller/pkg/ovn/libovsdbops/datapath.go @@ -0,0 +1,44 @@ +package libovsdbops + +import ( + "context" + "fmt" + + libovsdbclient "github.com/ovn-org/libovsdb/client" + + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/sbdb" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" +) + +func findDatapathByPredicate(sbClient libovsdbclient.Client, lookupFcn func(dp *sbdb.DatapathBinding) bool) (*sbdb.DatapathBinding, error) { + ctx, cancel := context.WithTimeout(context.Background(), types.OVSDBTimeout) + defer cancel() + datapathBindings := []sbdb.DatapathBinding{} + err := sbClient.WhereCache(lookupFcn).List(ctx, &datapathBindings) + if err != nil { + return nil, err + } + + if len(datapathBindings) != 1 { + return nil, fmt.Errorf("multiple datapath bindings found for a given lookup function") + } + + return &datapathBindings[0], nil +} + +func FindDatapathByExternalIDs(sbClient libovsdbclient.Client, externalIDs map[string]string) (*sbdb.DatapathBinding, error) { + datapathLookupFcn := func(dp *sbdb.DatapathBinding) bool { + datapathMatch := false + for k, v := range externalIDs { + if itemVal, ok := dp.ExternalIDs[k]; ok { + if itemVal == v { + datapathMatch = true + } + } + } + + return datapathMatch + } + + return findDatapathByPredicate(sbClient, datapathLookupFcn) +} diff --git a/go-controller/pkg/ovn/libovsdbops/mac_binding.go b/go-controller/pkg/ovn/libovsdbops/mac_binding.go new file mode 100644 index 00000000000..e5d34efa2f4 --- /dev/null +++ b/go-controller/pkg/ovn/libovsdbops/mac_binding.go @@ -0,0 +1,29 @@ +package libovsdbops + +import ( + libovsdbclient "github.com/ovn-org/libovsdb/client" + + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/sbdb" +) + +// Create or UpdateMacBinding either create a new mac binding or ensure the existing one has the +// correct datapath, logical_port, ip, and mac column entries +func CreateOrUpdateMacBinding(sbClient libovsdbclient.Client, mb *sbdb.MACBinding) error { + opModel := OperationModel{ + // no predicate needed, ip and logical_port columns are indexes + Model: mb, + OnModelUpdates: []interface{}{ + &mb.Datapath, + &mb.LogicalPort, + &mb.IP, + &mb.MAC, + }, + } + + m := NewModelClient(sbClient) + if _, err := m.CreateOrUpdate(opModel); err != nil { + return err + } + + return nil +} diff --git a/go-controller/pkg/ovn/libovsdbops/model.go b/go-controller/pkg/ovn/libovsdbops/model.go index 684644bc035..f2ad95ead5b 100644 --- a/go-controller/pkg/ovn/libovsdbops/model.go +++ b/go-controller/pkg/ovn/libovsdbops/model.go @@ -185,8 +185,9 @@ func copyIndexes(model model.Model) model.Model { } case *sbdb.MACBinding: return &sbdb.MACBinding{ - UUID: t.UUID, - IP: t.IP, + UUID: t.UUID, + LogicalPort: t.LogicalPort, + IP: t.IP, } default: panic(fmt.Sprintf("copyIndexes: unknown model %T", t)) diff --git a/go-controller/pkg/util/ovn.go b/go-controller/pkg/util/ovn.go index 292c3c71f1f..7bdcdcfd844 100644 --- a/go-controller/pkg/util/ovn.go +++ b/go-controller/pkg/util/ovn.go @@ -6,70 +6,39 @@ package util import ( "fmt" "net" - "strings" - "time" ocpconfigapi "github.com/openshift/api/config/v1" + libovsdbclient "github.com/ovn-org/libovsdb/client" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" - ovntypes "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/klog/v2" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/sbdb" ) // CreateMACBinding Creates MAC binding in OVN SBDB -func CreateMACBinding(logicalPort, datapathName string, portMAC net.HardwareAddr, nextHop net.IP) error { - datapath, err := GetDatapathUUID(datapathName) +func CreateMACBinding(sbClient libovsdbclient.Client, logicalPort, datapathName string, portMAC net.HardwareAddr, nextHop net.IP) error { + datapath, err := libovsdbops.FindDatapathByExternalIDs(sbClient, map[string]string{"name": datapathName}) if err != nil { return err } - // Check if exact match already exists - stdout, stderr, err := RunOVNSbctl("--data=bare", "--no-heading", "--columns=_uuid", "find", "MAC_Binding", - "logical_port="+logicalPort, - fmt.Sprintf(`mac="%s"`, portMAC), - "datapath="+datapath, - fmt.Sprintf("ip=\"%s\"", nextHop)) - if err != nil { - return fmt.Errorf("failed to check existence of MAC_Binding entry of (%s, %s, %s, %s)"+ - "stderr: %q, error: %v", datapath, logicalPort, portMAC, nextHop, stderr, err) - } - if stdout != "" { - klog.Infof("The MAC_Binding entry of (%s, %s, %s, %s) exists with uuid %s", - datapath, logicalPort, portMAC, nextHop, stdout) - return nil + // find Create mac_binding if needed + mb := &sbdb.MACBinding{ + LogicalPort: logicalPort, + MAC: string(portMAC), + Datapath: datapath.UUID, + IP: string(nextHop), } - // Create new binding - _, stderr, err = RunOVNSbctl("create", "mac_binding", "datapath="+datapath, fmt.Sprintf("ip=\"%s\"", nextHop), - "logical_port="+logicalPort, fmt.Sprintf(`mac="%s"`, portMAC)) + err = libovsdbops.CreateOrUpdateMacBinding(sbClient, mb) if err != nil { - return fmt.Errorf("failed to create a MAC_Binding entry of (%s, %s, %s, %s) "+ - "stderr: %q, error: %v", datapath, logicalPort, portMAC, nextHop, stderr, err) + return fmt.Errorf("failed to create/update MAC_Binding entry of (%s, %s, %s, %s)"+ + "error: %v", datapath.UUID, logicalPort, portMAC, nextHop, err) } return nil } -// GetDatapathUUID returns the OVN SBDB UUID for a datapath -func GetDatapathUUID(datapathName string) (string, error) { - // Get datapath from southbound, depending on startup this may take some time, so - // wait a bit for northd to create the cluster router's datapath in southbound - var datapath string - err := wait.PollImmediate(time.Second, 30*time.Second, func() (bool, error) { - datapath, _, _ = RunOVNSbctl("--data=bare", "--no-heading", "--columns=_uuid", "find", "datapath", - "external_ids:name="+datapathName) - datapath = strings.TrimSuffix(datapath, "\n") - // Ignore errors; can't easily detect which are transient or fatal - return datapath != "", nil - }) - if err != nil { - return "", fmt.Errorf("failed to get the datapath UUID of %s from OVN SB "+ - "stdout: %q, error: %v", ovntypes.OVNClusterRouter, datapath, err) - } - return datapath, nil -} - func PlatformTypeIsEgressIPCloudProvider() bool { return config.Kubernetes.PlatformType == string(ocpconfigapi.AWSPlatformType) || config.Kubernetes.PlatformType == string(ocpconfigapi.GCPPlatformType) || From c3472e17d5a49afa88be5e017e37f08518bb9b21 Mon Sep 17 00:00:00 2001 From: astoycos Date: Wed, 8 Dec 2021 11:03:28 -0500 Subject: [PATCH 5/7] Cleanup OVN package Remove some erronous fexec calls Remove the NBtxn struct and associated helper functions Signed-off-by: astoycos --- go-controller/pkg/ovn/egressfirewall_test.go | 7 ------ go-controller/pkg/ovn/libovsdbops/chassis.go | 2 +- go-controller/pkg/ovn/master_test.go | 24 +++++------------- go-controller/pkg/ovn/ovn.go | 26 +++----------------- 4 files changed, 11 insertions(+), 48 deletions(-) diff --git a/go-controller/pkg/ovn/egressfirewall_test.go b/go-controller/pkg/ovn/egressfirewall_test.go index db30bfb68b2..d91a8d2da0f 100644 --- a/go-controller/pkg/ovn/egressfirewall_test.go +++ b/go-controller/pkg/ovn/egressfirewall_test.go @@ -378,13 +378,6 @@ var _ = ginkgo.Describe("OVN EgressFirewall Operations for local gateway mode", }, } - //fExec.AddFakeCmdsNoOutputNoError([]string{ - // fmt.Sprintf("ovn-nbctl --timeout=15 --data=bare --no-heading --columns=external_id --format=table find acl priority<=%d priority>=%d", t.EgressFirewallStartPriority, t.MinimumReservedEgressFirewallPriority), - // fmt.Sprintf("ovn-nbctl --timeout=15 --data=bare --no-heading --columns=_uuid --format=table find acl priority<=%d priority>=%d direction=%s", t.EgressFirewallStartPriority, t.MinimumReservedEgressFirewallPriority, t.DirectionFromLPort), - // "ovn-nbctl --timeout=15 --data=bare --no-heading --columns=_uuid --format=table find ACL match=\"(ip4.dst == 1.2.3.4/23) && ip4.src == $a10481622940199974102 && ((udp && ( udp.dst == 100 ))) && ip4.dst != 10.128.0.0/14\" action=drop external-ids:egressFirewall=namespace1", - // "ovn-nbctl --timeout=15 --id=@node1-10000 create acl priority=10000 direction=" + t.DirectionToLPort + " match=\"(ip4.dst == 1.2.3.4/23) && ip4.src == $a10481622940199974102 && ((udp && ( udp.dst == 100 ))) && ip4.dst != 10.128.0.0/14\" action=drop external-ids:egressFirewall=namespace1 -- add logical_switch " + node1Name + " acls @node1-10000", - //}) - namespace1 := *newNamespace("namespace1") egressFirewall := newEgressFirewallObject("default", namespace1.Name, []egressfirewallapi.EgressFirewallRule{ { diff --git a/go-controller/pkg/ovn/libovsdbops/chassis.go b/go-controller/pkg/ovn/libovsdbops/chassis.go index 5789d902b8f..b9321cdb957 100644 --- a/go-controller/pkg/ovn/libovsdbops/chassis.go +++ b/go-controller/pkg/ovn/libovsdbops/chassis.go @@ -10,7 +10,7 @@ import ( "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" ) -// findChassis returns all the logical chassis +// ListChassis returns all the logical chassis func ListChassis(sbClient libovsdbclient.Client) ([]sbdb.Chassis, error) { ctx, cancel := context.WithTimeout(context.Background(), types.OVSDBTimeout) defer cancel() diff --git a/go-controller/pkg/ovn/master_test.go b/go-controller/pkg/ovn/master_test.go index 2ef087a91bc..439914db072 100644 --- a/go-controller/pkg/ovn/master_test.go +++ b/go-controller/pkg/ovn/master_test.go @@ -21,7 +21,6 @@ import ( addressset "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/address_set" lsm "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/logical_switch_manager" ovntest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing/libovsdb" libovsdbtest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing/libovsdb" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util" @@ -64,6 +63,7 @@ type tNode struct { DnatSnatIP string } +/* func cleanupGateway(fexec *ovntest.FakeExec, nodeName string, nodeSubnet string, clusterCIDR string, nextHop string) { const ( node1RouteUUID string = "0cac12cf-3e0f-4682-b028-5ea2e0001962" @@ -88,7 +88,6 @@ func cleanupGateway(fexec *ovntest.FakeExec, nodeName string, nodeSubnet string, }) } -/* func defaultFakeExec(nodeSubnet, nodeName string, sctpSupport bool) *ovntest.FakeExec { const ( mgmtMAC string = "01:02:03:04:05:06" @@ -240,7 +239,7 @@ func addNodeportLBs(fexec *ovntest.FakeExec, nodeName, tcpLBUUID, udpLBUUID, sct } */ -func addNodeLogicalFlows(testData []libovsdb.TestData, expectedOVNClusterRouter *nbdb.LogicalRouter, expectedNodeSwitch *nbdb.LogicalSwitch, expectedClusterRouterPortGroup, expectedClusterPortGroup *nbdb.PortGroup, node *tNode, clusterCIDR string, enableIPv6 bool) []libovsdb.TestData { +func addNodeLogicalFlows(testData []libovsdbtest.TestData, expectedOVNClusterRouter *nbdb.LogicalRouter, expectedNodeSwitch *nbdb.LogicalSwitch, expectedClusterRouterPortGroup, expectedClusterPortGroup *nbdb.PortGroup, node *tNode, clusterCIDR string, enableIPv6 bool) []libovsdbtest.TestData { lrpName := types.RouterToSwitchPrefix + node.Name chassisName := node.SystemID @@ -891,11 +890,7 @@ var _ = ginkgo.Describe("Gateway Init Operations", func() { EgressFirewallClient: egressFirewallFakeClient, } - fexec := ovntest.NewLooseCompareFakeExec() - err := util.SetExec(fexec) - gomega.Expect(err).NotTo(gomega.HaveOccurred()) - - _, err = config.InitConfig(ctx, fexec, nil) + _, err := config.InitConfig(ctx, nil, nil) gomega.Expect(err).NotTo(gomega.HaveOccurred()) config.Kubernetes.HostNetworkNamespace = "" nodeAnnotator := kube.NewNodeAnnotator(&kube.Kube{kubeFakeClient, egressIPFakeClient, egressFirewallFakeClient, nil}, testNode.Name) @@ -978,7 +973,7 @@ var _ = ginkgo.Describe("Gateway Init Operations", func() { libovsdbOvnNBClient, libovsdbOvnSBClient, libovsdbCleanup, err = libovsdbtest.NewNBSBTestHarness(dbSetup) gomega.Expect(err).NotTo(gomega.HaveOccurred()) - expectedDatabaseState := []libovsdb.TestData{} + expectedDatabaseState := []libovsdbtest.TestData{} expectedDatabaseState = addNodeLogicalFlows(expectedDatabaseState, expectedOVNClusterRouter, expectedNodeSwitch, expectedClusterRouterPortGroup, expectedClusterPortGroup, &node1, clusterCIDR, config.IPv6Mode) clusterController := NewOvnController(fakeClient, f, stopChan, addressset.NewFakeAddressSetFactory(), @@ -1020,9 +1015,6 @@ var _ = ginkgo.Describe("Gateway Init Operations", func() { expectedDatabaseState = generateGatewayInitExpectedNB(expectedDatabaseState, expectedOVNClusterRouter, expectedNodeSwitch, node1.Name, clusterSubnets, []*net.IPNet{subnet}, l3Config, []*net.IPNet{joinLRPIPs}, []*net.IPNet{dLRPIPs}, skipSnat, node1.NodeMgmtPortIP) gomega.Eventually(libovsdbOvnNBClient).Should(libovsdbtest.HaveData(expectedDatabaseState)) - // Make sure remaining fexec calls are still correct - gomega.Expect(fexec.CalledMatchesExpected()).To(gomega.BeTrue(), fexec.ErrorDesc) - return nil } @@ -1086,11 +1078,7 @@ var _ = ginkgo.Describe("Gateway Init Operations", func() { EgressFirewallClient: egressFirewallFakeClient, } - fexec := ovntest.NewLooseCompareFakeExec() - err := util.SetExec(fexec) - gomega.Expect(err).NotTo(gomega.HaveOccurred()) - - _, err = config.InitConfig(ctx, fexec, nil) + _, err := config.InitConfig(ctx, nil, nil) gomega.Expect(err).NotTo(gomega.HaveOccurred()) config.Kubernetes.HostNetworkNamespace = "" nodeAnnotator := kube.NewNodeAnnotator(&kube.Kube{kubeFakeClient, egressIPFakeClient, egressFirewallFakeClient, nil}, testNode.Name) @@ -1173,7 +1161,7 @@ var _ = ginkgo.Describe("Gateway Init Operations", func() { libovsdbOvnNBClient, libovsdbOvnSBClient, libovsdbCleanup, err = libovsdbtest.NewNBSBTestHarness(dbSetup) gomega.Expect(err).NotTo(gomega.HaveOccurred()) - expectedDatabaseState := []libovsdb.TestData{} + expectedDatabaseState := []libovsdbtest.TestData{} expectedDatabaseState = addNodeLogicalFlows(expectedDatabaseState, expectedOVNClusterRouter, expectedNodeSwitch, expectedClusterRouterPortGroup, expectedClusterPortGroup, &node1, clusterCIDR, config.IPv6Mode) clusterController := NewOvnController(fakeClient, f, stopChan, addressset.NewFakeAddressSetFactory(), diff --git a/go-controller/pkg/ovn/ovn.go b/go-controller/pkg/ovn/ovn.go index 7b1376ffb5e..a663dd561fc 100644 --- a/go-controller/pkg/ovn/ovn.go +++ b/go-controller/pkg/ovn/ovn.go @@ -753,19 +753,12 @@ func (oc *Controller) WatchEgressFirewall() *factory.Handler { return oc.watchFactory.AddEgressFirewallHandler(cache.ResourceEventHandlerFuncs{ AddFunc: func(obj interface{}) { egressFirewall := obj.(*egressfirewall.EgressFirewall).DeepCopy() - txn := util.NewNBTxn() addErrors := oc.addEgressFirewall(egressFirewall) if addErrors != nil { klog.Error(addErrors) egressFirewall.Status.Status = egressFirewallAddError } else { - _, stderr, err := txn.Commit() - if err != nil { - klog.Errorf("Failed to commit db changes for egressFirewall in namespace %s stderr: %q, err: %+v", egressFirewall.Namespace, stderr, err) - egressFirewall.Status.Status = egressFirewallAddError - } else { - egressFirewall.Status.Status = egressFirewallAppliedCorrectly - } + egressFirewall.Status.Status = egressFirewallAppliedCorrectly } err := oc.updateEgressFirewallWithRetry(egressFirewall) @@ -779,21 +772,14 @@ func (oc *Controller) WatchEgressFirewall() *factory.Handler { newEgressFirewall := newer.(*egressfirewall.EgressFirewall).DeepCopy() oldEgressFirewall := old.(*egressfirewall.EgressFirewall) if !reflect.DeepEqual(oldEgressFirewall.Spec, newEgressFirewall.Spec) { - txn := util.NewNBTxn() errList := oc.updateEgressFirewall(oldEgressFirewall, newEgressFirewall) if errList != nil { newEgressFirewall.Status.Status = egressFirewallUpdateError klog.Error(errList) } else { - _, stderr, err := txn.Commit() - if err != nil { - klog.Errorf("Failed to commit db changes for egressFirewall in namespace %s stderr: %q, err: %+v", newEgressFirewall.Namespace, stderr, err) - newEgressFirewall.Status.Status = egressFirewallUpdateError - - } else { - newEgressFirewall.Status.Status = egressFirewallAppliedCorrectly - } + newEgressFirewall.Status.Status = egressFirewallAppliedCorrectly } + err := oc.updateEgressFirewallWithRetry(newEgressFirewall) if err != nil { klog.Error(err) @@ -803,16 +789,12 @@ func (oc *Controller) WatchEgressFirewall() *factory.Handler { }, DeleteFunc: func(obj interface{}) { egressFirewall := obj.(*egressfirewall.EgressFirewall) - txn := util.NewNBTxn() deleteErrors := oc.deleteEgressFirewall(egressFirewall) if deleteErrors != nil { klog.Error(deleteErrors) return } - stdout, stderr, err := txn.Commit() - if err != nil { - klog.Errorf("Failed to commit db changes for egressFirewall in namespace %s stdout: %q, stderr: %q, err: %+v", egressFirewall.Namespace, stdout, stderr, err) - } + metrics.UpdateEgressFirewallRuleCount(float64(-len(egressFirewall.Spec.Egress))) metrics.DecrementEgressFirewallCount() }, From c8c1899c9259fc629c08fe89b124ed2fa6280f58 Mon Sep 17 00:00:00 2001 From: astoycos Date: Wed, 8 Dec 2021 11:27:33 -0500 Subject: [PATCH 6/7] Remove some nb/sb ctl helper functions Remove all of the unused nb/sb ctl helper functions from the util package and add notes on when the rest can be removed Signed-off-by: astoycos --- go-controller/pkg/util/ovs.go | 55 ++-------- go-controller/pkg/util/ovs_unit_test.go | 129 ------------------------ 2 files changed, 6 insertions(+), 178 deletions(-) diff --git a/go-controller/pkg/util/ovs.go b/go-controller/pkg/util/ovs.go index 468ad956c9d..ad0a18e42a3 100644 --- a/go-controller/pkg/util/ovs.go +++ b/go-controller/pkg/util/ovs.go @@ -2,7 +2,6 @@ package util import ( "bytes" - "encoding/csv" "encoding/json" "fmt" "os" @@ -13,7 +12,6 @@ import ( "strings" "sync/atomic" "time" - "unicode" "github.com/pkg/errors" @@ -409,6 +407,7 @@ func RunOVNAppctlWithTimeout(timeout int, args ...string) (string, string, error // Run the ovn-ctl command and retry if "Connection refused" // poll waitng for service to become available +// FIXME: Remove when https://github.com/ovn-org/libovsdb/issues/235 is fixed func runOVNretry(cmdPath string, envVars []string, args ...string) (*bytes.Buffer, *bytes.Buffer, error) { retriesLeft := ovnCmdRetryCount @@ -513,23 +512,15 @@ func getNbOVSDBArgs(command string, args ...string) []string { return cmdArgs } -// RunOVNNbctlUnix runs command via ovn-nbctl, with ovn-nbctl using the unix -// domain sockets to connect to the ovsdb-server backing the OVN NB database. -func RunOVNNbctlUnix(args ...string) (string, string, error) { - cmdArgs := []string{fmt.Sprintf("--timeout=%d", ovsCommandTimeout)} - cmdArgs = append(cmdArgs, args...) - stdout, stderr, err := runOVNretry(runner.nbctlPath, nil, cmdArgs...) - return strings.Trim(strings.TrimFunc(stdout.String(), unicode.IsSpace), "\""), - stderr.String(), err -} - // RunOVNNbctlWithTimeout runs command via ovn-nbctl with a specific timeout +// FIXME: Remove when https://github.com/ovn-org/libovsdb/issues/235 is fixed func RunOVNNbctlWithTimeout(timeout int, args ...string) (string, string, error) { stdout, stderr, err := RunOVNNbctlRawOutput(timeout, args...) return strings.Trim(strings.TrimSpace(stdout), "\""), stderr, err } // RunOVNNbctlRawOutput returns the output with no trimming or other string manipulation +// FIXME: Remove when https://github.com/ovn-org/libovsdb/issues/235 is fixed func RunOVNNbctlRawOutput(timeout int, args ...string) (string, string, error) { cmdArgs, envVars := getNbctlArgsAndEnv(timeout, args...) start := time.Now() @@ -540,43 +531,14 @@ func RunOVNNbctlRawOutput(timeout int, args ...string) (string, string, error) { return stdout.String(), stderr.String(), err } -// RunOVNNbctlCSV runs an nbctl command that results in CSV output, parses the rows returned, -// and returns the records -func RunOVNNbctlCSV(args []string) ([][]string, error) { - args = append([]string{"--no-heading", "--format=csv"}, args...) - - stdout, _, err := RunOVNNbctlRawOutput(15, args...) - if err != nil { - return nil, err - } - if len(stdout) == 0 { - return nil, nil - } - - r := csv.NewReader(strings.NewReader(stdout)) - records, err := r.ReadAll() - if err != nil { - return nil, fmt.Errorf("failed to parse nbctl CSV response: %w", err) - } - return records, nil -} - // RunOVNNbctl runs a command via ovn-nbctl. +// FIXME: Remove when https://github.com/ovn-org/libovsdb/issues/235 is fixed func RunOVNNbctl(args ...string) (string, string, error) { return RunOVNNbctlWithTimeout(ovsCommandTimeout, args...) } -// RunOVNSbctlUnix runs command via ovn-sbctl, with ovn-sbctl using the unix -// domain sockets to connect to the ovsdb-server backing the OVN SB database. -func RunOVNSbctlUnix(args ...string) (string, string, error) { - cmdArgs := []string{fmt.Sprintf("--timeout=%d", ovsCommandTimeout)} - cmdArgs = append(cmdArgs, args...) - stdout, stderr, err := runOVNretry(runner.sbctlPath, nil, cmdArgs...) - return strings.Trim(strings.TrimFunc(stdout.String(), unicode.IsSpace), "\""), - stderr.String(), err -} - // RunOVNSbctlWithTimeout runs command via ovn-sbctl with a specific timeout +// FIXME: Remove when https://github.com/ovn-org/libovsdb/issues/235 is fixed func RunOVNSbctlWithTimeout(timeout int, args ...string) (string, string, error) { var cmdArgs []string @@ -623,16 +585,11 @@ func RunOVSDBClientOVNNB(command string, args ...string) (string, string, error) } // RunOVNSbctl runs a command via ovn-sbctl. +// FIXME: Remove when https://github.com/ovn-org/libovsdb/issues/235 is fixed func RunOVNSbctl(args ...string) (string, string, error) { return RunOVNSbctlWithTimeout(ovsCommandTimeout, args...) } -// RunOVNCtl runs an ovn-ctl command. -func RunOVNCtl(args ...string) (string, string, error) { - stdout, stderr, err := runOVNretry(runner.ovnctlPath, nil, args...) - return strings.Trim(strings.TrimSpace(stdout.String()), "\""), stderr.String(), err -} - // RunOVNNBAppCtlWithTimeout runs an ovn-appctl command with a timeout to nbdb func RunOVNNBAppCtlWithTimeout(timeout int, args ...string) (string, string, error) { cmdArgs := []string{fmt.Sprintf("--timeout=%d", timeout)} diff --git a/go-controller/pkg/util/ovs_unit_test.go b/go-controller/pkg/util/ovs_unit_test.go index dd10d12fdb1..e192f7924fc 100644 --- a/go-controller/pkg/util/ovs_unit_test.go +++ b/go-controller/pkg/util/ovs_unit_test.go @@ -1302,49 +1302,6 @@ func TestRunOVNAppctlWithTimeout(t *testing.T) { } } -func TestRunOVNNbctlUnix(t *testing.T) { - mockKexecIface := new(mock_k8s_io_utils_exec.Interface) - mockExecRunner := new(mocks.ExecRunner) - mockCmd := new(mock_k8s_io_utils_exec.Cmd) - // below is defined in ovs.go - runCmdExecRunner = mockExecRunner - // note runner is defined in ovs.go file - runner = &execHelper{exec: mockKexecIface} - tests := []struct { - desc string - expectedErr error - onRetArgsExecUtilsIface *ovntest.TestifyMockHelper - onRetArgsKexecIface *ovntest.TestifyMockHelper - }{ - { - desc: "negative: run `ovn-nbctl` command with no env vars generated", - expectedErr: fmt.Errorf("failed to execute ovn-nbctl command"), - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string"}, RetArgList: []interface{}{nil, nil, fmt.Errorf("failed to execute ovn-nbctl command")}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string"}, RetArgList: []interface{}{mockCmd}}, - }, - { - desc: "positive: run `ovn-nbctl` command with no env vars generated", - expectedErr: nil, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("testblah")), bytes.NewBuffer([]byte("")), nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string"}, RetArgList: []interface{}{mockCmd}}, - }, - } - for i, tc := range tests { - t.Run(fmt.Sprintf("%d:%s", i, tc.desc), func(t *testing.T) { - ovntest.ProcessMockFn(&mockExecRunner.Mock, *tc.onRetArgsExecUtilsIface) - ovntest.ProcessMockFn(&mockKexecIface.Mock, *tc.onRetArgsKexecIface) - - _, _, e := RunOVNNbctlUnix() - - if tc.expectedErr != nil { - assert.Error(t, e) - } - mockExecRunner.AssertExpectations(t) - mockKexecIface.AssertExpectations(t) - }) - } -} - func TestRunOVNNbctlWithTimeout(t *testing.T) { mockKexecIface := new(mock_k8s_io_utils_exec.Interface) mockExecRunner := new(mocks.ExecRunner) @@ -1434,49 +1391,6 @@ func TestRunOVNNbctl(t *testing.T) { } } -func TestRunOVNSbctlUnix(t *testing.T) { - mockKexecIface := new(mock_k8s_io_utils_exec.Interface) - mockExecRunner := new(mocks.ExecRunner) - mockCmd := new(mock_k8s_io_utils_exec.Cmd) - // below is defined in ovs.go - runCmdExecRunner = mockExecRunner - // note runner is defined in ovs.go file - runner = &execHelper{exec: mockKexecIface} - tests := []struct { - desc string - expectedErr error - onRetArgsExecUtilsIface *ovntest.TestifyMockHelper - onRetArgsKexecIface *ovntest.TestifyMockHelper - }{ - { - desc: "negative: run `ovn-sbctl` command with no env vars generated", - expectedErr: fmt.Errorf("failed to execute ovn-sbctl command"), - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string"}, RetArgList: []interface{}{nil, nil, fmt.Errorf("failed to execute ovn-sbctl command")}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string"}, RetArgList: []interface{}{mockCmd}}, - }, - { - desc: "positive: run `ovn-sbctl` command with no env vars generated", - expectedErr: nil, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("testblah")), bytes.NewBuffer([]byte("")), nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string"}, RetArgList: []interface{}{mockCmd}}, - }, - } - for i, tc := range tests { - t.Run(fmt.Sprintf("%d:%s", i, tc.desc), func(t *testing.T) { - ovntest.ProcessMockFn(&mockExecRunner.Mock, *tc.onRetArgsExecUtilsIface) - ovntest.ProcessMockFn(&mockKexecIface.Mock, *tc.onRetArgsKexecIface) - - _, _, e := RunOVNSbctlUnix() - - if tc.expectedErr != nil { - assert.Error(t, e) - } - mockExecRunner.AssertExpectations(t) - mockKexecIface.AssertExpectations(t) - }) - } -} - func TestRunOVNSbctlWithTimeout(t *testing.T) { mockKexecIface := new(mock_k8s_io_utils_exec.Interface) mockExecRunner := new(mocks.ExecRunner) @@ -1695,49 +1609,6 @@ func TestRunOVSDBClientOVNNB(t *testing.T) { } } -func TestRunOVNCtl(t *testing.T) { - mockKexecIface := new(mock_k8s_io_utils_exec.Interface) - mockExecRunner := new(mocks.ExecRunner) - mockCmd := new(mock_k8s_io_utils_exec.Cmd) - // below is defined in ovs.go - runCmdExecRunner = mockExecRunner - // note runner is defined in ovs.go file - runner = &execHelper{exec: mockKexecIface} - tests := []struct { - desc string - expectedErr error - onRetArgsExecUtilsIface *ovntest.TestifyMockHelper - onRetArgsKexecIface *ovntest.TestifyMockHelper - }{ - { - desc: "negative: run `ovn-ctl` command", - expectedErr: fmt.Errorf("failed to execute ovn-ctl command"), - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string"}, RetArgList: []interface{}{nil, nil, fmt.Errorf("failed to execute ovn-ctl command")}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - }, - { - desc: "positive: run `ovn-ctl` command", - expectedErr: nil, - onRetArgsExecUtilsIface: &ovntest.TestifyMockHelper{OnCallMethodName: "RunCmd", OnCallMethodArgType: []string{"*mocks.Cmd", "string", "[]string", "string", "string"}, RetArgList: []interface{}{bytes.NewBuffer([]byte("testblah")), bytes.NewBuffer([]byte("")), nil}}, - onRetArgsKexecIface: &ovntest.TestifyMockHelper{OnCallMethodName: "Command", OnCallMethodArgType: []string{"string", "string", "string"}, RetArgList: []interface{}{mockCmd}}, - }, - } - for i, tc := range tests { - t.Run(fmt.Sprintf("%d:%s", i, tc.desc), func(t *testing.T) { - ovntest.ProcessMockFn(&mockExecRunner.Mock, *tc.onRetArgsExecUtilsIface) - ovntest.ProcessMockFn(&mockKexecIface.Mock, *tc.onRetArgsKexecIface) - - _, _, e := RunOVNCtl() - - if tc.expectedErr != nil { - assert.Error(t, e) - } - mockExecRunner.AssertExpectations(t) - mockKexecIface.AssertExpectations(t) - }) - } -} - func TestRunOVNNBAppCtl(t *testing.T) { mockKexecIface := new(mock_k8s_io_utils_exec.Interface) mockExecRunner := new(mocks.ExecRunner) From cd445c5e7e94fb13535c051a307d4f69336252ab Mon Sep 17 00:00:00 2001 From: astoycos Date: Tue, 7 Dec 2021 16:38:33 -0500 Subject: [PATCH 7/7] Move libovsdbops package Move the libovsdbops package out of the `go-controller/pkg/ovn` directory and into `go-controller/pkg` since its used by many packages in the directory. Signed-off-by: astoycos --- go-controller/hybrid-overlay/pkg/controller/master.go | 3 ++- go-controller/hybrid-overlay/pkg/controller/master_test.go | 3 ++- go-controller/hybrid-overlay/pkg/controller/out.txt | 0 go-controller/pkg/{ovn => }/libovsdbops/acl.go | 0 go-controller/pkg/{ovn => }/libovsdbops/chassis.go | 0 go-controller/pkg/{ovn => }/libovsdbops/datapath.go | 0 go-controller/pkg/{ovn => }/libovsdbops/lbgroup.go | 0 go-controller/pkg/{ovn => }/libovsdbops/loadbalancer.go | 0 .../pkg/{ovn => }/libovsdbops/logical_switch_port.go | 0 go-controller/pkg/{ovn => }/libovsdbops/mac_binding.go | 0 go-controller/pkg/{ovn => }/libovsdbops/meter.go | 0 go-controller/pkg/{ovn => }/libovsdbops/model.go | 0 go-controller/pkg/{ovn => }/libovsdbops/model_client.go | 0 .../pkg/{ovn => }/libovsdbops/model_client_test.go | 0 go-controller/pkg/{ovn => }/libovsdbops/named_uuid.go | 0 go-controller/pkg/{ovn => }/libovsdbops/nb_global.go | 0 go-controller/pkg/{ovn => }/libovsdbops/portgroup.go | 0 go-controller/pkg/{ovn => }/libovsdbops/router.go | 0 go-controller/pkg/{ovn => }/libovsdbops/sb_global.go | 0 go-controller/pkg/{ovn => }/libovsdbops/switch.go | 0 go-controller/pkg/{ovn => }/libovsdbops/switch_test.go | 0 go-controller/pkg/{ovn => }/libovsdbops/transact.go | 0 go-controller/pkg/metrics/master.go | 3 ++- go-controller/pkg/metrics/ovn_db.go | 4 ++-- go-controller/pkg/node/node_test.go | 1 + go-controller/pkg/ovn/address_set/address_set.go | 6 ++++-- go-controller/pkg/ovn/controller/services/repair.go | 3 ++- go-controller/pkg/ovn/controller/unidling/unidle.go | 1 + go-controller/pkg/ovn/egressfirewall.go | 3 ++- go-controller/pkg/ovn/egressfirewall_test.go | 3 ++- go-controller/pkg/ovn/egressgw.go | 3 ++- go-controller/pkg/ovn/egressgw_test.go | 3 ++- go-controller/pkg/ovn/egressip.go | 3 ++- go-controller/pkg/ovn/gateway_cleanup.go | 3 ++- go-controller/pkg/ovn/gateway_init.go | 3 ++- go-controller/pkg/ovn/gateway_test.go | 3 ++- go-controller/pkg/ovn/gress_policy.go | 3 ++- go-controller/pkg/ovn/loadbalancer/lb_cache.go | 3 ++- go-controller/pkg/ovn/loadbalancer/loadbalancer.go | 2 +- go-controller/pkg/ovn/master.go | 3 ++- go-controller/pkg/ovn/ovn.go | 3 ++- go-controller/pkg/ovn/pods.go | 5 +++-- go-controller/pkg/ovn/pods_test.go | 3 ++- go-controller/pkg/ovn/policy.go | 3 ++- go-controller/pkg/ovn/policy_test.go | 3 ++- go-controller/pkg/util/ovn.go | 3 ++- go-controller/pkg/util/util.go | 3 ++- 47 files changed, 54 insertions(+), 28 deletions(-) delete mode 100644 go-controller/hybrid-overlay/pkg/controller/out.txt rename go-controller/pkg/{ovn => }/libovsdbops/acl.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/chassis.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/datapath.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/lbgroup.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/loadbalancer.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/logical_switch_port.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/mac_binding.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/meter.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/model.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/model_client.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/model_client_test.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/named_uuid.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/nb_global.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/portgroup.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/router.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/sb_global.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/switch.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/switch_test.go (100%) rename go-controller/pkg/{ovn => }/libovsdbops/transact.go (100%) diff --git a/go-controller/hybrid-overlay/pkg/controller/master.go b/go-controller/hybrid-overlay/pkg/controller/master.go index 97373c32124..3bc5d1e0676 100644 --- a/go-controller/hybrid-overlay/pkg/controller/master.go +++ b/go-controller/hybrid-overlay/pkg/controller/master.go @@ -12,8 +12,9 @@ import ( "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/informer" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/kube" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/subnetallocator" ovntypes "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util" diff --git a/go-controller/hybrid-overlay/pkg/controller/master_test.go b/go-controller/hybrid-overlay/pkg/controller/master_test.go index 79f139ae151..c1c47da4825 100644 --- a/go-controller/hybrid-overlay/pkg/controller/master_test.go +++ b/go-controller/hybrid-overlay/pkg/controller/master_test.go @@ -16,8 +16,9 @@ import ( "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/informer" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/kube" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + ovntest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing" libovsdbtest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing/libovsdb" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" diff --git a/go-controller/hybrid-overlay/pkg/controller/out.txt b/go-controller/hybrid-overlay/pkg/controller/out.txt deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/go-controller/pkg/ovn/libovsdbops/acl.go b/go-controller/pkg/libovsdbops/acl.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/acl.go rename to go-controller/pkg/libovsdbops/acl.go diff --git a/go-controller/pkg/ovn/libovsdbops/chassis.go b/go-controller/pkg/libovsdbops/chassis.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/chassis.go rename to go-controller/pkg/libovsdbops/chassis.go diff --git a/go-controller/pkg/ovn/libovsdbops/datapath.go b/go-controller/pkg/libovsdbops/datapath.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/datapath.go rename to go-controller/pkg/libovsdbops/datapath.go diff --git a/go-controller/pkg/ovn/libovsdbops/lbgroup.go b/go-controller/pkg/libovsdbops/lbgroup.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/lbgroup.go rename to go-controller/pkg/libovsdbops/lbgroup.go diff --git a/go-controller/pkg/ovn/libovsdbops/loadbalancer.go b/go-controller/pkg/libovsdbops/loadbalancer.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/loadbalancer.go rename to go-controller/pkg/libovsdbops/loadbalancer.go diff --git a/go-controller/pkg/ovn/libovsdbops/logical_switch_port.go b/go-controller/pkg/libovsdbops/logical_switch_port.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/logical_switch_port.go rename to go-controller/pkg/libovsdbops/logical_switch_port.go diff --git a/go-controller/pkg/ovn/libovsdbops/mac_binding.go b/go-controller/pkg/libovsdbops/mac_binding.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/mac_binding.go rename to go-controller/pkg/libovsdbops/mac_binding.go diff --git a/go-controller/pkg/ovn/libovsdbops/meter.go b/go-controller/pkg/libovsdbops/meter.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/meter.go rename to go-controller/pkg/libovsdbops/meter.go diff --git a/go-controller/pkg/ovn/libovsdbops/model.go b/go-controller/pkg/libovsdbops/model.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/model.go rename to go-controller/pkg/libovsdbops/model.go diff --git a/go-controller/pkg/ovn/libovsdbops/model_client.go b/go-controller/pkg/libovsdbops/model_client.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/model_client.go rename to go-controller/pkg/libovsdbops/model_client.go diff --git a/go-controller/pkg/ovn/libovsdbops/model_client_test.go b/go-controller/pkg/libovsdbops/model_client_test.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/model_client_test.go rename to go-controller/pkg/libovsdbops/model_client_test.go diff --git a/go-controller/pkg/ovn/libovsdbops/named_uuid.go b/go-controller/pkg/libovsdbops/named_uuid.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/named_uuid.go rename to go-controller/pkg/libovsdbops/named_uuid.go diff --git a/go-controller/pkg/ovn/libovsdbops/nb_global.go b/go-controller/pkg/libovsdbops/nb_global.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/nb_global.go rename to go-controller/pkg/libovsdbops/nb_global.go diff --git a/go-controller/pkg/ovn/libovsdbops/portgroup.go b/go-controller/pkg/libovsdbops/portgroup.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/portgroup.go rename to go-controller/pkg/libovsdbops/portgroup.go diff --git a/go-controller/pkg/ovn/libovsdbops/router.go b/go-controller/pkg/libovsdbops/router.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/router.go rename to go-controller/pkg/libovsdbops/router.go diff --git a/go-controller/pkg/ovn/libovsdbops/sb_global.go b/go-controller/pkg/libovsdbops/sb_global.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/sb_global.go rename to go-controller/pkg/libovsdbops/sb_global.go diff --git a/go-controller/pkg/ovn/libovsdbops/switch.go b/go-controller/pkg/libovsdbops/switch.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/switch.go rename to go-controller/pkg/libovsdbops/switch.go diff --git a/go-controller/pkg/ovn/libovsdbops/switch_test.go b/go-controller/pkg/libovsdbops/switch_test.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/switch_test.go rename to go-controller/pkg/libovsdbops/switch_test.go diff --git a/go-controller/pkg/ovn/libovsdbops/transact.go b/go-controller/pkg/libovsdbops/transact.go similarity index 100% rename from go-controller/pkg/ovn/libovsdbops/transact.go rename to go-controller/pkg/libovsdbops/transact.go diff --git a/go-controller/pkg/metrics/master.go b/go-controller/pkg/metrics/master.go index 88ffb81e66e..2dd68613d86 100644 --- a/go-controller/pkg/metrics/master.go +++ b/go-controller/pkg/metrics/master.go @@ -10,9 +10,10 @@ import ( "github.com/ovn-org/libovsdb/client" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/sbdb" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util" "github.com/prometheus/client_golang/prometheus" diff --git a/go-controller/pkg/metrics/ovn_db.go b/go-controller/pkg/metrics/ovn_db.go index c271b06149a..b5a534ab3c5 100644 --- a/go-controller/pkg/metrics/ovn_db.go +++ b/go-controller/pkg/metrics/ovn_db.go @@ -266,10 +266,10 @@ func ovnE2eTimeStampUpdater(direction, database string) { var err error if direction == "sb" { - stdout, stderr, err = util.RunOVNSbctlUnix("--if-exists", "--no-leader-only", + stdout, stderr, err = util.RunOVNSbctl("--if-exists", "--no-leader-only", "get", "SB_Global", ".", "options:e2e_timestamp") } else { - stdout, stderr, err = util.RunOVNNbctlUnix("--if-exists", "--no-leader-only", + stdout, stderr, err = util.RunOVNNbctl("--if-exists", "--no-leader-only", "get", "NB_Global", ".", "options:e2e_timestamp") } if err != nil { diff --git a/go-controller/pkg/node/node_test.go b/go-controller/pkg/node/node_test.go index 932153f4f9c..7808344cc11 100644 --- a/go-controller/pkg/node/node_test.go +++ b/go-controller/pkg/node/node_test.go @@ -9,6 +9,7 @@ import ( "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/kube/mocks" + ovntest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing" netlink_mocks "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing/mocks/github.com/vishvananda/netlink" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" diff --git a/go-controller/pkg/ovn/address_set/address_set.go b/go-controller/pkg/ovn/address_set/address_set.go index 52826c22365..4e5694807c3 100644 --- a/go-controller/pkg/ovn/address_set/address_set.go +++ b/go-controller/pkg/ovn/address_set/address_set.go @@ -3,19 +3,21 @@ package addressset import ( "context" "fmt" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" "net" "sort" "strings" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" + "github.com/pkg/errors" libovsdbclient "github.com/ovn-org/libovsdb/client" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" + libovsdbops "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - libovsdbops "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util" "k8s.io/apimachinery/pkg/util/sets" diff --git a/go-controller/pkg/ovn/controller/services/repair.go b/go-controller/pkg/ovn/controller/services/repair.go index 02affe27bbb..6feafb98108 100644 --- a/go-controller/pkg/ovn/controller/services/repair.go +++ b/go-controller/pkg/ovn/controller/services/repair.go @@ -8,7 +8,8 @@ import ( libovsdbclient "github.com/ovn-org/libovsdb/client" globalconfig "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" + ovnlb "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/loadbalancer" apierrors "k8s.io/apimachinery/pkg/api/errors" diff --git a/go-controller/pkg/ovn/controller/unidling/unidle.go b/go-controller/pkg/ovn/controller/unidling/unidle.go index 36745b6c3c7..eb0e9a844cc 100644 --- a/go-controller/pkg/ovn/controller/unidling/unidle.go +++ b/go-controller/pkg/ovn/controller/unidling/unidle.go @@ -11,6 +11,7 @@ import ( "github.com/ovn-org/libovsdb/ovsdb" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/sbdb" ovntypes "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util" kapi "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" diff --git a/go-controller/pkg/ovn/egressfirewall.go b/go-controller/pkg/ovn/egressfirewall.go index c61b4c3c4bd..d4d2cd252a8 100644 --- a/go-controller/pkg/ovn/egressfirewall.go +++ b/go-controller/pkg/ovn/egressfirewall.go @@ -10,9 +10,10 @@ import ( "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" egressfirewallapi "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/crd/egressfirewall/v1" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" addressset "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/address_set" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" kapi "k8s.io/api/core/v1" diff --git a/go-controller/pkg/ovn/egressfirewall_test.go b/go-controller/pkg/ovn/egressfirewall_test.go index d91a8d2da0f..b567a6785df 100644 --- a/go-controller/pkg/ovn/egressfirewall_test.go +++ b/go-controller/pkg/ovn/egressfirewall_test.go @@ -11,9 +11,10 @@ import ( "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" egressfirewallapi "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/crd/egressfirewall/v1" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" addressset "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/address_set" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing/libovsdb" libovsdbtest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing/libovsdb" t "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" diff --git a/go-controller/pkg/ovn/egressgw.go b/go-controller/pkg/ovn/egressgw.go index 667d5198625..557e2f3a20a 100644 --- a/go-controller/pkg/ovn/egressgw.go +++ b/go-controller/pkg/ovn/egressgw.go @@ -15,8 +15,9 @@ import ( libovsdbclient "github.com/ovn-org/libovsdb/client" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/factory" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" ovntypes "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util" diff --git a/go-controller/pkg/ovn/egressgw_test.go b/go-controller/pkg/ovn/egressgw_test.go index 3434178c6e3..63c9dd20b6e 100644 --- a/go-controller/pkg/ovn/egressgw_test.go +++ b/go-controller/pkg/ovn/egressgw_test.go @@ -7,8 +7,9 @@ import ( "strconv" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + libovsdbtest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing/libovsdb" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" ovntypes "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" diff --git a/go-controller/pkg/ovn/egressip.go b/go-controller/pkg/ovn/egressip.go index b152d4c4a32..3ef3328f01b 100644 --- a/go-controller/pkg/ovn/egressip.go +++ b/go-controller/pkg/ovn/egressip.go @@ -19,9 +19,10 @@ import ( "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" egressipv1 "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/crd/egressip/v1" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/factory" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/metrics" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util" kapi "k8s.io/api/core/v1" diff --git a/go-controller/pkg/ovn/gateway_cleanup.go b/go-controller/pkg/ovn/gateway_cleanup.go index cfd91896e70..9133c6153e5 100644 --- a/go-controller/pkg/ovn/gateway_cleanup.go +++ b/go-controller/pkg/ovn/gateway_cleanup.go @@ -6,8 +6,9 @@ import ( "strconv" "strings" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + ovnlb "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/loadbalancer" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/sbdb" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" diff --git a/go-controller/pkg/ovn/gateway_init.go b/go-controller/pkg/ovn/gateway_init.go index a656719b436..9809542fe0e 100644 --- a/go-controller/pkg/ovn/gateway_init.go +++ b/go-controller/pkg/ovn/gateway_init.go @@ -8,8 +8,9 @@ import ( "strings" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util" diff --git a/go-controller/pkg/ovn/gateway_test.go b/go-controller/pkg/ovn/gateway_test.go index 867425544f3..bd0928b6268 100644 --- a/go-controller/pkg/ovn/gateway_test.go +++ b/go-controller/pkg/ovn/gateway_test.go @@ -10,8 +10,9 @@ import ( "github.com/onsi/gomega" "github.com/onsi/gomega/format" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + ovnlb "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/loadbalancer" ovntest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing/libovsdb" diff --git a/go-controller/pkg/ovn/gress_policy.go b/go-controller/pkg/ovn/gress_policy.go index 295a31e717b..dfb45eee188 100644 --- a/go-controller/pkg/ovn/gress_policy.go +++ b/go-controller/pkg/ovn/gress_policy.go @@ -8,10 +8,11 @@ import ( "github.com/ovn-org/libovsdb/client" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" addressset "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/address_set" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/gateway" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util" diff --git a/go-controller/pkg/ovn/loadbalancer/lb_cache.go b/go-controller/pkg/ovn/loadbalancer/lb_cache.go index 3e0caadd636..a5487ecc723 100644 --- a/go-controller/pkg/ovn/loadbalancer/lb_cache.go +++ b/go-controller/pkg/ovn/loadbalancer/lb_cache.go @@ -6,7 +6,8 @@ import ( "sync" libovsdbclient "github.com/ovn-org/libovsdb/client" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" + "k8s.io/apimachinery/pkg/util/sets" ) diff --git a/go-controller/pkg/ovn/loadbalancer/loadbalancer.go b/go-controller/pkg/ovn/loadbalancer/loadbalancer.go index 1063833e04c..0f8afb1c819 100644 --- a/go-controller/pkg/ovn/loadbalancer/loadbalancer.go +++ b/go-controller/pkg/ovn/loadbalancer/loadbalancer.go @@ -9,8 +9,8 @@ import ( libovsdbclient "github.com/ovn-org/libovsdb/client" libovsdb "github.com/ovn-org/libovsdb/ovsdb" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" "k8s.io/klog/v2" ) diff --git a/go-controller/pkg/ovn/master.go b/go-controller/pkg/ovn/master.go index d9a00d6123c..70aea49f1b9 100644 --- a/go-controller/pkg/ovn/master.go +++ b/go-controller/pkg/ovn/master.go @@ -25,9 +25,10 @@ import ( hocontroller "github.com/ovn-org/ovn-kubernetes/go-controller/hybrid-overlay/pkg/controller" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/informer" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/metrics" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + ovnlb "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/loadbalancer" lsm "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/logical_switch_manager" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" diff --git a/go-controller/pkg/ovn/ovn.go b/go-controller/pkg/ovn/ovn.go index a663dd561fc..7069c7c6997 100644 --- a/go-controller/pkg/ovn/ovn.go +++ b/go-controller/pkg/ovn/ovn.go @@ -21,12 +21,13 @@ import ( egressipv1 "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/crd/egressip/v1" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/factory" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/kube" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/metrics" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" addressset "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/address_set" svccontroller "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/controller/services" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/controller/unidling" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + lsm "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/logical_switch_manager" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/subnetallocator" ovntypes "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" diff --git a/go-controller/pkg/ovn/pods.go b/go-controller/pkg/ovn/pods.go index 56d33ee697d..20479e1881e 100644 --- a/go-controller/pkg/ovn/pods.go +++ b/go-controller/pkg/ovn/pods.go @@ -3,10 +3,11 @@ package ovn import ( "context" "fmt" - ovntypes "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" "net" "time" + ovntypes "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/metrics" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/ipallocator" @@ -20,8 +21,8 @@ import ( libovsdbclient "github.com/ovn-org/libovsdb/client" "github.com/ovn-org/libovsdb/model" "github.com/ovn-org/libovsdb/ovsdb" + libovsdbops "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - libovsdbops "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" ) func (oc *Controller) syncPods(pods []interface{}) { diff --git a/go-controller/pkg/ovn/pods_test.go b/go-controller/pkg/ovn/pods_test.go index b123f803637..f447c748094 100644 --- a/go-controller/pkg/ovn/pods_test.go +++ b/go-controller/pkg/ovn/pods_test.go @@ -21,8 +21,9 @@ import ( "github.com/onsi/ginkgo" "github.com/onsi/gomega" + libovsdbops "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - libovsdbops "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + libovsdbtest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing/libovsdb" ) diff --git a/go-controller/pkg/ovn/policy.go b/go-controller/pkg/ovn/policy.go index 94bcdc856f4..f78fdf52234 100644 --- a/go-controller/pkg/ovn/policy.go +++ b/go-controller/pkg/ovn/policy.go @@ -12,8 +12,9 @@ import ( ovsdb "github.com/ovn-org/libovsdb/ovsdb" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/factory" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/util" kapi "k8s.io/api/core/v1" diff --git a/go-controller/pkg/ovn/policy_test.go b/go-controller/pkg/ovn/policy_test.go index e0f55645aec..7dbdcc3186d 100644 --- a/go-controller/pkg/ovn/policy_test.go +++ b/go-controller/pkg/ovn/policy_test.go @@ -14,9 +14,10 @@ import ( libovsdbclient "github.com/ovn-org/libovsdb/client" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" addressset "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/address_set" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + ovntest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing/libovsdb" libovsdbtest "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/testing/libovsdb" diff --git a/go-controller/pkg/util/ovn.go b/go-controller/pkg/util/ovn.go index 7bdcdcfd844..8294371bbc2 100644 --- a/go-controller/pkg/util/ovn.go +++ b/go-controller/pkg/util/ovn.go @@ -11,7 +11,8 @@ import ( libovsdbclient "github.com/ovn-org/libovsdb/client" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/sbdb" ) diff --git a/go-controller/pkg/util/util.go b/go-controller/pkg/util/util.go index 3c76b2fa074..b624f3bc878 100644 --- a/go-controller/pkg/util/util.go +++ b/go-controller/pkg/util/util.go @@ -12,8 +12,9 @@ import ( libovsdbclient "github.com/ovn-org/libovsdb/client" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/config" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops" "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/nbdb" - "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/ovn/libovsdbops" + "github.com/ovn-org/ovn-kubernetes/go-controller/pkg/types" "github.com/urfave/cli/v2"