Skip to content

Commit 08a95ad

Browse files
authored
Removes error silencing from IsFailForwardEnabled (#2957)
Signed-off-by: Mikalai Radchuk <[email protected]>
1 parent c29863b commit 08a95ad

File tree

4 files changed

+52
-4
lines changed

4 files changed

+52
-4
lines changed

pkg/controller/registry/resolver/fail_forward.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ import (
1717
// backwards compatible.
1818
func IsFailForwardEnabled(ogLister v1listers.OperatorGroupNamespaceLister) (bool, error) {
1919
ogs, err := ogLister.List(labels.Everything())
20-
if err != nil || len(ogs) == 0 {
21-
return false, nil
20+
if err != nil {
21+
return false, err
2222
}
2323
if len(ogs) != 1 {
2424
return false, fmt.Errorf("found %d operatorGroups, expected 1", len(ogs))

pkg/controller/registry/resolver/resolver_test.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ import (
1212
"github.com/sirupsen/logrus/hooks/test"
1313
"github.com/stretchr/testify/assert"
1414
"github.com/stretchr/testify/require"
15+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1516

1617
"github.com/operator-framework/api/pkg/constraints"
18+
operatorsv1 "github.com/operator-framework/api/pkg/operators/v1"
1719
"github.com/operator-framework/api/pkg/operators/v1alpha1"
1820
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/cache"
1921
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/solver"
@@ -1373,6 +1375,12 @@ func TestSolveOperators_TransferApiOwnership(t *testing.T) {
13731375

13741376
namespace := "olm"
13751377
catalog := cache.SourceKey{Name: "community", Namespace: namespace}
1378+
og := &operatorsv1.OperatorGroup{
1379+
ObjectMeta: metav1.ObjectMeta{
1380+
Name: "og",
1381+
Namespace: namespace,
1382+
},
1383+
}
13761384

13771385
phases := []struct {
13781386
subs []*v1alpha1.Subscription
@@ -1442,7 +1450,7 @@ func TestSolveOperators_TransferApiOwnership(t *testing.T) {
14421450
key: cache.NewVirtualSourceKey(namespace),
14431451
csvLister: &csvs,
14441452
subLister: fakeSubscriptionLister(p.subs),
1445-
ogLister: fakeOperatorGroupLister{},
1453+
ogLister: fakeOperatorGroupLister{og},
14461454
logger: logger,
14471455
},
14481456
}),

pkg/controller/registry/resolver/source_csvs_test.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,12 @@ func (f fakeOperatorGroupLister) Get(name string) (*operatorsv1.OperatorGroup, e
467467
}
468468

469469
func TestPropertiesAnnotationHonored(t *testing.T) {
470+
og := &operatorsv1.OperatorGroup{
471+
ObjectMeta: metav1.ObjectMeta{
472+
Name: "og",
473+
Namespace: "fake-ns",
474+
},
475+
}
470476
src := &csvSource{
471477
csvLister: fakeCSVLister{
472478
&v1alpha1.ClusterServiceVersion{
@@ -478,7 +484,7 @@ func TestPropertiesAnnotationHonored(t *testing.T) {
478484
},
479485
},
480486
subLister: fakeSubscriptionLister{},
481-
ogLister: fakeOperatorGroupLister{},
487+
ogLister: fakeOperatorGroupLister{og},
482488
}
483489
ss, err := src.Snapshot(context.Background())
484490
require.NoError(t, err)

pkg/controller/registry/resolver/step_resolver_test.go

+34
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ func TestResolver(t *testing.T) {
335335
name: "SubscriptionOmitsChannel",
336336
clusterState: []runtime.Object{
337337
newSub(namespace, "package", "", catalog),
338+
newOperatorGroup("foo", namespace),
338339
},
339340
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
340341
catalog: {
@@ -354,6 +355,7 @@ func TestResolver(t *testing.T) {
354355
name: "SubscriptionWithNoCandidates/Error",
355356
clusterState: []runtime.Object{
356357
newSub(namespace, "a", "alpha", catalog),
358+
newOperatorGroup("foo", namespace),
357359
},
358360
out: resolverTestOut{
359361
solverError: solver.NotSatisfiable{
@@ -372,6 +374,7 @@ func TestResolver(t *testing.T) {
372374
name: "SubscriptionWithNoCandidatesInPackage/Error",
373375
clusterState: []runtime.Object{
374376
newSub(namespace, "a", "alpha", catalog),
377+
newOperatorGroup("foo", namespace),
375378
},
376379
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
377380
catalog: {
@@ -395,6 +398,7 @@ func TestResolver(t *testing.T) {
395398
name: "SubscriptionWithNoCandidatesInChannel/Error",
396399
clusterState: []runtime.Object{
397400
newSub(namespace, "a", "alpha", catalog),
401+
newOperatorGroup("foo", namespace),
398402
},
399403
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
400404
catalog: {
@@ -418,6 +422,7 @@ func TestResolver(t *testing.T) {
418422
name: "SubscriptionWithNoCandidatesWithStartingCSVName/Error",
419423
clusterState: []runtime.Object{
420424
newSub(namespace, "a", "alpha", catalog, withStartingCSV("notfound")),
425+
newOperatorGroup("foo", namespace),
421426
},
422427
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
423428
catalog: {
@@ -441,6 +446,7 @@ func TestResolver(t *testing.T) {
441446
name: "SingleNewSubscription/NoDeps",
442447
clusterState: []runtime.Object{
443448
newSub(namespace, "a", "alpha", catalog),
449+
newOperatorGroup("foo", namespace),
444450
},
445451
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
446452
catalog: {
@@ -460,6 +466,7 @@ func TestResolver(t *testing.T) {
460466
name: "SingleNewSubscription/ResolveOne",
461467
clusterState: []runtime.Object{
462468
newSub(namespace, "a", "alpha", catalog),
469+
newOperatorGroup("foo", namespace),
463470
},
464471
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
465472
catalog: {
@@ -482,6 +489,7 @@ func TestResolver(t *testing.T) {
482489
name: "SingleNewSubscription/ResolveOne/BundlePath",
483490
clusterState: []runtime.Object{
484491
newSub(namespace, "a", "alpha", catalog),
492+
newOperatorGroup("foo", namespace),
485493
},
486494
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
487495
catalog: {
@@ -528,6 +536,7 @@ func TestResolver(t *testing.T) {
528536
name: "SingleNewSubscription/ResolveOne/AdditionalBundleObjects",
529537
clusterState: []runtime.Object{
530538
newSub(namespace, "a", "alpha", catalog),
539+
newOperatorGroup("foo", namespace),
531540
},
532541
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
533542
catalog: {
@@ -550,6 +559,7 @@ func TestResolver(t *testing.T) {
550559
name: "SingleNewSubscription/ResolveOne/AdditionalBundleObjects/Service",
551560
clusterState: []runtime.Object{
552561
newSub(namespace, "a", "alpha", catalog),
562+
newOperatorGroup("foo", namespace),
553563
},
554564
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
555565
catalog: {
@@ -572,6 +582,7 @@ func TestResolver(t *testing.T) {
572582
name: "SingleNewSubscription/DependencyMissing",
573583
clusterState: []runtime.Object{
574584
newSub(namespace, "a", "alpha", catalog),
585+
newOperatorGroup("foo", namespace),
575586
},
576587
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
577588
catalog: {
@@ -606,6 +617,7 @@ func TestResolver(t *testing.T) {
606617
clusterState: []runtime.Object{
607618
existingSub(namespace, "a.v1", "a", "alpha", catalog),
608619
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, nil, nil, nil),
620+
newOperatorGroup("foo", namespace),
609621
},
610622
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
611623
catalog: {
@@ -620,6 +632,7 @@ func TestResolver(t *testing.T) {
620632
existingSub(namespace, "a.v1", "a", "alpha", catalog),
621633
existingSub(namespace, "b.v1", "b", "alpha", catalog),
622634
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, nil, nil, nil),
635+
newOperatorGroup("foo", namespace),
623636
},
624637
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
625638
catalog: {
@@ -638,6 +651,7 @@ func TestResolver(t *testing.T) {
638651
clusterState: []runtime.Object{
639652
newSub(namespace, "a", "alpha", catalog),
640653
newSub(namespace, "a", "beta", catalog),
654+
newOperatorGroup("foo", namespace),
641655
},
642656
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
643657
catalog: {
@@ -664,6 +678,7 @@ func TestResolver(t *testing.T) {
664678
s.Name = s.Name + "-2"
665679
return
666680
}(),
681+
newOperatorGroup("foo", namespace),
667682
},
668683
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
669684
catalog: {
@@ -689,6 +704,7 @@ func TestResolver(t *testing.T) {
689704
clusterState: []runtime.Object{
690705
existingOperator("ns1", "a.v1", "a", "alpha", "", nil, nil, nil, nil),
691706
existingOperator("ns2", "a.v1", "a", "alpha", "", nil, nil, nil, nil),
707+
newOperatorGroup("foo", namespace),
692708
},
693709
out: nothing,
694710
},
@@ -697,6 +713,7 @@ func TestResolver(t *testing.T) {
697713
clusterState: []runtime.Object{
698714
existingSub(namespace, "a.v1", "a", "alpha", catalog),
699715
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, nil, nil, nil),
716+
newOperatorGroup("foo", namespace),
700717
},
701718
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
702719
catalog: {
@@ -718,6 +735,7 @@ func TestResolver(t *testing.T) {
718735
clusterState: []runtime.Object{
719736
existingSub(namespace, "a.v1", "a", "alpha", catalog),
720737
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, nil, nil, nil),
738+
newOperatorGroup("foo", namespace),
721739
},
722740
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{catalog: {
723741
stripManifests(withBundlePath(bundle("a.v2", "a", "alpha", "a.v1", Provides1, nil, nil, nil), "quay.io/test/bundle@sha256:abcd"))},
@@ -759,6 +777,7 @@ func TestResolver(t *testing.T) {
759777
name: "InstalledSub/NoRunningOperator",
760778
clusterState: []runtime.Object{
761779
existingSub(namespace, "a.v1", "a", "alpha", catalog),
780+
newOperatorGroup("foo", namespace),
762781
},
763782
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
764783
catalog: {
@@ -778,6 +797,7 @@ func TestResolver(t *testing.T) {
778797
clusterState: []runtime.Object{
779798
existingSub(namespace, "a.v1", "a", "alpha", catalog),
780799
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, nil, nil, nil),
800+
newOperatorGroup("foo", namespace),
781801
},
782802
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
783803
catalog: {
@@ -802,6 +822,7 @@ func TestResolver(t *testing.T) {
802822
clusterState: []runtime.Object{
803823
existingSub(namespace, "a.v1", "a", "alpha", catalog),
804824
existingOperator(namespace, "a.v1", "a", "alpha", "", nil, nil, Provides1, nil),
825+
newOperatorGroup("foo", namespace),
805826
},
806827
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
807828
catalog: {
@@ -827,6 +848,7 @@ func TestResolver(t *testing.T) {
827848
existingSub(namespace, "a.v1", "a", "alpha", catalog),
828849
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, nil, nil, nil),
829850
newSub(namespace, "b", "beta", catalog),
851+
newOperatorGroup("foo", namespace),
830852
},
831853
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
832854
catalog: {
@@ -851,6 +873,7 @@ func TestResolver(t *testing.T) {
851873
clusterState: []runtime.Object{
852874
existingSub(namespace, "a.v1", "a", "alpha", catalog),
853875
newSub(namespace, "b", "beta", catalog),
876+
newOperatorGroup("foo", namespace),
854877
},
855878
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
856879
catalog: {
@@ -873,6 +896,7 @@ func TestResolver(t *testing.T) {
873896
clusterState: []runtime.Object{
874897
existingSub(namespace, "a.v1", "a", "alpha", catalog),
875898
newSub(namespace, "b", "beta", catalog),
899+
newOperatorGroup("foo", namespace),
876900
},
877901
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
878902
catalog: {
@@ -898,6 +922,7 @@ func TestResolver(t *testing.T) {
898922
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, Requires2, nil, nil),
899923
existingSub(namespace, "b.v1", "b", "alpha", catalog),
900924
existingOperator(namespace, "b.v1", "b", "alpha", "", Provides2, Requires1, nil, nil),
925+
newOperatorGroup("foo", namespace),
901926
},
902927
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
903928
catalog: {
@@ -924,6 +949,7 @@ func TestResolver(t *testing.T) {
924949
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, nil, nil, nil),
925950
existingSub(namespace, "b.v1", "b", "alpha", catalog),
926951
existingOperator(namespace, "b.v1", "b", "alpha", "", nil, Requires1, nil, nil),
952+
newOperatorGroup("foo", namespace),
927953
},
928954
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
929955
catalog: {
@@ -946,6 +972,7 @@ func TestResolver(t *testing.T) {
946972
name: "PicksOlderProvider",
947973
clusterState: []runtime.Object{
948974
newSub(namespace, "b", "alpha", catalog),
975+
newOperatorGroup("foo", namespace),
949976
},
950977
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
951978
catalog: {
@@ -970,6 +997,7 @@ func TestResolver(t *testing.T) {
970997
clusterState: []runtime.Object{
971998
existingSub(namespace, "a.v1", "a", "alpha", catalog),
972999
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, nil, nil, nil),
1000+
newOperatorGroup("foo", namespace),
9731001
},
9741002
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{catalog: {
9751003
bundle("a.v3", "a", "alpha", "a.v2", nil, nil, nil, nil, withVersion("1.0.0"), withSkipRange("< 1.0.0")),
@@ -990,6 +1018,7 @@ func TestResolver(t *testing.T) {
9901018
existingSub(namespace, "b.v1", "b", "beta", catalog),
9911019
existingOperator(namespace, "a.v1", "a", "alpha", "", nil, Requires1, nil, nil),
9921020
existingOperator(namespace, "b.v1", "b", "beta", "", Provides1, nil, nil, nil),
1021+
newOperatorGroup("foo", namespace),
9931022
},
9941023
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{
9951024
catalog: {
@@ -1015,6 +1044,7 @@ func TestResolver(t *testing.T) {
10151044
clusterState: []runtime.Object{
10161045
existingSub(namespace, "a.v1", "a", "alpha", catalog),
10171046
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, nil, nil, nil),
1047+
newOperatorGroup("foo", namespace),
10181048
},
10191049
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{catalog: {
10201050
bundle("a.v2", "a", "alpha", "", nil, nil, nil, nil, withVersion("1.0.0"), withSkipRange("< 1.0.0")),
@@ -1034,6 +1064,7 @@ func TestResolver(t *testing.T) {
10341064
name: "NewSub/StartingCSV",
10351065
clusterState: []runtime.Object{
10361066
newSub(namespace, "a", "alpha", catalog, withStartingCSV("a.v2")),
1067+
newOperatorGroup("foo", namespace),
10371068
},
10381069
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{catalog: {
10391070
bundle("a.v1", "a", "alpha", "", nil, nil, nil, nil),
@@ -1054,6 +1085,7 @@ func TestResolver(t *testing.T) {
10541085
clusterState: []runtime.Object{
10551086
existingSub(namespace, "a.v1", "a", "alpha", catalog),
10561087
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, nil, nil, nil),
1088+
newOperatorGroup("foo", namespace),
10571089
},
10581090
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{catalog: {
10591091
bundle("a.v2", "a", "alpha", "", nil, nil, nil, nil, withVersion("1.0.0"), withSkips([]string{"a.v1"})),
@@ -1074,6 +1106,7 @@ func TestResolver(t *testing.T) {
10741106
existingSub(namespace, "a.v2", "a", "alpha", catalog),
10751107
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, nil, nil, nil, withPhase(v1alpha1.CSVPhaseReplacing)),
10761108
existingOperator(namespace, "a.v2", "a", "alpha", "a.v1", Provides1, nil, nil, nil, withPhase(v1alpha1.CSVPhaseFailed)),
1109+
newOperatorGroup("foo", namespace),
10771110
},
10781111
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{catalog: {
10791112
bundle("a.v1", "a", "alpha", "", Provides1, nil, nil, nil, withVersion("1.0.0")),
@@ -1121,6 +1154,7 @@ func TestResolver(t *testing.T) {
11211154
existingOperator(namespace, "a.v1", "a", "alpha", "", Provides1, nil, nil, nil, withPhase(v1alpha1.CSVPhaseReplacing)),
11221155
existingOperator(namespace, "a.v2", "a", "alpha", "a.v1", Provides1, nil, nil, nil, withPhase(v1alpha1.CSVPhaseReplacing)),
11231156
existingOperator(namespace, "a.v3", "a", "alpha", "a.v2", Provides1, nil, nil, nil, withPhase(v1alpha1.CSVPhaseFailed)),
1157+
newOperatorGroup("foo", namespace),
11241158
},
11251159
bundlesByCatalog: map[resolvercache.SourceKey][]*api.Bundle{catalog: {
11261160
bundle("a.v1", "a", "alpha", "", Provides1, nil, nil, nil, withVersion("1.0.0")),

0 commit comments

Comments
 (0)