@@ -29,7 +29,6 @@ import (
29
29
syncagentv1alpha1 "github.com/kcp-dev/api-syncagent/sdk/apis/syncagent/v1alpha1"
30
30
31
31
kcpapisv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1"
32
- kcpdevv1alpha1 "github.com/kcp-dev/kcp/sdk/apis/apis/v1alpha1"
33
32
apiexportprovider "github.com/kcp-dev/multicluster-provider/apiexport"
34
33
mccontroller "sigs.k8s.io/multicluster-runtime/pkg/controller"
35
34
mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager"
@@ -75,7 +74,7 @@ type Reconciler struct {
75
74
stateNamespace string
76
75
agentName string
77
76
78
- apiExport * kcpdevv1alpha1 .APIExport
77
+ apiExport * kcpapisv1alpha1 .APIExport
79
78
80
79
// URL for which the current vwCluster instance has been created
81
80
vwURL string
@@ -110,7 +109,7 @@ func Add(
110
109
kcpCluster cluster.Cluster ,
111
110
kcpRestConfig * rest.Config ,
112
111
log * zap.SugaredLogger ,
113
- apiExport * kcpdevv1alpha1 .APIExport ,
112
+ apiExport * kcpapisv1alpha1 .APIExport ,
114
113
prFilter labels.Selector ,
115
114
stateNamespace string ,
116
115
agentName string ,
@@ -144,7 +143,7 @@ func Add(
144
143
// Watch for changes to APIExport on the kcp side to start/restart the actual syncing controllers;
145
144
// the cache is already restricted by a fieldSelector in the main.go to respect the RBAC restrictions,
146
145
// so there is no need here to add an additional filter.
147
- WatchesRawSource (source .Kind (kcpCluster .GetCache (), & kcpdevv1alpha1 .APIExport {}, controllerutil.EnqueueConst [* kcpdevv1alpha1 .APIExport ]("dummy" ))).
146
+ WatchesRawSource (source .Kind (kcpCluster .GetCache (), & kcpapisv1alpha1 .APIExport {}, controllerutil.EnqueueConst [* kcpapisv1alpha1 .APIExport ]("dummy" ))).
148
147
// Watch for changes to the PublishedResources
149
148
Watches (& syncagentv1alpha1.PublishedResource {}, controllerutil.EnqueueConst [ctrlruntimeclient.Object ]("dummy" ), builder .WithPredicates (predicate .ByLabels (prFilter ))).
150
149
Build (reconciler )
@@ -158,15 +157,15 @@ func (r *Reconciler) Reconcile(ctx context.Context, _ reconcile.Request) (reconc
158
157
159
158
key := types.NamespacedName {Name : r .apiExport .Name }
160
159
161
- apiExport := & kcpdevv1alpha1 .APIExport {}
160
+ apiExport := & kcpapisv1alpha1 .APIExport {}
162
161
if err := r .kcpCluster .GetClient ().Get (ctx , key , apiExport ); ctrlruntimeclient .IgnoreNotFound (err ) != nil {
163
162
return reconcile.Result {}, fmt .Errorf ("failed to retrieve APIExport: %w" , err )
164
163
}
165
164
166
165
return reconcile.Result {}, r .reconcile (ctx , log , apiExport )
167
166
}
168
167
169
- func (r * Reconciler ) reconcile (ctx context.Context , log * zap.SugaredLogger , apiExport * kcpdevv1alpha1 .APIExport ) error {
168
+ func (r * Reconciler ) reconcile (ctx context.Context , log * zap.SugaredLogger , apiExport * kcpapisv1alpha1 .APIExport ) error {
170
169
// We're not yet making use of APIEndpointSlices, as we don't even fully
171
170
// support a sharded kcp setup yet. Hence for now we're safe just using
172
171
// this deprecated VW URL.
@@ -261,12 +260,10 @@ func (r *Reconciler) ensureManager(log *zap.SugaredLogger, vwURL string) error {
261
260
// Make sure the vwManager can Engage() on the controller, even though we
262
261
// start and stop them outside the control of the manager. This shim will
263
262
// ensure Engage() calls are handed to the underlying sync controller as
264
- // as long as the controller is running. There is sadly no way to remove
265
- // a shim from the manager again, so the list of runnables in the manager
266
- // will just grow over time.
267
- manager .Add (& controllerShim {
268
- reconciler : r ,
269
- })
263
+ // as long as the controller is running.
264
+ if err := manager .Add (& controllerShim {reconciler : r }); err != nil {
265
+ return fmt .Errorf ("failed to initialize cluster: %w" , err )
266
+ }
270
267
271
268
// use the app's root context as the base, not the reconciling context, which
272
269
// might get cancelled after Reconcile() is done;
0 commit comments