-
Notifications
You must be signed in to change notification settings - Fork 29
✨ Extend interface with runner #62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,4 +60,9 @@ type Provider interface { | |
// IndexField indexes the given object by the given field on all engaged | ||
// clusters, current and future. | ||
IndexField(ctx context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error | ||
|
||
// Start runs the provider. Implementation of this method should block. | ||
// If you need to pass in manager, it is recommended to implement SetupWithManager(mgr mcmanager.Manager) error method on individual providers. | ||
// Even if a provider gets a manager through e.g. `SetupWithManager` the `Aware` passed to this method must be used to engage clusters. | ||
Start(context.Context, Aware) error | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we're mixing two concepts here.
The start part is ONLY related to runnables. The aware part is a parameter that the provider should hold, provided during setup?. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So what do you suggest here? I dont see mixing here, but I been soaking in this for way too long :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a mixing either. It only takes an I'd instead argue that this will encourage cleaner design because provider developers will rather ask for a kubeconfig in their setup (either as parameters to their |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,7 +39,6 @@ import ( | |
"sigs.k8s.io/controller-runtime/pkg/manager" | ||
"sigs.k8s.io/controller-runtime/pkg/reconcile" | ||
|
||
mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager" | ||
"sigs.k8s.io/multicluster-runtime/pkg/multicluster" | ||
) | ||
|
||
|
@@ -109,7 +108,7 @@ type Provider struct { | |
client client.Client | ||
|
||
lock sync.Mutex | ||
mcMgr mcmanager.Manager | ||
mcAware multicluster.Aware | ||
clusters map[string]cluster.Cluster | ||
cancelFns map[string]context.CancelFunc | ||
indexers []index | ||
|
@@ -126,13 +125,14 @@ func (p *Provider) Get(_ context.Context, clusterName string) (cluster.Cluster, | |
return nil, multicluster.ErrClusterNotFound | ||
} | ||
|
||
// Run starts the provider and blocks. | ||
func (p *Provider) Run(ctx context.Context, mgr mcmanager.Manager) error { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we mark it deprecated instead? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need to? Its not like we deprecating a functionality and giving people to find different way of doing things. |
||
p.log.Info("Starting Cluster-API cluster provider") | ||
|
||
// Start starts the provider and blocks. | ||
func (p *Provider) Start(ctx context.Context, mcAware multicluster.Aware) error { | ||
p.lock.Lock() | ||
p.mcMgr = mgr | ||
p.lock.Unlock() | ||
defer p.lock.Unlock() | ||
|
||
p.mcAware = mcAware | ||
|
||
p.log.Info("Starting Cluster-API cluster provider") | ||
|
||
<-ctx.Done() | ||
|
||
|
@@ -171,7 +171,7 @@ func (p *Provider) Reconcile(ctx context.Context, req reconcile.Request) (reconc | |
// TODO(sttts): do tighter logging. | ||
|
||
// provider already started? | ||
if p.mcMgr == nil { | ||
if p.mcAware == nil { | ||
return reconcile.Result{RequeueAfter: time.Second * 2}, nil | ||
} | ||
|
||
|
@@ -222,7 +222,7 @@ func (p *Provider) Reconcile(ctx context.Context, req reconcile.Request) (reconc | |
p.log.Info("Added new cluster") | ||
|
||
// engage manager. | ||
if err := p.mcMgr.Engage(clusterCtx, key, cl); err != nil { | ||
if err := p.mcAware.Engage(clusterCtx, key, cl); err != nil { | ||
log.Error(err, "failed to engage manager") | ||
delete(p.clusters, key) | ||
delete(p.cancelFns, key) | ||
|
Uh oh!
There was an error while loading. Please reload this page.