From 6f242e7a742cbf715d7d5bef698960986edfa113 Mon Sep 17 00:00:00 2001 From: Ricardo Weir Date: Mon, 5 Aug 2024 17:41:59 -0700 Subject: [PATCH] Connect to vCluster Platform earlier vCluster is now able to request a data source from vCluster Platform. vCluster is only able to use the data source if it attempts to connect to the vCluster Platform prior to deploying its own control plane. vCluster Platform is now connected before control plane is deployed but the platform controllers and tailscale server are started after because they require the control plane to be running. --- cmd/vcluster/cmd/start.go | 17 +++++++++++------ pkg/pro/platform.go | 4 ++-- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cmd/vcluster/cmd/start.go b/cmd/vcluster/cmd/start.go index b55b3565e8..910e244ca0 100644 --- a/cmd/vcluster/cmd/start.go +++ b/cmd/vcluster/cmd/start.go @@ -89,7 +89,12 @@ func ExecuteStart(ctx context.Context, options *StartOptions) error { // set features for plugins to recognize plugin.DefaultManager.SetProFeatures(pro.LicenseFeatures()) - // check if we should create certs + // connect to vCluster platform if configured + startPlatformServersAndControllers, err := pro.ConnectToPlatform(ctx, vConfig) + if err != nil { + return fmt.Errorf("connect to platform: %w", err) + } + err = setup.Initialize(ctx, vConfig) if err != nil { return fmt.Errorf("initialize: %w", err) @@ -101,6 +106,11 @@ func ExecuteStart(ctx context.Context, options *StartOptions) error { return fmt.Errorf("create controller context: %w", err) } + err = startPlatformServersAndControllers(controllerCtx.VirtualManager) + if err != nil { + return fmt.Errorf("start platform controllers: %w", err) + } + // start integrations err = integrations.StartIntegrations(controllerCtx) if err != nil { @@ -134,11 +144,6 @@ func ExecuteStart(ctx context.Context, options *StartOptions) error { } } - // connect to vCluster platform if configured - if err := pro.ConnectToPlatform(ctx, vConfig, controllerCtx.VirtualManager); err != nil { - return fmt.Errorf("connect to platform: %w", err) - } - // start leader election + controllers err = StartLeaderElection(controllerCtx, func() error { return setup.StartControllers(controllerCtx, syncers) diff --git a/pkg/pro/platform.go b/pkg/pro/platform.go index 11407313ab..4674f3ee52 100644 --- a/pkg/pro/platform.go +++ b/pkg/pro/platform.go @@ -7,6 +7,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" ) -var ConnectToPlatform = func(context.Context, *config.VirtualClusterConfig, manager.Manager) error { - return nil +var ConnectToPlatform = func(context.Context, *config.VirtualClusterConfig) (func(mgr manager.Manager) error, error) { + return func(_ manager.Manager) error { return nil }, nil }