@@ -45,7 +45,7 @@ func (c *APIReconciler) reconcile(ctx context.Context, apiDomainKey dynamicconte
45
45
logger := klog .FromContext (ctx )
46
46
47
47
// collect APIResourceSchemas by syncTarget.
48
- apiResourceSchemas , schemaIdentites , err := c .getAllAcceptedResourceSchemas (syncTarget )
48
+ apiResourceSchemas , schemaIdentites , err := c .getAllAcceptedResourceSchemas (ctx , syncTarget )
49
49
if err != nil {
50
50
return err
51
51
}
@@ -150,40 +150,63 @@ func gvrString(gvr schema.GroupVersionResource) string {
150
150
151
151
// getAllAcceptedResourceSchemas return all resourceSchemas from APIExports defined in this syncTarget filtered by the status.syncedResource
152
152
// of syncTarget such that only resources with accepted state is returned, together with their identityHash.
153
- func (c * APIReconciler ) getAllAcceptedResourceSchemas (syncTarget * workloadv1alpha1.SyncTarget ) (map [schema.GroupResource ]* apisv1alpha1.APIResourceSchema , map [schema.GroupResource ]string , error ) {
153
+ func (c * APIReconciler ) getAllAcceptedResourceSchemas (ctx context. Context , syncTarget * workloadv1alpha1.SyncTarget ) (map [schema.GroupResource ]* apisv1alpha1.APIResourceSchema , map [schema.GroupResource ]string , error ) {
154
154
apiResourceSchemas := map [schema.GroupResource ]* apisv1alpha1.APIResourceSchema {}
155
155
156
156
identityHashByGroupResource := map [schema.GroupResource ]string {}
157
157
158
+ logger := klog .FromContext (ctx )
159
+ logger .V (4 ).Info ("getting identity hashes for compatible APIs" , "count" , len (syncTarget .Status .SyncedResources ))
160
+
158
161
// get all identityHash for compatible APIs
159
162
for _ , syncedResource := range syncTarget .Status .SyncedResources {
163
+ logger := logger .WithValues (
164
+ "group" , syncedResource .Group ,
165
+ "resource" , syncedResource .Resource ,
166
+ "identity" , syncedResource .IdentityHash ,
167
+ )
160
168
if syncedResource .State == workloadv1alpha1 .ResourceSchemaAcceptedState {
169
+ logger .V (4 ).Info ("including synced resource because it is accepted" )
161
170
identityHashByGroupResource [schema.GroupResource {
162
171
Group : syncedResource .Group ,
163
172
Resource : syncedResource .Resource ,
164
173
}] = syncedResource .IdentityHash
174
+ } else {
175
+ logger .V (4 ).Info ("excluding synced resource because it is unaccepted" )
165
176
}
166
177
}
167
178
179
+ logger .V (4 ).Info ("processing supported APIExports" , "count" , len (syncTarget .Spec .SupportedAPIExports ))
168
180
var errs []error
169
181
for _ , exportRef := range syncTarget .Spec .SupportedAPIExports {
182
+ logger .V (4 ).Info ("looking at export" , "path" , exportRef .Path , "name" , exportRef .Export )
183
+
170
184
path := logicalcluster .NewPath (exportRef .Path )
171
185
if path .Empty () {
186
+ logger .V (4 ).Info ("falling back to sync target's logical cluster for path" )
172
187
path = logicalcluster .From (syncTarget ).Path ()
173
188
}
174
189
190
+ logger := logger .WithValues ("path" , path , "name" , exportRef .Export )
191
+ logger .V (4 ).Info ("getting APIExport" )
175
192
apiExport , err := indexers .ByPathAndName [* apisv1alpha1.APIExport ](apisv1alpha1 .Resource ("apiexports" ), c .apiExportIndexer , path , exportRef .Export )
176
193
if err != nil {
194
+ logger .V (4 ).Error (err , "error getting APIExport" )
177
195
errs = append (errs , err )
178
196
continue
179
197
}
180
198
199
+ logger .V (4 ).Info ("checking APIExport's schemas" , "count" , len (apiExport .Spec .LatestResourceSchemas ))
181
200
for _ , schemaName := range apiExport .Spec .LatestResourceSchemas {
201
+ logger := logger .WithValues ("schema" , schemaName )
202
+ logger .V (4 ).Info ("getting APIResourceSchema" )
182
203
apiResourceSchema , err := c .apiResourceSchemaLister .Cluster (logicalcluster .From (apiExport )).Get (schemaName )
183
204
if apierrors .IsNotFound (err ) {
205
+ logger .V (4 ).Info ("APIResourceSchema not found" )
184
206
continue
185
207
}
186
208
if err != nil {
209
+ logger .V (4 ).Error (err , "error getting APIResourceSchema" )
187
210
errs = append (errs , err )
188
211
continue
189
212
}
@@ -193,9 +216,14 @@ func (c *APIReconciler) getAllAcceptedResourceSchemas(syncTarget *workloadv1alph
193
216
Resource : apiResourceSchema .Spec .Names .Plural ,
194
217
}
195
218
219
+ logger = logger .WithValues ("group" , gr .Group , "resource" , gr .Resource )
220
+
196
221
// if identityHash does not exist, it is not a compatible API.
197
222
if _ , ok := identityHashByGroupResource [gr ]; ok {
223
+ logger .V (4 ).Info ("identity found, including resource" )
198
224
apiResourceSchemas [gr ] = apiResourceSchema
225
+ } else {
226
+ logger .V (4 ).Info ("identity not found, excluding resource" )
199
227
}
200
228
}
201
229
}
0 commit comments