Skip to content

Commit

Permalink
Support discovery of OVN-IC in OCP deployments
Browse files Browse the repository at this point in the history
Signed-off-by: Aswin Suryanarayanan <[email protected]>
  • Loading branch information
aswinsuryan committed Aug 22, 2023
1 parent 0e503a2 commit c39b2ca
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
14 changes: 12 additions & 2 deletions controllers/submariner/route_agent_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package submariner
import (
"context"
"strconv"
"strings"

"github.com/go-logr/logr"
"github.com/submariner-io/admiral/pkg/names"
Expand Down Expand Up @@ -49,6 +50,15 @@ func newRouteAgentDaemonSet(cr *v1alpha1.Submariner, clusterNetwork *network.Clu
"app": name,
"component": "routeagent",
}
ovnNBDBPath := network.DefaultOvnNBDB

configurePath, ok := clusterNetwork.PluginSettings[network.OvnNBDB]
if ok {
parts := strings.Split(configurePath, ":")
if len(parts) == 2 && parts[0] == "unix" {
ovnNBDBPath = parts[1]
}
}

maxUnavailable := intstr.FromString("100%")

Expand Down Expand Up @@ -87,7 +97,7 @@ func newRouteAgentDaemonSet(cr *v1alpha1.Submariner, clusterNetwork *network.Clu
Path: "/sys",
}}},
{Name: "host-var-run-openvswitch-nbdb-sock", VolumeSource: corev1.VolumeSource{HostPath: &corev1.HostPathVolumeSource{
Path: "/var/run/openvswitch/ovnnb_db.sock",
Path: ovnNBDBPath,
}}},
},
Containers: []corev1.Container{
Expand All @@ -108,7 +118,7 @@ func newRouteAgentDaemonSet(cr *v1alpha1.Submariner, clusterNetwork *network.Clu
{Name: "host-sys", MountPath: "/sys", ReadOnly: true},
{Name: "host-run-xtables-lock", MountPath: "/run/xtables.lock"},
{Name: "host-run-openvswitch-db-sock", MountPath: "/run/openvswitch/db.sock"},
{Name: "host-var-run-openvswitch-nbdb-sock", MountPath: "/var/run/openvswitch/ovnnb_db.sock"},
{Name: "host-var-run-openvswitch-nbdb-sock", MountPath: ovnNBDBPath},
},
Env: []corev1.EnvVar{
{Name: "SUBMARINER_NAMESPACE", Value: cr.Spec.Namespace},
Expand Down
22 changes: 21 additions & 1 deletion pkg/discovery/network/openshift4.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,27 @@ func discoverOpenShift4Network(ctx context.Context, client controllerClient.Clie
return nil, errors.WithMessage(err, "error obtaining the default 'cluster' OpenShift4 Network config resource")
}

return parseOS4Network(network)
clusterNetwork, err := parseOS4Network(network)
if err != nil {
return nil, err
}

if clusterNetwork.NetworkPlugin == cni.OVNKubernetes {
ovnDBPod, err := FindPod(ctx, client, "name=ovnkube-db")
if err != nil {
return nil, err
}

if ovnDBPod == nil {
// IC is enabled and Openshift uses zone per node and to connect to OVN DB using
// socket connection we need to use this path.
clusterNetwork.PluginSettings = map[string]string{
OvnNBDB: "unix:/var/run/ovn-ic/ovnnb_db.sock",
}
}
}

return clusterNetwork, err
}

func parseOS4Network(cr *unstructured.Unstructured) (*ClusterNetwork, error) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/discovery/network/ovnkubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ const (
ovnKubeService = "ovnkube-db"
OvnNBDB = "OVN_NBDB"
OvnSBDB = "OVN_SBDB"
DefaultOvnNBDB = "/var/run/openvswitch/ovnnb_db.sock"
OvnNBDBDefaultPort = 6641
OvnSBDBDefaultPort = 6642
)
Expand Down Expand Up @@ -109,7 +110,7 @@ func discoverOvnNodeClusterNetwork(ctx context.Context, client controllerClient.
func createLocalClusterNetwork() *ClusterNetwork {
return &ClusterNetwork{
PluginSettings: map[string]string{
OvnNBDB: "unix:/var/run/openvswitch/ovnnb_db.sock",
OvnNBDB: "unix:" + DefaultOvnNBDB,
},
}
}
Expand Down

0 comments on commit c39b2ca

Please sign in to comment.