Skip to content

Commit ae0b265

Browse files
author
Per Goncalves da Silva
committed
no live calls
Signed-off-by: Per Goncalves da Silva <[email protected]>
1 parent 61a0e72 commit ae0b265

File tree

1 file changed

+46
-41
lines changed

1 file changed

+46
-41
lines changed

pkg/controller/operators/catalog/operator.go

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import (
4747
"k8s.io/client-go/tools/clientcmd"
4848
"k8s.io/client-go/tools/pager"
4949
"k8s.io/client-go/tools/record"
50-
"k8s.io/client-go/util/retry"
5150
"k8s.io/client-go/util/workqueue"
5251
utilclock "k8s.io/utils/clock"
5352

@@ -760,7 +759,7 @@ func NewOperator(ctx context.Context, kubeconfigPath string, clock utilclock.Clo
760759
queueinformer.WithLogger(op.logger),
761760
queueinformer.WithQueue(op.nsResolveQueue),
762761
queueinformer.WithInformer(namespaceInformer.Informer()),
763-
queueinformer.WithSyncer(queueinformer.LegacySyncHandler(op.syncResolvingNamespace).ToSyncer()),
762+
queueinformer.WithSyncer(queueinformer.LegacySyncHandler(op.syncResolvingNamespace).ToSyncerWithDelete(op.handleDeletion)),
764763
)
765764
if err != nil {
766765
return nil, err
@@ -1772,34 +1771,38 @@ func (o *Operator) removeSubsCond(subs []*v1alpha1.Subscription, condType v1alph
17721771

17731772
func (o *Operator) updateSubscriptionStatuses(subs []*v1alpha1.Subscription) ([]*v1alpha1.Subscription, error) {
17741773
var (
1775-
errs []error
1776-
mu sync.Mutex
1777-
wg sync.WaitGroup
1778-
getOpts = metav1.GetOptions{}
1774+
errs []error
1775+
mu sync.Mutex
1776+
wg sync.WaitGroup
1777+
// getOpts = metav1.GetOptions{}
17791778
updateOpts = metav1.UpdateOptions{}
17801779
)
17811780

17821781
for _, sub := range subs {
17831782
wg.Add(1)
17841783
go func(sub *v1alpha1.Subscription) {
17851784
defer wg.Done()
1786-
1787-
update := func() error {
1788-
// Update the status of the latest revision
1789-
latest, err := o.client.OperatorsV1alpha1().Subscriptions(sub.GetNamespace()).Get(context.TODO(), sub.GetName(), getOpts)
1790-
if err != nil {
1791-
return err
1792-
}
1793-
latest.Status = sub.Status
1794-
*sub = *latest
1795-
_, err = o.client.OperatorsV1alpha1().Subscriptions(sub.Namespace).UpdateStatus(context.TODO(), latest, updateOpts)
1796-
return err
1797-
}
1798-
if err := retry.RetryOnConflict(retry.DefaultRetry, update); err != nil {
1785+
if _, err := o.client.OperatorsV1alpha1().Subscriptions(sub.Namespace).UpdateStatus(context.TODO(), sub, updateOpts); err != nil {
17991786
mu.Lock()
18001787
defer mu.Unlock()
18011788
errs = append(errs, err)
18021789
}
1790+
//update := func() error {
1791+
// // Update the status of the latest revision
1792+
// latest, err := o.client.OperatorsV1alpha1().Subscriptions(sub.GetNamespace()).Get(context.TODO(), sub.GetName(), getOpts)
1793+
// if err != nil {
1794+
// return err
1795+
// }
1796+
// latest.Status = sub.Status
1797+
// *sub = *latest
1798+
// _, err = o.client.OperatorsV1alpha1().Subscriptions(sub.Namespace).UpdateStatus(context.TODO(), latest, updateOpts)
1799+
// return err
1800+
//}
1801+
//if err := retry.RetryOnConflict(retry.DefaultRetry, update); err != nil {
1802+
// mu.Lock()
1803+
// defer mu.Unlock()
1804+
// errs = append(errs, err)
1805+
//}
18031806
}(sub)
18041807
}
18051808
wg.Wait()
@@ -2860,31 +2863,33 @@ func (o *Operator) getUpdatedOwnerReferences(refs []metav1.OwnerReference, names
28602863
}
28612864

28622865
func (o *Operator) listSubscriptions(namespace string) (subs []*v1alpha1.Subscription, err error) {
2863-
list, err := o.client.OperatorsV1alpha1().Subscriptions(namespace).List(context.TODO(), metav1.ListOptions{})
2864-
if err != nil {
2865-
return
2866-
}
2867-
2868-
subs = make([]*v1alpha1.Subscription, 0)
2869-
for i := range list.Items {
2870-
subs = append(subs, &list.Items[i])
2871-
}
2872-
2873-
return
2866+
return o.lister.OperatorsV1alpha1().SubscriptionLister().List(labels.Everything())
2867+
//list, err := o.client.OperatorsV1alpha1().Subscriptions(namespace).List(context.TODO(), metav1.ListOptions{})
2868+
//if err != nil {
2869+
// return
2870+
//}
2871+
//
2872+
//subs = make([]*v1alpha1.Subscription, 0)
2873+
//for i := range list.Items {
2874+
// subs = append(subs, &list.Items[i])
2875+
//}
2876+
//
2877+
//return
28742878
}
28752879

28762880
func (o *Operator) listInstallPlans(namespace string) (ips []*v1alpha1.InstallPlan, err error) {
2877-
list, err := o.client.OperatorsV1alpha1().InstallPlans(namespace).List(context.TODO(), metav1.ListOptions{})
2878-
if err != nil {
2879-
return
2880-
}
2881-
2882-
ips = make([]*v1alpha1.InstallPlan, 0)
2883-
for i := range list.Items {
2884-
ips = append(ips, &list.Items[i])
2885-
}
2886-
2887-
return
2881+
return o.lister.OperatorsV1alpha1().InstallPlanLister().List(labels.Everything())
2882+
//list, err := o.client.OperatorsV1alpha1().InstallPlans(namespace).List(context.TODO(), metav1.ListOptions{})
2883+
//if err != nil {
2884+
// return
2885+
//}
2886+
//
2887+
//ips = make([]*v1alpha1.InstallPlan, 0)
2888+
//for i := range list.Items {
2889+
// ips = append(ips, &list.Items[i])
2890+
//}
2891+
//
2892+
//return
28882893
}
28892894

28902895
// competingCRDOwnersExist returns true if there exists a CSV that owns at least one of the given CSVs owned CRDs (that's not the given CSV)

0 commit comments

Comments
 (0)