Skip to content

Commit

Permalink
Move core-infra functionality and use libovsdb
Browse files Browse the repository at this point in the history
Rename the files which contain the core submariner/ovn
functionality bits. Convert all the ovsdb clients from
go-ovn to ovsdb.

Re-organize some submariner files to align more
closely with OVN Semantics.  Convert all calls
reguarding OVN logical_router_static_routes to
use libovsdb rather than go-ovn.

Convert all logical_router_policy calls
to libovsdb.

convert all OVN sbdb chassis
related calls to use libovsdb.

Update how clusterSet service avaliability works
in the networkplugin-syncer code. Speciafically it ensures we add
the a new OVN object (OVN cluster loadbalancer_group) to the submariner
router. This group has all the VIPs for the cluster in question.

Update vendoring since ovn-k requires k8s 1.23

Signed-off-by: Andrew Stoycos <astoycos@redhat.com>
  • Loading branch information
astoycos committed Jun 3, 2022
1 parent 70fba05 commit 5a47c29
Show file tree
Hide file tree
Showing 16 changed files with 791 additions and 821 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ ifneq (,$(DAPPER_HOST_ARCH))
IMAGES ?= submariner-gateway submariner-route-agent submariner-globalnet submariner-networkplugin-syncer
PRELOAD_IMAGES = $(IMAGES) submariner-operator

