@@ -154,7 +154,7 @@ func (d *namespacedResourcesDeleter) Delete(clusterName logicalcluster.Name, nsN
154154 return nil
155155}
156156
157- func (d * namespacedResourcesDeleter ) initOpCache (clusterName logicalcluster.Name ) {
157+ func (d * namespacedResourcesDeleter ) initOpCache (clusterName logicalcluster.Name ) error {
158158 // pre-fill opCache with the discovery info
159159 //
160160 // TODO(sttts): get rid of opCache and http 405 logic around it and trust discovery info
@@ -163,7 +163,7 @@ func (d *namespacedResourcesDeleter) initOpCache(clusterName logicalcluster.Name
163163 utilruntime .HandleError (fmt .Errorf ("unable to get all supported resources from server: %v" , err ))
164164 }
165165 if len (resources ) == 0 {
166- klog . Fatalf ( "Unable to get any supported resources from server: %v" , err )
166+ return fmt . Errorf ( "unable to get any supported resources from server: %v" , err )
167167 }
168168
169169 for _ , rl := range resources {
@@ -188,6 +188,7 @@ func (d *namespacedResourcesDeleter) initOpCache(clusterName logicalcluster.Name
188188 }
189189 }
190190 }
191+ return nil
191192}
192193
193194// ResourcesRemainingError is used to inform the caller that all resources are not yet fully removed from the namespace.
@@ -236,14 +237,14 @@ func (o *operationNotSupportedCache) setNotSupported(key operationKey) {
236237}
237238
238239// isSupported returns true if the operation is supported
239- func (d * namespacedResourcesDeleter ) isSupported (clusterName logicalcluster.Name , key operationKey ) bool {
240+ func (d * namespacedResourcesDeleter ) isSupported (clusterName logicalcluster.Name , key operationKey ) ( bool , error ) {
240241 // Quick read-only check to see if the cache already exists
241242 d .opCachesMutex .RLock ()
242243 cache , exists := d .opCaches [clusterName ]
243244 d .opCachesMutex .RUnlock ()
244245
245246 if exists {
246- return cache .isSupported (key )
247+ return cache .isSupported (key ), nil
247248 }
248249
249250 // Doesn't exist - may need to create
@@ -254,7 +255,7 @@ func (d *namespacedResourcesDeleter) isSupported(clusterName logicalcluster.Name
254255 // when we checked with the read lock held, and now.
255256 cache , exists = d .opCaches [clusterName ]
256257 if exists {
257- return cache .isSupported (key )
258+ return cache .isSupported (key ), nil
258259 }
259260
260261 // Definitely doesn't exist - need to create it.
@@ -263,9 +264,11 @@ func (d *namespacedResourcesDeleter) isSupported(clusterName logicalcluster.Name
263264 }
264265 d .opCaches [clusterName ] = cache
265266
266- d .initOpCache (clusterName )
267+ if err := d .initOpCache (clusterName ); err != nil {
268+ return false , err
269+ }
267270
268- return cache .isSupported (key )
271+ return cache .isSupported (key ), nil
269272}
270273
271274// updateNamespaceFunc is a function that makes an update to a namespace
@@ -342,7 +345,9 @@ func (d *namespacedResourcesDeleter) deleteCollection(clusterName logicalcluster
342345 klog .V (5 ).Infof ("namespace controller - deleteCollection - namespace: %s, gvr: %v" , namespace , gvr )
343346
344347 key := operationKey {operation : operationDeleteCollection , gvr : gvr }
345- if ! d .isSupported (clusterName , key ) {
348+ if supported , err := d .isSupported (clusterName , key ); err != nil {
349+ return false , err
350+ } else if ! supported {
346351 klog .V (5 ).Infof ("namespace controller - deleteCollection ignored since not supported - namespace: %s, gvr: %v" , namespace , gvr )
347352 return false , nil
348353 }
@@ -381,7 +386,9 @@ func (d *namespacedResourcesDeleter) listCollection(clusterName logicalcluster.N
381386 klog .V (5 ).Infof ("namespace controller - listCollection - namespace: %s, gvr: %v" , namespace , gvr )
382387
383388 key := operationKey {operation : operationList , gvr : gvr }
384- if ! d .isSupported (clusterName , key ) {
389+ if supported , err := d .isSupported (clusterName , key ); err != nil {
390+ return nil , false , err
391+ } else if ! supported {
385392 klog .V (5 ).Infof ("namespace controller - listCollection ignored since not supported - namespace: %s, gvr: %v" , namespace , gvr )
386393 return nil , false , nil
387394 }
0 commit comments