Skip to content

Commit

Permalink
Merge branch 'devel' into globalip_pod_not_ready
Browse files Browse the repository at this point in the history
  • Loading branch information
tpantelis authored Aug 20, 2023
2 parents 4ea6c19 + 826316e commit b7f6961
Show file tree
Hide file tree
Showing 15 changed files with 799 additions and 233 deletions.
15 changes: 10 additions & 5 deletions pkg/cable/libreswan/libreswan.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
const (
cableDriverName = "libreswan"
whackTimeout = 5 * time.Second
dpdDelay = 30 // seconds
)

var logger = log.Logger{Logger: logf.Log.WithName("libreswan")}
Expand Down Expand Up @@ -172,7 +173,7 @@ func retrieveActiveConnectionStats() (map[string]int, map[string]int, error) {
defer cancel()

// Retrieve active tunnels from the daemon
cmd := exec.CommandContext(ctx, "/usr/libexec/ipsec/whack", "--trafficstatus")
cmd := exec.CommandContext(ctx, "/usr/sbin/ipsec", "whack", "--trafficstatus")

stdout, err := cmd.StdoutPipe()
if err != nil {
Expand Down Expand Up @@ -311,7 +312,8 @@ func whack(args ...string) error {
ctx, cancel := context.WithTimeout(context.TODO(), whackTimeout)
defer cancel()

cmd := exec.CommandContext(ctx, "/usr/libexec/ipsec/whack", args...)
fullArgs := append([]string{"whack"}, args...)
cmd := exec.CommandContext(ctx, "/usr/sbin/ipsec", fullArgs...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

Expand Down Expand Up @@ -427,7 +429,8 @@ func (i *libreswan) bidirectionalConnectToEndpoint(connectionName string, endpoi
"--client", rightSubnet,

"--ikeport", strconv.Itoa(int(rightNATTPort)),
"--dpdaction=hold")
"--dpdaction=hold",
"--dpddelay", strconv.Itoa(dpdDelay))

logger.Infof("Executing whack with args: %v", args)

Expand Down Expand Up @@ -470,7 +473,8 @@ func (i *libreswan) serverConnectToEndpoint(connectionName string, endpointInfo
"--id", remoteEndpointIdentifier,
"--host", "%any",
"--client", rightSubnet,
"--dpdaction=hold")
"--dpdaction=hold",
"--dpddelay", strconv.Itoa(dpdDelay))

logger.Infof("Executing whack with args: %v", args)

Expand Down Expand Up @@ -512,7 +516,8 @@ func (i *libreswan) clientConnectToEndpoint(connectionName string, endpointInfo
"--client", rightSubnet,

"--ikeport", strconv.Itoa(int(rightNATTPort)),
"--dpdaction=hold")
"--dpdaction=hold",
"--dpddelay", strconv.Itoa(dpdDelay))

logger.Infof("Executing whack with args: %v", args)

Expand Down
101 changes: 2 additions & 99 deletions pkg/networkplugin-syncer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,113 +19,16 @@ limitations under the License.
package main

import (
"flag"
"os"

"github.com/kelseyhightower/envconfig"
"github.com/submariner-io/admiral/pkg/log"
"github.com/submariner-io/admiral/pkg/log/kzerolog"
"github.com/submariner-io/admiral/pkg/names"
admversion "github.com/submariner-io/admiral/pkg/version"
"github.com/submariner-io/submariner/pkg/cni"
"github.com/submariner-io/submariner/pkg/event"
"github.com/submariner-io/submariner/pkg/event/controller"
eventlogger "github.com/submariner-io/submariner/pkg/event/logger"
"github.com/submariner-io/submariner/pkg/networkplugin-syncer/handlers/ovn"
"github.com/submariner-io/submariner/pkg/routeagent_driver/environment"
"github.com/submariner-io/submariner/pkg/versions"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
)

var (
masterURL string
kubeconfig string
logger = log.Logger{Logger: logf.Log.WithName("main")}
showVersion = false
)
var logger = log.Logger{Logger: logf.Log.WithName("main")}

func main() {
kzerolog.AddFlags(nil)
flag.Parse()

admversion.Print(names.NetworkPluginSyncerComponent, versions.Submariner())

if showVersion {
return
}

kzerolog.InitK8sLogging()

versions.Log(&logger)
logger.Info("Network Plugin Syncer is deprecated and will be removed in future")

logger.Info("Starting submariner-networkplugin-syncer")
// set up signals so we handle the first shutdown signal gracefully
stopCh := signals.SetupSignalHandler().Done()

var env environment.Specification

err := envconfig.Process("submariner", &env)
logger.FatalOnError(err, "Error processing env config")

networkPlugin := os.Getenv("SUBMARINER_NETWORKPLUGIN")

if networkPlugin == "" {
networkPlugin = cni.Generic
}

registry := event.NewRegistry("networkplugin-syncer", networkPlugin)
err = registry.AddHandlers(eventlogger.NewHandler(), ovn.NewSyncHandler(getK8sClient(), &env))
logger.FatalOnError(err, "Error registering the handlers")

if env.Uninstall {
if err := registry.StopHandlers(true); err != nil {
logger.Warningf("Error stopping handlers: %v", err)
}

return
}

ctl, err := controller.New(&controller.Config{
Registry: registry,
MasterURL: masterURL,
Kubeconfig: kubeconfig,
})
logger.FatalOnError(err, "Error creating controller for event handling")

err = ctl.Start(stopCh)
logger.FatalOnError(err, "Error starting controller")

<-stopCh
ctl.Stop()

logger.Info("All controllers stopped or exited. Stopping submariner-networkplugin-syncer")
}

func getK8sClient() kubernetes.Interface {
var cfg *rest.Config
var err error

if masterURL == "" && kubeconfig == "" {
cfg, err = rest.InClusterConfig()
logger.FatalOnError(err, "Error getting in-cluster-config, please set kubeconfig and master parameters")
} else {
cfg, err = clientcmd.BuildConfigFromFlags(masterURL, kubeconfig)
logger.FatalOnError(err, "Error building kubeconfig")
}

clientSet, err := kubernetes.NewForConfig(cfg)
logger.FatalOnError(err, "Error building clientset")

return clientSet
}

func init() {
flag.StringVar(&kubeconfig, "kubeconfig", "", "Path to a kubeconfig. Only required if out-of-cluster.")
flag.StringVar(&masterURL, "master", "",
"The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.")
flag.BoolVar(&showVersion, "version", showVersion, "Show version")
}
1 change: 1 addition & 0 deletions pkg/routeagent_driver/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ const (
FilterTable = "filter"

OvnTransitSwitchIPAnnotation = "k8s.ovn.org/node-transit-switch-port-ifaddr"
OvnZoneAnnotation = "k8s.ovn.org/zone-name"
)
89 changes: 0 additions & 89 deletions pkg/routeagent_driver/handlers/ovn/bridge.go

This file was deleted.

Loading

0 comments on commit b7f6961

Please sign in to comment.