ifneq (,$(filter ovn,$(_using)))
ifneq (,$(filter ovn,$(USING)))
SETTINGS ?= $(DAPPER_SOURCE)/.shipyard.e2e.ovn.yml
else
SETTINGS ?= $(DAPPER_SOURCE)/.shipyard.e2e.yml
Expand Down
45 changes: 18 additions & 27 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ go 1.17
require (
github.com/cenkalti/backoff/v4 v4.1.1
github.com/coreos/go-iptables v0.6.0
github.com/ebay/go-ovn v0.1.1-0.20210414223409-7376ba97f8cd
github.com/emirpasic/gods v1.18.1
github.com/go-ping/ping v0.0.0-20210506233800-ff8be3320020
github.com/kelseyhightower/envconfig v1.4.0
github.com/onsi/ginkgo v1.16.5
github.com/onsi/gomega v1.19.0
github.com/ovn-org/libovsdb v0.6.1-0.20220127023511-a619f0fd93be
github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20220203162605-b7bde92275c5
github.com/ovn-org/libovsdb v0.6.1-0.20220427123326-d7b273399db4
github.com/ovn-org/ovn-kubernetes/go-controller v0.0.0-20220511131059-ac1ce4691c0f
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.12.2
github.com/submariner-io/admiral v0.13.0-m2
Expand All @@ -22,30 +21,29 @@ require (
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9
golang.zx2c4.com/wireguard/wgctrl v0.0.0-20211215182854-7a385b3431de
google.golang.org/protobuf v1.27.1
k8s.io/api v0.22.1
k8s.io/apimachinery v0.22.1
k8s.io/client-go v1.5.2
k8s.io/api v0.23.5
k8s.io/apimachinery v0.23.5
k8s.io/client-go v0.23.5
k8s.io/klog v1.0.0
k8s.io/klog/v2 v2.20.0
k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9
sigs.k8s.io/controller-runtime v0.7.0
k8s.io/klog/v2 v2.30.0
k8s.io/utils v0.0.0-20211116205334-6203023598ed
sigs.k8s.io/controller-runtime v0.11.2
sigs.k8s.io/mcs-api v0.1.0
)

require (
cloud.google.com/go v0.65.0 // indirect
cloud.google.com/go v0.81.0 // indirect
github.com/BurntSushi/toml v0.4.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cenkalti/hub v1.0.1 // indirect
github.com/cenkalti/rpc2 v0.0.0-20210604223624-c1acbc6ec984 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/ebay/libovsdb v0.0.0-20190718202342-e49b8c4e1142 // indirect
github.com/evanphx/json-patch v4.11.0+incompatible // indirect
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/go-logr/logr v1.1.0 // indirect
github.com/go-logr/stdr v1.1.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-logr/logr v1.2.2 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
Expand Down Expand Up @@ -85,7 +83,7 @@ require (
golang.org/x/crypto v0.0.0-20211215165025-cf75a172585e // indirect
golang.org/x/mod v0.5.1 // indirect
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
golang.org/x/text v0.3.7 // indirect
Expand All @@ -99,15 +97,8 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
honnef.co/go/tools v0.2.2 // indirect
k8s.io/kube-openapi v0.0.0-20210421082810-95288971da7e // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

// Pinned to kubernetes-1.19.10
replace (
k8s.io/api => k8s.io/api v0.19.10
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.19.10
k8s.io/client-go => k8s.io/client-go v0.19.10
k8s.io/cloud-provider => k8s.io/cloud-provider v0.19.10
k8s.io/kube-openapi v0.0.0-20211115234752-e816edb12b65 // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
)
369 changes: 308 additions & 61 deletions go.sum

Large diffs are not rendered by default.

38 changes: 34 additions & 4 deletions pkg/networkplugin-syncer/handlers/ovn/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ import (
"sync"

libovsdbclient "github.com/ovn-org/libovsdb/client"
"github.com/submariner-io/admiral/pkg/log"
submV1 "github.com/submariner-io/submariner/pkg/apis/submariner.io/v1"
"github.com/submariner-io/submariner/pkg/cidr"
"github.com/submariner-io/submariner/pkg/event"
"github.com/submariner-io/submariner/pkg/networkplugin-syncer/handlers/ovn/nbctl"
"github.com/submariner-io/submariner/pkg/routeagent_driver/constants"
"github.com/submariner-io/submariner/pkg/routeagent_driver/environment"
clientset "k8s.io/client-go/kubernetes"
Expand All @@ -38,10 +38,8 @@ var ErrWaitingForLocalEndpoint = errors.New("waiting for the local endpoint deta

type SyncHandler struct {
event.HandlerBase
stopChan chan struct{}
syncMutex sync.Mutex
k8sClientset clientset.Interface
nbctl *nbctl.NbCtl
nbdb libovsdbclient.Client
sbdb libovsdbclient.Client
localClusterCIDR []string
Expand Down Expand Up @@ -153,7 +151,7 @@ func (ovn *SyncHandler) updateRemoteEndpointsInfra() error {
}

// Synchronize the policy rules inserted by submariner in the ovn_cluster_router, those point to submariner_router
err := ovn.setupOvnClusterRouterRemoteRules()
err := ovn.setupOvnClusterRouterLRPs()
if err != nil {
return err
}
Expand All @@ -167,3 +165,35 @@ func (ovn *SyncHandler) updateRemoteEndpointsInfra() error {

return nil
}

func (ovn *SyncHandler) updateGatewayNode() error {
if ovn.localEndpoint == nil {
klog.Warningf("No local endpoint, cannot update local endpoint information in OVN NBDB")
return nil
}

gwHostname := ovn.localEndpoint.Spec.Hostname

chassis, err := ovn.findChassisByHostname(gwHostname)
if errors.Is(err, libovsdbclient.ErrNotFound) {
klog.Fatalf("The OVN chassis for hostname %q could not be found", gwHostname)
} else if err != nil {
// Hopefully this error can be retried
return err
}

klog.V(log.DEBUG).Infof("Chassis for gw %q is %q, host: %q", gwHostname, chassis.Name, chassis.Hostname)

// Create/update the submariner external port associated to one of the external switches.
if err := ovn.createOrUpdateSubmarinerExternalPort(); err != nil {
return err
}

// Associate the port to an specific chassis (=host) on OVN so the traffic flows out/in through that host
// the active submariner-gateway in our case.
if err := ovn.associateSubmarinerRouterToChassis(chassis); err != nil {
return err
}

return ovn.updateSubmarinerRouterLocalRoutes()
}
167 changes: 0 additions & 167 deletions pkg/networkplugin-syncer/handlers/ovn/infrastructure.go

This file was deleted.

51 changes: 51 additions & 0 deletions pkg/networkplugin-syncer/handlers/ovn/ovn_chassis.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
SPDX-License-Identifier: Apache-2.0
Copyright Contributors to the Submariner project.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package ovn

import (
"strings"

libovsdbclient "github.com/ovn-org/libovsdb/client"
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/libovsdbops"
"github.com/ovn-org/ovn-kubernetes/go-controller/pkg/sbdb"
"github.com/pkg/errors"
)

func (ovn *SyncHandler) findChassisByHostname(hostname string) (*sbdb.Chassis, error) {
chassisList, err := libovsdbops.ListChassis(ovn.sbdb)
if err != nil {
return nil, errors.Wrap(err, "unable to get chassis list from OVN")
}
// Attempt matching by the exact hostname.
for i := range chassisList {
if chassisList[i].Hostname == hostname {
return chassisList[i], nil
}
}

// In a second round try to match expecting a higher level domain after the hostname.
for i := range chassisList {
if strings.HasPrefix(chassisList[i].Hostname, hostname+".") ||
strings.HasPrefix(hostname, chassisList[i].Hostname+".") {
return chassisList[i], nil
}
}

return nil, libovsdbclient.ErrNotFound
}
Loading

0 comments on commit 5a47c29

Please sign in to comment.