From 876b391843a7454a41005e8fce33308483c35726 Mon Sep 17 00:00:00 2001 From: Tom Pantelis Date: Wed, 20 Nov 2024 10:29:18 -0500 Subject: [PATCH] Use WaitForLocalNodeReady in gateway main Signed-off-by: Tom Pantelis --- main.go | 11 ++++++++++- pkg/node/node_test.go | 2 +- pkg/routeagent_driver/main.go | 2 -- pkg/types/types.go | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 57aa86fca..dd6c544eb 100644 --- a/main.go +++ b/main.go @@ -36,6 +36,7 @@ import ( submarinerClientset "github.com/submariner-io/submariner/pkg/client/clientset/versioned" "github.com/submariner-io/submariner/pkg/gateway" "github.com/submariner-io/submariner/pkg/natdiscovery" + "github.com/submariner-io/submariner/pkg/node" "github.com/submariner-io/submariner/pkg/types" "github.com/submariner-io/submariner/pkg/versions" "golang.org/x/net/http/httpproxy" @@ -123,6 +124,14 @@ func main() { logger.FatalOnError(subv1.AddToScheme(scheme.Scheme), "Error adding submariner types to the scheme") + ctx := signals.SetupSignalHandler() + + if submSpec.WaitForNode { + node.WaitForLocalNodeReady(ctx, k8sClient) + + return + } + gw, err := gateway.New(&gateway.Config{ LeaderElectionConfig: gateway.LeaderElectionConfig{ LeaseDuration: time.Duration(gwLeadershipConfig.LeaseDuration) * time.Second, @@ -146,7 +155,7 @@ func main() { }) logger.FatalOnError(err, "Error creating gateway instance") - err = gw.Run(signals.SetupSignalHandler()) + err = gw.Run(ctx) logger.FatalOnError(err, "Error running the gateway") } diff --git a/pkg/node/node_test.go b/pkg/node/node_test.go index 6c15464ae..c6b9f43cd 100644 --- a/pkg/node/node_test.go +++ b/pkg/node/node_test.go @@ -150,7 +150,7 @@ func newTestDriver() *testDriver { }) JustBeforeEach(func() { - t.client = fakeK8s.NewClientset(t.initialObjs...) + t.client = fakeK8s.NewSimpleClientset(t.initialObjs...) }) return t diff --git a/pkg/routeagent_driver/main.go b/pkg/routeagent_driver/main.go index 08300099e..048d06e31 100644 --- a/pkg/routeagent_driver/main.go +++ b/pkg/routeagent_driver/main.go @@ -23,7 +23,6 @@ import ( "io/fs" "os" "strconv" - "time" "github.com/kelseyhightower/envconfig" "github.com/pkg/errors" @@ -49,7 +48,6 @@ import ( "github.com/submariner-io/submariner/pkg/routeagent_driver/handlers/mtu" "github.com/submariner-io/submariner/pkg/routeagent_driver/handlers/ovn" "github.com/submariner-io/submariner/pkg/versions" - corev1 "k8s.io/api/core/v1" "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" diff --git a/pkg/types/types.go b/pkg/types/types.go index e376a645e..ac578fe59 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -46,6 +46,7 @@ type SubmarinerSpecification struct { HealthCheckEnabled bool `default:"true"` Uninstall bool HaltOnCertError bool `split_words:"true"` + WaitForNode bool HealthCheckInterval uint HealthCheckMaxPacketLossCount uint MetricsPort int `default:"32780"`