mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-08-23 22:26:49 +00:00
only init cluster and csr client in bootstrap phase (#1229)
Signed-off-by: Wei Liu <liuweixa@redhat.com> Co-authored-by: Wei Liu <liuweixa@redhat.com>
This commit is contained in:
co-authored by
Wei Liu
parent
d8cd1adca1
commit
ac48573cf4
@@ -86,6 +86,32 @@ func (d *GRPCDriver) BuildClients(ctx context.Context, secretOption register.Sec
|
||||
clusterClient, 10*time.Minute).Cluster().V1().ManagedClusters()
|
||||
clusterWatchStore.SetInformer(clusterInformers.Informer())
|
||||
|
||||
csrClientHolder, err := cloudeventscsr.NewAgentClientHolder(ctx,
|
||||
cloudeventsoptions.NewGenericClientOptions(
|
||||
config,
|
||||
cloudeventscsr.NewCSRCodec(),
|
||||
secretOption.ClusterName,
|
||||
).WithClusterName(secretOption.ClusterName),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
csrControl := &ceCSRControl{csrClientHolder: csrClientHolder}
|
||||
if err := d.csrDriver.SetCSRControl(csrControl, secretOption.ClusterName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
d.control = csrControl
|
||||
|
||||
// Initialize the cluster client and CSR control in the bootstrap phase.
|
||||
// Other clients should not be initialized, since they require
|
||||
// permissions that are not allowed in the bootstrap phase.
|
||||
if bootstrapped {
|
||||
return ®ister.Clients{
|
||||
ClusterClient: clusterClient,
|
||||
ClusterInformer: clusterInformers,
|
||||
}, nil
|
||||
}
|
||||
|
||||
leaseWatchStore := cloudeventsstore.NewSimpleStore[*coordv1.Lease]()
|
||||
leaseClient, err := cloudeventslease.NewLeaseClient(
|
||||
ctx,
|
||||
@@ -128,22 +154,6 @@ func (d *GRPCDriver) BuildClients(ctx context.Context, secretOption register.Sec
|
||||
Addon().V1alpha1().ManagedClusterAddOns()
|
||||
addonWatchStore.SetInformer(addonInformer.Informer())
|
||||
|
||||
csrClientHolder, err := cloudeventscsr.NewAgentClientHolder(ctx,
|
||||
cloudeventsoptions.NewGenericClientOptions(
|
||||
config,
|
||||
cloudeventscsr.NewCSRCodec(),
|
||||
secretOption.ClusterName,
|
||||
).WithClusterName(secretOption.ClusterName),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
csrControl := &ceCSRControl{csrClientHolder: csrClientHolder}
|
||||
if err := d.csrDriver.SetCSRControl(csrControl, secretOption.ClusterName); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
d.control = csrControl
|
||||
|
||||
clients := ®ister.Clients{
|
||||
ClusterClient: clusterClient,
|
||||
ClusterInformer: clusterInformers,
|
||||
|
||||
Reference in New Issue
Block a user