Skip to content

Commit 08ea39b

Browse files
Merge pull request #572 from njhale/fix-slowness
fix(csv-requeue): requeue on namespace all if all namespaces are watched
2 parents ab19c3a + 7b0dca4 commit 08ea39b

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

pkg/controller/operators/olm/operator.go

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"time"
88

99
log "github.com/sirupsen/logrus"
10-
"k8s.io/api/apps/v1"
1110
k8serrors "k8s.io/apimachinery/pkg/api/errors"
1211
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1312
"k8s.io/apimachinery/pkg/labels"
@@ -246,7 +245,7 @@ func NewOperator(crClient versioned.Interface, opClient operatorclient.ClientInt
246245
// Register queue and QueueInformer
247246
queueName := fmt.Sprintf("%s/csv-deployments", namespace)
248247
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())
250249
op.RegisterQueueInformer(depQueueInformer)
251250
}
252251

@@ -271,29 +270,19 @@ func (a *Operator) requeueCSV(name, namespace string) {
271270
// We can build the key directly, will need to change if queue uses different key scheme
272271
key := fmt.Sprintf("%s/%s", namespace, name)
273272
logger := log.WithField("key", key)
274-
logger.Debugf("requeueing CSV")
273+
logger.Debug("requeueing CSV")
275274

276-
if queue, ok := a.csvQueues[namespace]; ok {
275+
if queue, ok := a.csvQueues[metav1.NamespaceAll]; len(a.csvQueues) == 1 && ok {
277276
queue.AddRateLimited(key)
278277
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+
}
290279

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
294283
}
295284

296-
return nil
285+
logger.Debug("couldn't find queue for CSV")
297286
}
298287

299288
func (a *Operator) syncObject(obj interface{}) (syncError error) {
@@ -837,11 +826,13 @@ func (a *Operator) requeueOwnerCSVs(ownee metav1.Object) {
837826
logger := log.WithFields(log.Fields{
838827
"ownee": ownee.GetName(),
839828
"selflink": ownee.GetSelfLink(),
829+
"namespace": ownee.GetNamespace(),
840830
})
841831

842832
// Attempt to requeue CSV owners in the same namespace as the object
843833
owners := ownerutil.GetOwnersByKind(ownee, v1alpha1.ClusterServiceVersionKind)
844834
if len(owners) == 0 {
835+
logger.Debugf("No ownerreferences found")
845836
return
846837
}
847838

0 commit comments

Comments
 (0)