7
7
"time"
8
8
9
9
log "github.com/sirupsen/logrus"
10
- "k8s.io/api/apps/v1"
11
10
k8serrors "k8s.io/apimachinery/pkg/api/errors"
12
11
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13
12
"k8s.io/apimachinery/pkg/labels"
@@ -246,7 +245,7 @@ func NewOperator(crClient versioned.Interface, opClient operatorclient.ClientInt
246
245
// Register queue and QueueInformer
247
246
queueName := fmt .Sprintf ("%s/csv-deployments" , namespace )
248
247
depQueue := workqueue .NewNamedRateLimitingQueue (workqueue .DefaultControllerRateLimiter (), queueName )
249
- depQueueInformer := queueinformer .NewInformer (depQueue , depInformer .Informer (), op .syncDeployment , depHandlers , queueName , metrics .NewMetricsNil ())
248
+ depQueueInformer := queueinformer .NewInformer (depQueue , depInformer .Informer (), op .syncObject , depHandlers , queueName , metrics .NewMetricsNil ())
250
249
op .RegisterQueueInformer (depQueueInformer )
251
250
}
252
251
@@ -271,29 +270,19 @@ func (a *Operator) requeueCSV(name, namespace string) {
271
270
// We can build the key directly, will need to change if queue uses different key scheme
272
271
key := fmt .Sprintf ("%s/%s" , namespace , name )
273
272
logger := log .WithField ("key" , key )
274
- logger .Debugf ("requeueing CSV" )
273
+ logger .Debug ("requeueing CSV" )
275
274
276
- if queue , ok := a .csvQueues [namespace ]; ok {
275
+ if queue , ok := a .csvQueues [metav1 . NamespaceAll ]; len ( a . csvQueues ) == 1 && ok {
277
276
queue .AddRateLimited (key )
278
277
return
279
- }
280
-
281
- logger .Debugf ("couldn't find queue for CSV" )
282
- }
283
-
284
- func (a * Operator ) syncDeployment (obj interface {}) (syncError error ) {
285
- deployment , ok := obj .(* v1.Deployment )
286
- if ! ok {
287
- log .Debugf ("wrong type: %#v" , obj )
288
- return fmt .Errorf ("casting Deployment failed" )
289
- }
278
+ }
290
279
291
- // Requeue owner CSVs
292
- if ownerutil . IsOwnedByKind ( deployment , v1alpha1 . ClusterServiceVersionKind ) {
293
- a . requeueOwnerCSVs ( deployment )
280
+ if queue , ok := a . csvQueues [ namespace ]; ok {
281
+ queue . AddRateLimited ( key )
282
+ return
294
283
}
295
284
296
- return nil
285
+ logger . Debug ( "couldn't find queue for CSV" )
297
286
}
298
287
299
288
func (a * Operator ) syncObject (obj interface {}) (syncError error ) {
@@ -837,11 +826,13 @@ func (a *Operator) requeueOwnerCSVs(ownee metav1.Object) {
837
826
logger := log .WithFields (log.Fields {
838
827
"ownee" : ownee .GetName (),
839
828
"selflink" : ownee .GetSelfLink (),
829
+ "namespace" : ownee .GetNamespace (),
840
830
})
841
831
842
832
// Attempt to requeue CSV owners in the same namespace as the object
843
833
owners := ownerutil .GetOwnersByKind (ownee , v1alpha1 .ClusterServiceVersionKind )
844
834
if len (owners ) == 0 {
835
+ logger .Debugf ("No ownerreferences found" )
845
836
return
846
837
}
847
838
0 commit comments