Skip to content

Commit 8c8b82a

Browse files
committed
Make manager to start the provider
1 parent 49ae642 commit 8c8b82a

File tree

6 files changed

+11
-14
lines changed

6 files changed

+11
-14
lines changed

examples/cluster-api/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,6 @@ func main() {
128128
g.Go(func() error {
129129
return ignoreCanceled(localMgr.Start(ctx))
130130
})
131-
g.Go(func() error {
132-
return ignoreCanceled(provider.Start(ctx, mcMgr))
133-
})
134131
g.Go(func() error {
135132
return ignoreCanceled(mcMgr.Start(ctx))
136133
})

examples/file/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,6 @@ func main() {
113113
g.Go(func() error {
114114
return ignoreCanceled(mgr.Start(ctx))
115115
})
116-
g.Go(func() error {
117-
return ignoreCanceled(provider.Start(ctx, mgr))
118-
})
119116
if err := g.Wait(); err != nil {
120117
entryLog.Info("error in errgroup: %w", err)
121118
return

examples/kind/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ func main() {
9191

9292
// Starting everything.
9393
g, ctx := errgroup.WithContext(ctx)
94-
g.Go(func() error {
95-
return ignoreCanceled(provider.Start(ctx, mgr))
96-
})
9794
g.Go(func() error {
9895
return ignoreCanceled(mgr.Start(ctx))
9996
})

examples/namespace/main.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,6 @@ func run(ctx context.Context, log logr.Logger, kubeconfig string) error {
153153

154154
// Starting everything.
155155
g, ctx := errgroup.WithContext(ctx)
156-
g.Go(func() error {
157-
return ignoreCanceled(provider.Start(ctx, mgr))
158-
})
159156
g.Go(func() error {
160157
return ignoreCanceled(cl.Start(ctx))
161158
})

pkg/manager/manager.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,16 @@ func (p *scopedManager) Add(r manager.Runnable) error {
254254

255255
// Start starts the manager.
256256
func (p *scopedManager) Start(ctx context.Context) error {
257+
err := p.Add(manager.RunnableFunc(func(ctx context.Context) error {
258+
provider := p.Manager.GetProvider()
259+
if provider != nil {
260+
return provider.Start(ctx, p)
261+
}
262+
return nil
263+
}))
264+
if err != nil {
265+
return err
266+
}
257267
return p.Manager.GetLocalManager().Start(ctx)
258268
}
259269

providers/cluster-api/provider.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,8 @@ func (p *Provider) Get(_ context.Context, clusterName string) (cluster.Cluster,
128128
// Start starts the provider and blocks.
129129
func (p *Provider) Start(ctx context.Context, aware multicluster.Aware) error {
130130
p.lock.Lock()
131-
defer p.lock.Unlock()
132-
133131
p.aware = aware
132+
p.lock.Unlock()
134133

135134
p.log.Info("Starting Cluster-API cluster provider")
136135

0 commit comments

Comments
 (0)