forked from operator-framework/operator-lifecycle-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubscription_e2e_test.go
2631 lines (2255 loc) · 102 KB
/
subscription_e2e_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package e2e
import (
"context"
"encoding/json"
"fmt"
"reflect"
"strings"
"sync"
"time"
"github.com/blang/semver"
"github.com/ghodss/yaml"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
configv1 "github.com/openshift/api/config/v1"
configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
"github.com/stretchr/testify/require"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/discovery"
"github.com/operator-framework/api/pkg/lib/version"
"github.com/operator-framework/api/pkg/operators/v1alpha1"
"github.com/operator-framework/operator-lifecycle-manager/pkg/api/client/clientset/versioned"
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/install"
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry"
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver"
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/projection"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/comparison"
"github.com/operator-framework/operator-lifecycle-manager/pkg/lib/operatorclient"
"github.com/operator-framework/operator-lifecycle-manager/test/e2e/ctx"
registryapi "github.com/operator-framework/operator-registry/pkg/api"
)
func Step(level int, text string, callbacks ...func()) {
By(strings.Repeat(" ", level*2)+text, callbacks...)
}
const (
timeout = time.Second * 20
interval = time.Millisecond * 100
)
var _ = By
var _ = Describe("Subscription", func() {
AfterEach(func() {
TearDown(testNamespace)
})
// I. Creating a new subscription
// A. If package is not installed, creating a subscription should install latest version
It("creation if not installed", func() {
c := newKubeClient()
crc := newCRClient()
defer func() {
require.NoError(GinkgoT(), crc.OperatorsV1alpha1().Subscriptions(testNamespace).DeleteCollection(context.Background(), metav1.DeleteOptions{}, metav1.ListOptions{}))
}()
require.NoError(GinkgoT(), initCatalog(GinkgoT(), c, crc))
cleanup, _ := createSubscription(GinkgoT(), crc, testNamespace, testSubscriptionName, testPackageName, betaChannel, v1alpha1.ApprovalAutomatic)
defer cleanup()
subscription, err := fetchSubscription(crc, testNamespace, testSubscriptionName, subscriptionStateAtLatestChecker)
require.NoError(GinkgoT(), err)
require.NotNil(GinkgoT(), subscription)
csv, err := fetchCSV(crc, subscription.Status.CurrentCSV, testNamespace, buildCSVConditionChecker(v1alpha1.CSVPhaseSucceeded))
require.NoError(GinkgoT(), err)
// Check for the olm.package property as a proxy for
// verifying that the annotation value is reasonable.
Expect(
projection.PropertyListFromPropertiesAnnotation(csv.GetAnnotations()["operatorframework.io/properties"]),
).To(ContainElement(
®istryapi.Property{Type: "olm.package", Value: `{"packageName":"myapp","version":"0.1.1"}`},
))
})
// I. Creating a new subscription
// B. If package is already installed, creating a subscription should upgrade it to the latest
// version
It("creation using existing CSV", func() {
c := newKubeClient()
crc := newCRClient()
defer func() {
require.NoError(GinkgoT(), crc.OperatorsV1alpha1().Subscriptions(testNamespace).DeleteCollection(context.Background(), metav1.DeleteOptions{}, metav1.ListOptions{}))
}()
require.NoError(GinkgoT(), initCatalog(GinkgoT(), c, crc))
// Will be cleaned up by the upgrade process
_, err := createCSV(c, crc, stableCSV, testNamespace, false, false)
require.NoError(GinkgoT(), err)
subscriptionCleanup, _ := createSubscription(GinkgoT(), crc, testNamespace, testSubscriptionName, testPackageName, alphaChannel, v1alpha1.ApprovalAutomatic)
defer subscriptionCleanup()
subscription, err := fetchSubscription(crc, testNamespace, testSubscriptionName, subscriptionStateAtLatestChecker)
require.NoError(GinkgoT(), err)
require.NotNil(GinkgoT(), subscription)
_, err = fetchCSV(crc, subscription.Status.CurrentCSV, testNamespace, buildCSVConditionChecker(v1alpha1.CSVPhaseSucceeded))
require.NoError(GinkgoT(), err)
})
It("skip range", func() {
crdPlural := genName("ins")
crdName := crdPlural + ".cluster.com"
crd := apiextensions.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: crdName,
},
Spec: apiextensions.CustomResourceDefinitionSpec{
Group: "cluster.com",
Version: "v1alpha1",
Names: apiextensions.CustomResourceDefinitionNames{
Plural: crdPlural,
Singular: crdPlural,
Kind: crdPlural,
ListKind: "list" + crdPlural,
},
Scope: "Namespaced",
},
}
mainPackageName := genName("nginx-")
mainPackageStable := fmt.Sprintf("%s-stable", mainPackageName)
updatedPackageStable := fmt.Sprintf("%s-updated", mainPackageName)
stableChannel := "stable"
mainCSV := newCSV(mainPackageStable, testNamespace, "", semver.MustParse("0.1.0-1556661347"), []apiextensions.CustomResourceDefinition{crd}, nil, nil)
updatedCSV := newCSV(updatedPackageStable, testNamespace, "", semver.MustParse("0.1.0-1556661832"), []apiextensions.CustomResourceDefinition{crd}, nil, nil)
updatedCSV.SetAnnotations(map[string]string{resolver.SkipPackageAnnotationKey: ">=0.1.0-1556661347 <0.1.0-1556661832"})
c := newKubeClient()
crc := newCRClient()
defer func() {
require.NoError(GinkgoT(), crc.OperatorsV1alpha1().Subscriptions(testNamespace).DeleteCollection(context.Background(), metav1.DeleteOptions{}, metav1.ListOptions{}))
}()
mainCatalogName := genName("mock-ocs-main-")
// Create separate manifests for each CatalogSource
mainManifests := []registry.PackageManifest{
{
PackageName: mainPackageName,
Channels: []registry.PackageChannel{
{Name: stableChannel, CurrentCSVName: mainPackageStable},
},
DefaultChannelName: stableChannel,
},
}
updatedManifests := []registry.PackageManifest{
{
PackageName: mainPackageName,
Channels: []registry.PackageChannel{
{Name: stableChannel, CurrentCSVName: updatedPackageStable},
},
DefaultChannelName: stableChannel,
},
}
// Create catalog source
_, cleanupMainCatalogSource := createInternalCatalogSource(c, crc, mainCatalogName, testNamespace, mainManifests, []apiextensions.CustomResourceDefinition{crd}, []v1alpha1.ClusterServiceVersion{mainCSV})
defer cleanupMainCatalogSource()
// Attempt to get the catalog source before creating subscription
_, err := fetchCatalogSourceOnStatus(crc, mainCatalogName, testNamespace, catalogSourceRegistryPodSynced)
require.NoError(GinkgoT(), err)
// Create a subscription
subscriptionName := genName("sub-nginx-")
subscriptionCleanup := createSubscriptionForCatalog(crc, testNamespace, subscriptionName, mainCatalogName, mainPackageName, stableChannel, "", v1alpha1.ApprovalAutomatic)
defer subscriptionCleanup()
// Wait for csv to install
firstCSV, err := awaitCSV(GinkgoT(), crc, testNamespace, mainCSV.GetName(), csvSucceededChecker)
require.NoError(GinkgoT(), err)
// Update catalog with a new csv in the channel with a skip range
updateInternalCatalog(GinkgoT(), c, crc, mainCatalogName, testNamespace, []apiextensions.CustomResourceDefinition{crd}, []v1alpha1.ClusterServiceVersion{updatedCSV}, updatedManifests)
// Wait for csv to update
finalCSV, err := awaitCSV(GinkgoT(), crc, testNamespace, updatedCSV.GetName(), csvSucceededChecker)
require.NoError(GinkgoT(), err)
// Ensure we set the replacement field based on the registry data
require.Equal(GinkgoT(), firstCSV.GetName(), finalCSV.Spec.Replaces)
})
// If installPlanApproval is set to manual, the installplans created should be created with approval: manual
It("creation manual approval", func() {
c := newKubeClient()
crc := newCRClient()
defer func() {
require.NoError(GinkgoT(), crc.OperatorsV1alpha1().Subscriptions(testNamespace).DeleteCollection(context.Background(), metav1.DeleteOptions{}, metav1.ListOptions{}))
}()
require.NoError(GinkgoT(), initCatalog(GinkgoT(), c, crc))
subscriptionCleanup, _ := createSubscription(GinkgoT(), crc, testNamespace, "manual-subscription", testPackageName, stableChannel, v1alpha1.ApprovalManual)
defer subscriptionCleanup()
subscription, err := fetchSubscription(crc, testNamespace, "manual-subscription", subscriptionStateUpgradePendingChecker)
require.NoError(GinkgoT(), err)
require.NotNil(GinkgoT(), subscription)
installPlan, err := fetchInstallPlan(GinkgoT(), crc, subscription.Status.Install.Name, buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseRequiresApproval))
require.NoError(GinkgoT(), err)
require.NotNil(GinkgoT(), installPlan)
require.Equal(GinkgoT(), v1alpha1.ApprovalManual, installPlan.Spec.Approval)
require.Equal(GinkgoT(), v1alpha1.InstallPlanPhaseRequiresApproval, installPlan.Status.Phase)
// Delete the current installplan
err = crc.OperatorsV1alpha1().InstallPlans(testNamespace).Delete(context.Background(), installPlan.Name, metav1.DeleteOptions{})
require.NoError(GinkgoT(), err)
var ipName string
Eventually(func() bool {
fetched, err := crc.OperatorsV1alpha1().Subscriptions(testNamespace).Get(context.TODO(), "manual-subscription", metav1.GetOptions{})
if err != nil {
return false
}
if fetched.Status.Install != nil {
ipName = fetched.Status.Install.Name
return fetched.Status.Install.Name != installPlan.Name
}
return false
}, 5*time.Minute, 10*time.Second).Should(BeTrue())
// Fetch new installplan
newInstallPlan, err := fetchInstallPlan(GinkgoT(), crc, ipName, buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseRequiresApproval))
require.NoError(GinkgoT(), err)
require.NotNil(GinkgoT(), newInstallPlan)
require.NotEqual(GinkgoT(), installPlan.Name, newInstallPlan.Name, "expected new installplan recreated")
require.Equal(GinkgoT(), v1alpha1.ApprovalManual, newInstallPlan.Spec.Approval)
require.Equal(GinkgoT(), v1alpha1.InstallPlanPhaseRequiresApproval, newInstallPlan.Status.Phase)
// Set the InstallPlan's approved to True
Eventually(Apply(newInstallPlan, func(p *v1alpha1.InstallPlan) error {
p.Spec.Approved = true
return nil
})).Should(Succeed())
_, err = crc.OperatorsV1alpha1().InstallPlans(testNamespace).Update(context.Background(), newInstallPlan, metav1.UpdateOptions{})
require.NoError(GinkgoT(), err)
subscription, err = fetchSubscription(crc, testNamespace, "manual-subscription", subscriptionStateAtLatestChecker)
require.NoError(GinkgoT(), err)
require.NotNil(GinkgoT(), subscription)
_, err = fetchCSV(crc, subscription.Status.CurrentCSV, testNamespace, buildCSVConditionChecker(v1alpha1.CSVPhaseSucceeded))
require.NoError(GinkgoT(), err)
})
It("with starting CSV", func() {
crdPlural := genName("ins")
crdName := crdPlural + ".cluster.com"
crd := apiextensions.CustomResourceDefinition{
ObjectMeta: metav1.ObjectMeta{
Name: crdName,
},
Spec: apiextensions.CustomResourceDefinitionSpec{
Group: "cluster.com",
Version: "v1alpha1",
Names: apiextensions.CustomResourceDefinitionNames{
Plural: crdPlural,
Singular: crdPlural,
Kind: crdPlural,
ListKind: "list" + crdPlural,
},
Scope: "Namespaced",
},
}
// Create CSV
packageName := genName("nginx-")
stableChannel := "stable"
csvA := newCSV("nginx-a", testNamespace, "", semver.MustParse("0.1.0"), []apiextensions.CustomResourceDefinition{crd}, nil, nil)
csvB := newCSV("nginx-b", testNamespace, "nginx-a", semver.MustParse("0.2.0"), []apiextensions.CustomResourceDefinition{crd}, nil, nil)
// Create PackageManifests
manifests := []registry.PackageManifest{
{
PackageName: packageName,
Channels: []registry.PackageChannel{
{Name: stableChannel, CurrentCSVName: csvB.GetName()},
},
DefaultChannelName: stableChannel,
},
}
// Create the CatalogSource
c := newKubeClient()
crc := newCRClient()
catalogSourceName := genName("mock-nginx-")
_, cleanupCatalogSource := createInternalCatalogSource(c, crc, catalogSourceName, testNamespace, manifests, []apiextensions.CustomResourceDefinition{crd}, []v1alpha1.ClusterServiceVersion{csvA, csvB})
defer cleanupCatalogSource()
// Attempt to get the catalog source before creating install plan
_, err := fetchCatalogSourceOnStatus(crc, catalogSourceName, testNamespace, catalogSourceRegistryPodSynced)
require.NoError(GinkgoT(), err)
subscriptionName := genName("sub-nginx-")
cleanupSubscription := createSubscriptionForCatalog(crc, testNamespace, subscriptionName, catalogSourceName, packageName, stableChannel, csvA.GetName(), v1alpha1.ApprovalManual)
defer cleanupSubscription()
subscription, err := fetchSubscription(crc, testNamespace, subscriptionName, subscriptionHasInstallPlanChecker)
require.NoError(GinkgoT(), err)
require.NotNil(GinkgoT(), subscription)
installPlanName := subscription.Status.Install.Name
// Wait for InstallPlan to be status: Complete before checking resource presence
requiresApprovalChecker := buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseRequiresApproval)
fetchedInstallPlan, err := fetchInstallPlan(GinkgoT(), crc, installPlanName, requiresApprovalChecker)
require.NoError(GinkgoT(), err)
// Ensure that only 1 installplan was created
ips, err := crc.OperatorsV1alpha1().InstallPlans(testNamespace).List(context.Background(), metav1.ListOptions{})
require.NoError(GinkgoT(), err)
require.Len(GinkgoT(), ips.Items, 1)
// Ensure that csvA and its crd are found in the plan
csvFound := false
crdFound := false
for _, s := range fetchedInstallPlan.Status.Plan {
require.Equal(GinkgoT(), csvA.GetName(), s.Resolving, "unexpected resolution found")
require.Equal(GinkgoT(), v1alpha1.StepStatusUnknown, s.Status, "status should be unknown")
require.Equal(GinkgoT(), catalogSourceName, s.Resource.CatalogSource, "incorrect catalogsource on step resource")
switch kind := s.Resource.Kind; kind {
case v1alpha1.ClusterServiceVersionKind:
require.Equal(GinkgoT(), csvA.GetName(), s.Resource.Name, "unexpected csv found")
csvFound = true
case "CustomResourceDefinition":
require.Equal(GinkgoT(), crdName, s.Resource.Name, "unexpected crd found")
crdFound = true
default:
GinkgoT().Fatalf("unexpected resource kind found in installplan: %s", kind)
}
}
require.True(GinkgoT(), csvFound, "expected csv not found in installplan")
require.True(GinkgoT(), crdFound, "expected crd not found in installplan")
// Ensure that csvB is not found in the plan
csvFound = false
for _, s := range fetchedInstallPlan.Status.Plan {
require.Equal(GinkgoT(), csvA.GetName(), s.Resolving, "unexpected resolution found")
require.Equal(GinkgoT(), v1alpha1.StepStatusUnknown, s.Status, "status should be unknown")
require.Equal(GinkgoT(), catalogSourceName, s.Resource.CatalogSource, "incorrect catalogsource on step resource")
switch kind := s.Resource.Kind; kind {
case v1alpha1.ClusterServiceVersionKind:
if s.Resource.Name == csvB.GetName() {
csvFound = true
}
}
}
require.False(GinkgoT(), csvFound, "expected csv not found in installplan")
// Approve the installplan and wait for csvA to be installed
fetchedInstallPlan.Spec.Approved = true
_, err = crc.OperatorsV1alpha1().InstallPlans(testNamespace).Update(context.Background(), fetchedInstallPlan, metav1.UpdateOptions{})
require.NoError(GinkgoT(), err)
_, err = awaitCSV(GinkgoT(), crc, testNamespace, csvA.GetName(), csvSucceededChecker)
require.NoError(GinkgoT(), err)
// Wait for the subscription to begin upgrading to csvB
subscription, err = fetchSubscription(crc, testNamespace, subscriptionName, subscriptionStateUpgradePendingChecker)
require.NoError(GinkgoT(), err)
require.NotEqual(GinkgoT(), fetchedInstallPlan.GetName(), subscription.Status.InstallPlanRef.Name, "expected new installplan for upgraded csv")
upgradeInstallPlan, err := fetchInstallPlan(GinkgoT(), crc, subscription.Status.InstallPlanRef.Name, requiresApprovalChecker)
require.NoError(GinkgoT(), err)
// Approve the upgrade installplan and wait for
upgradeInstallPlan.Spec.Approved = true
_, err = crc.OperatorsV1alpha1().InstallPlans(testNamespace).Update(context.Background(), upgradeInstallPlan, metav1.UpdateOptions{})
require.NoError(GinkgoT(), err)
_, err = awaitCSV(GinkgoT(), crc, testNamespace, csvB.GetName(), csvSucceededChecker)
require.NoError(GinkgoT(), err)
// Ensure that 2 installplans were created
ips, err = crc.OperatorsV1alpha1().InstallPlans(testNamespace).List(context.Background(), metav1.ListOptions{})
require.NoError(GinkgoT(), err)
require.Len(GinkgoT(), ips.Items, 2)
})
It("updates multiple intermediates", func() {
crd := newCRD("ins")
// Create CSV
packageName := genName("nginx-")
stableChannel := "stable"
csvA := newCSV("nginx-a", testNamespace, "", semver.MustParse("0.1.0"), []apiextensions.CustomResourceDefinition{crd}, nil, nil)
csvB := newCSV("nginx-b", testNamespace, "nginx-a", semver.MustParse("0.2.0"), []apiextensions.CustomResourceDefinition{crd}, nil, nil)
csvC := newCSV("nginx-c", testNamespace, "nginx-b", semver.MustParse("0.3.0"), []apiextensions.CustomResourceDefinition{crd}, nil, nil)
// Create PackageManifests
manifests := []registry.PackageManifest{
{
PackageName: packageName,
Channels: []registry.PackageChannel{
{Name: stableChannel, CurrentCSVName: csvA.GetName()},
},
DefaultChannelName: stableChannel,
},
}
// Create the CatalogSource with just one version
c := newKubeClient()
crc := newCRClient()
catalogSourceName := genName("mock-nginx-")
_, cleanupCatalogSource := createInternalCatalogSource(c, crc, catalogSourceName, testNamespace, manifests, []apiextensions.CustomResourceDefinition{crd}, []v1alpha1.ClusterServiceVersion{csvA})
defer cleanupCatalogSource()
// Attempt to get the catalog source before creating install plan
_, err := fetchCatalogSourceOnStatus(crc, catalogSourceName, testNamespace, catalogSourceRegistryPodSynced)
require.NoError(GinkgoT(), err)
subscriptionName := genName("sub-nginx-")
cleanupSubscription := createSubscriptionForCatalog(crc, testNamespace, subscriptionName, catalogSourceName, packageName, stableChannel, csvA.GetName(), v1alpha1.ApprovalAutomatic)
defer cleanupSubscription()
subscription, err := fetchSubscription(crc, testNamespace, subscriptionName, subscriptionHasInstallPlanChecker)
require.NoError(GinkgoT(), err)
require.NotNil(GinkgoT(), subscription)
// Wait for csvA to be installed
_, err = awaitCSV(GinkgoT(), crc, testNamespace, csvA.GetName(), csvSucceededChecker)
require.NoError(GinkgoT(), err)
// Set up async watches that will fail the test if csvB doesn't get created in between csvA and csvC
var wg sync.WaitGroup
go func(t GinkgoTInterface) {
defer GinkgoRecover()
wg.Add(1)
defer wg.Done()
_, err := awaitCSV(GinkgoT(), crc, testNamespace, csvB.GetName(), csvReplacingChecker)
require.NoError(GinkgoT(), err)
}(GinkgoT())
// Update the catalog to include multiple updates
packages := []registry.PackageManifest{
{
PackageName: packageName,
Channels: []registry.PackageChannel{
{Name: stableChannel, CurrentCSVName: csvC.GetName()},
},
DefaultChannelName: stableChannel,
},
}
updateInternalCatalog(GinkgoT(), c, crc, catalogSourceName, testNamespace, []apiextensions.CustomResourceDefinition{crd}, []v1alpha1.ClusterServiceVersion{csvA, csvB, csvC}, packages)
// wait for checks on intermediate csvs to succeed
wg.Wait()
// Wait for csvC to be installed
_, err = awaitCSV(GinkgoT(), crc, testNamespace, csvC.GetName(), csvSucceededChecker)
require.NoError(GinkgoT(), err)
// Should eventually GC the CSVs
err = waitForCSVToDelete(GinkgoT(), crc, csvA.Name)
require.NoError(GinkgoT(), err)
err = waitForCSVToDelete(GinkgoT(), crc, csvB.Name)
require.NoError(GinkgoT(), err)
// TODO: check installplans, subscription status, etc
})
// TestSubscriptionUpdatesExistingInstallPlan ensures that an existing InstallPlan
// has the appropriate approval requirement from Subscription.
It("updates existing install plan", func() {
Skip("ToDo: This test was skipped before ginkgo conversion")
// Create CSV
packageName := genName("nginx-")
stableChannel := "stable"
csvA := newCSV("nginx-a", testNamespace, "", semver.MustParse("0.1.0"), nil, nil, nil)
csvB := newCSV("nginx-b", testNamespace, "nginx-a", semver.MustParse("0.2.0"), nil, nil, nil)
// Create PackageManifests
manifests := []registry.PackageManifest{
{
PackageName: packageName,
Channels: []registry.PackageChannel{
{Name: stableChannel, CurrentCSVName: csvB.GetName()},
},
DefaultChannelName: stableChannel,
},
}
// Create the CatalogSource with just one version
c := newKubeClient()
crc := newCRClient()
catalogSourceName := genName("mock-nginx-")
_, cleanupCatalogSource := createInternalCatalogSource(c, crc, catalogSourceName, testNamespace, manifests, nil, []v1alpha1.ClusterServiceVersion{csvA, csvB})
defer cleanupCatalogSource()
// Attempt to get the catalog source before creating install plan
_, err := fetchCatalogSourceOnStatus(crc, catalogSourceName, testNamespace, catalogSourceRegistryPodSynced)
require.NoError(GinkgoT(), err)
// Create a subscription to just get an InstallPlan for csvB
subscriptionName := genName("sub-nginx-")
createSubscriptionForCatalog(crc, testNamespace, subscriptionName, catalogSourceName, packageName, stableChannel, csvB.GetName(), v1alpha1.ApprovalAutomatic)
// Wait for csvB to be installed
_, err = awaitCSV(GinkgoT(), crc, testNamespace, csvB.GetName(), csvSucceededChecker)
require.NoError(GinkgoT(), err)
subscription, err := fetchSubscription(crc, testNamespace, subscriptionName, subscriptionHasInstallPlanChecker)
fetchedInstallPlan, err := fetchInstallPlan(GinkgoT(), crc, subscription.Status.InstallPlanRef.Name, buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseComplete))
// Delete this subscription
err = crc.OperatorsV1alpha1().Subscriptions(testNamespace).DeleteCollection(context.Background(), *metav1.NewDeleteOptions(0), metav1.ListOptions{})
require.NoError(GinkgoT(), err)
// Delete orphaned csvB
require.NoError(GinkgoT(), crc.OperatorsV1alpha1().ClusterServiceVersions(testNamespace).Delete(context.Background(), csvB.GetName(), metav1.DeleteOptions{}))
// Create an InstallPlan for csvB
ip := &v1alpha1.InstallPlan{
ObjectMeta: metav1.ObjectMeta{
GenerateName: "install-",
Namespace: testNamespace,
},
Spec: v1alpha1.InstallPlanSpec{
ClusterServiceVersionNames: []string{csvB.GetName()},
Approval: v1alpha1.ApprovalAutomatic,
Approved: false,
},
}
ip2, err := crc.OperatorsV1alpha1().InstallPlans(testNamespace).Create(context.Background(), ip, metav1.CreateOptions{})
require.NoError(GinkgoT(), err)
ip2.Status = v1alpha1.InstallPlanStatus{
Plan: fetchedInstallPlan.Status.Plan,
CatalogSources: []string{catalogSourceName},
}
_, err = crc.OperatorsV1alpha1().InstallPlans(testNamespace).UpdateStatus(context.Background(), ip2, metav1.UpdateOptions{})
require.NoError(GinkgoT(), err)
subscriptionName = genName("sub-nginx-")
cleanupSubscription := createSubscriptionForCatalog(crc, testNamespace, subscriptionName, catalogSourceName, packageName, stableChannel, csvA.GetName(), v1alpha1.ApprovalManual)
defer cleanupSubscription()
subscription, err = fetchSubscription(crc, testNamespace, subscriptionName, subscriptionHasInstallPlanChecker)
require.NoError(GinkgoT(), err)
require.NotNil(GinkgoT(), subscription)
installPlanName := subscription.Status.Install.Name
// Wait for InstallPlan to be status: Complete before checking resource presence
requiresApprovalChecker := buildInstallPlanPhaseCheckFunc(v1alpha1.InstallPlanPhaseRequiresApproval)
fetchedInstallPlan, err = fetchInstallPlan(GinkgoT(), crc, installPlanName, requiresApprovalChecker)
require.NoError(GinkgoT(), err)
// Approve the installplan and wait for csvA to be installed
fetchedInstallPlan.Spec.Approved = true
_, err = crc.OperatorsV1alpha1().InstallPlans(testNamespace).Update(context.Background(), fetchedInstallPlan, metav1.UpdateOptions{})
require.NoError(GinkgoT(), err)
// Wait for csvA to be installed
_, err = awaitCSV(GinkgoT(), crc, testNamespace, csvA.GetName(), csvSucceededChecker)
require.NoError(GinkgoT(), err)
// Wait for the subscription to begin upgrading to csvB
subscription, err = fetchSubscription(crc, testNamespace, subscriptionName, subscriptionStateUpgradePendingChecker)
require.NoError(GinkgoT(), err)
// Fetch existing csvB installPlan
fetchedInstallPlan, err = fetchInstallPlan(GinkgoT(), crc, subscription.Status.InstallPlanRef.Name, requiresApprovalChecker)
require.NoError(GinkgoT(), err)
require.Equal(GinkgoT(), ip2.GetName(), subscription.Status.InstallPlanRef.Name, "expected new installplan is the same with pre-exising one")
// Approve the installplan and wait for csvB to be installed
fetchedInstallPlan.Spec.Approved = true
_, err = crc.OperatorsV1alpha1().InstallPlans(testNamespace).Update(context.Background(), fetchedInstallPlan, metav1.UpdateOptions{})
require.NoError(GinkgoT(), err)
// Wait for csvB to be installed
_, err = awaitCSV(GinkgoT(), crc, testNamespace, csvB.GetName(), csvSucceededChecker)
require.NoError(GinkgoT(), err)
})
Describe("puppeting CatalogSource health status", func() {
var (
c operatorclient.ClientInterface
crc versioned.Interface
getOpts metav1.GetOptions
deleteOpts *metav1.DeleteOptions
)
BeforeEach(func() {
c = newKubeClient()
crc = newCRClient()
getOpts = metav1.GetOptions{}
deleteOpts = &metav1.DeleteOptions{}
})
AfterEach(func() {
err := crc.OperatorsV1alpha1().Subscriptions(testNamespace).DeleteCollection(context.Background(), metav1.DeleteOptions{}, metav1.ListOptions{})
Expect(err).NotTo(HaveOccurred())
})
When("missing target catalog", func() {
// TestSubscriptionStatusMissingTargetCatalogSource ensures that a Subscription has the appropriate status condition when
// its target catalog is missing.
//
// Steps:
// 1. Generate an initial CatalogSource in the target namespace
// 2. Generate Subscription, "sub", targetting non-existent CatalogSource, "missing"
// 3. Wait for sub status to show SubscriptionCatalogSourcesUnhealthy with status True, reason CatalogSourcesUpdated, and appropriate missing message
// 4. Update sub's spec to target the "mysubscription"
// 5. Wait for sub's status to show SubscriptionCatalogSourcesUnhealthy with status False, reason AllCatalogSourcesHealthy, and reason "all available catalogsources are healthy"
// 6. Wait for sub to succeed
It("should surface the missing catalog", func() {
err := initCatalog(GinkgoT(), c, crc)
Expect(err).NotTo(HaveOccurred())
missingName := "missing"
cleanup := createSubscriptionForCatalog(crc, testNamespace, testSubscriptionName, missingName, testPackageName, betaChannel, "", v1alpha1.ApprovalAutomatic)
defer cleanup()
By("detecting its absence")
sub, err := fetchSubscription(crc, testNamespace, testSubscriptionName, subscriptionHasCondition(v1alpha1.SubscriptionCatalogSourcesUnhealthy, corev1.ConditionTrue, v1alpha1.UnhealthyCatalogSourceFound, fmt.Sprintf("targeted catalogsource %s/%s missing", testNamespace, missingName)))
Expect(err).NotTo(HaveOccurred())
Expect(sub).ToNot(BeNil())
// Update sub to target an existing CatalogSource
sub.Spec.CatalogSource = catalogSourceName
_, err = crc.OperatorsV1alpha1().Subscriptions(testNamespace).Update(context.Background(), sub, metav1.UpdateOptions{})
Expect(err).NotTo(HaveOccurred())
// Wait for SubscriptionCatalogSourcesUnhealthy to be false
By("detecting a new existing target")
_, err = fetchSubscription(crc, testNamespace, testSubscriptionName, subscriptionHasCondition(v1alpha1.SubscriptionCatalogSourcesUnhealthy, corev1.ConditionFalse, v1alpha1.AllCatalogSourcesHealthy, "all available catalogsources are healthy"))
Expect(err).NotTo(HaveOccurred())
// Wait for success
_, err = fetchSubscription(crc, testNamespace, testSubscriptionName, subscriptionStateAtLatestChecker)
Expect(err).NotTo(HaveOccurred())
})
})
When("the target catalog's sourceType", func() {
Context("is unknown", func() {
It("should surface catalog health", func() {
cs := &v1alpha1.CatalogSource{
TypeMeta: metav1.TypeMeta{
Kind: v1alpha1.CatalogSourceKind,
APIVersion: v1alpha1.CatalogSourceCRDAPIVersion,
},
ObjectMeta: metav1.ObjectMeta{
Name: "cs",
},
Spec: v1alpha1.CatalogSourceSpec{
SourceType: "goose",
},
}
var err error
cs, err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Create(context.Background(), cs, metav1.CreateOptions{})
defer func() {
err = crc.OperatorsV1alpha1().CatalogSources(cs.GetNamespace()).Delete(context.Background(), cs.GetName(), *deleteOpts)
Expect(err).ToNot(HaveOccurred())
}()
subName := genName("sub-")
cleanup := createSubscriptionForCatalog(
crc,
cs.GetNamespace(),
subName,
cs.GetName(),
testPackageName,
betaChannel,
"",
v1alpha1.ApprovalManual,
)
defer cleanup()
var sub *v1alpha1.Subscription
sub, err = fetchSubscription(
crc,
cs.GetNamespace(),
subName,
subscriptionHasCondition(
v1alpha1.SubscriptionCatalogSourcesUnhealthy,
corev1.ConditionTrue,
v1alpha1.UnhealthyCatalogSourceFound,
fmt.Sprintf("targeted catalogsource %s/%s unhealthy", cs.GetNamespace(), cs.GetName()),
),
)
Expect(err).NotTo(HaveOccurred())
Expect(sub).ToNot(BeNil())
// Get the latest CatalogSource
cs, err = crc.OperatorsV1alpha1().CatalogSources(cs.GetNamespace()).Get(context.Background(), cs.GetName(), getOpts)
Expect(err).NotTo(HaveOccurred())
Expect(cs).ToNot(BeNil())
})
})
Context("is grpc and its spec is missing the address and image fields", func() {
It("should surface catalog health", func() {
// Create a CatalogSource pointing to the grpc pod
cs := &v1alpha1.CatalogSource{
TypeMeta: metav1.TypeMeta{
Kind: v1alpha1.CatalogSourceKind,
APIVersion: v1alpha1.CatalogSourceCRDAPIVersion,
},
ObjectMeta: metav1.ObjectMeta{
Name: genName("cs-"),
Namespace: testNamespace,
},
Spec: v1alpha1.CatalogSourceSpec{
SourceType: v1alpha1.SourceTypeGrpc,
},
}
var err error
cs, err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Create(context.Background(), cs, metav1.CreateOptions{})
defer func() {
err = crc.OperatorsV1alpha1().CatalogSources(cs.GetNamespace()).Delete(context.Background(), cs.GetName(), *deleteOpts)
Expect(err).ToNot(HaveOccurred())
}()
subName := genName("sub-")
cleanup := createSubscriptionForCatalog(
crc,
cs.GetNamespace(),
subName,
cs.GetName(),
testPackageName,
betaChannel,
"",
v1alpha1.ApprovalManual,
)
defer cleanup()
var sub *v1alpha1.Subscription
sub, err = fetchSubscription(
crc,
cs.GetNamespace(),
subName,
subscriptionHasCondition(
v1alpha1.SubscriptionCatalogSourcesUnhealthy,
corev1.ConditionTrue,
v1alpha1.UnhealthyCatalogSourceFound,
fmt.Sprintf("targeted catalogsource %s/%s unhealthy", cs.GetNamespace(), cs.GetName()),
),
)
Expect(err).NotTo(HaveOccurred())
Expect(sub).ToNot(BeNil())
})
})
Context("is internal and its spec is missing the configmap reference", func() {
It("should surface catalog health", func() {
cs := &v1alpha1.CatalogSource{
TypeMeta: metav1.TypeMeta{
Kind: v1alpha1.CatalogSourceKind,
APIVersion: v1alpha1.CatalogSourceCRDAPIVersion,
},
ObjectMeta: metav1.ObjectMeta{
Name: genName("cs-"),
Namespace: testNamespace,
},
Spec: v1alpha1.CatalogSourceSpec{
SourceType: v1alpha1.SourceTypeInternal,
},
}
var err error
cs, err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Create(context.Background(), cs, metav1.CreateOptions{})
defer func() {
err = crc.OperatorsV1alpha1().CatalogSources(cs.GetNamespace()).Delete(context.Background(), cs.GetName(), *deleteOpts)
Expect(err).ToNot(HaveOccurred())
}()
subName := genName("sub-")
cleanup := createSubscriptionForCatalog(
crc,
cs.GetNamespace(),
subName,
cs.GetName(),
testPackageName,
betaChannel,
"",
v1alpha1.ApprovalManual,
)
defer cleanup()
var sub *v1alpha1.Subscription
sub, err = fetchSubscription(
crc,
cs.GetNamespace(),
subName,
subscriptionHasCondition(
v1alpha1.SubscriptionCatalogSourcesUnhealthy,
corev1.ConditionTrue,
v1alpha1.UnhealthyCatalogSourceFound,
fmt.Sprintf("targeted catalogsource %s/%s unhealthy", cs.GetNamespace(), cs.GetName()),
),
)
Expect(err).NotTo(HaveOccurred())
Expect(sub).ToNot(BeNil())
})
})
Context("is configmap and its spec is missing the configmap reference", func() {
It("should surface catalog health", func() {
cs := &v1alpha1.CatalogSource{
TypeMeta: metav1.TypeMeta{
Kind: v1alpha1.CatalogSourceKind,
APIVersion: v1alpha1.CatalogSourceCRDAPIVersion,
},
ObjectMeta: metav1.ObjectMeta{
Name: genName("cs-"),
Namespace: testNamespace,
},
Spec: v1alpha1.CatalogSourceSpec{
SourceType: v1alpha1.SourceTypeInternal,
},
}
var err error
cs, err = crc.OperatorsV1alpha1().CatalogSources(testNamespace).Create(context.Background(), cs, metav1.CreateOptions{})
defer func() {
err = crc.OperatorsV1alpha1().CatalogSources(cs.GetNamespace()).Delete(context.Background(), cs.GetName(), *deleteOpts)
Expect(err).ToNot(HaveOccurred())
}()
subName := genName("sub-")
cleanup := createSubscriptionForCatalog(
crc,
cs.GetNamespace(),
subName,
cs.GetName(),
testPackageName,
betaChannel,
"",
v1alpha1.ApprovalAutomatic,
)
defer cleanup()
var sub *v1alpha1.Subscription
sub, err = fetchSubscription(
crc,
cs.GetNamespace(),
subName,
subscriptionHasCondition(
v1alpha1.SubscriptionCatalogSourcesUnhealthy,
corev1.ConditionTrue,
v1alpha1.UnhealthyCatalogSourceFound,
fmt.Sprintf("targeted catalogsource %s/%s unhealthy", cs.GetNamespace(), cs.GetName()),
),
)
Expect(err).NotTo(HaveOccurred())
Expect(sub).ToNot(BeNil())
})
})
})
})
// TestSubscriptionInstallPlanStatus ensures that a Subscription has the appropriate status conditions for possible referenced
// InstallPlan states.
//
// Steps:
// 1. Create namespace, ns
// 2. Create CatalogSource, cs, in ns
// 3. Create OperatorGroup, og, in ns selecting its own namespace
// 4. Create Subscription to a package of cs in ns, sub
// 5. Wait for the package from sub to install successfully with no remaining InstallPlan status conditions
// 6. Store conditions for later comparision
// 7. Get the InstallPlan
// 8. Set the InstallPlan's approval mode to Manual
// 9. Set the InstallPlan's phase to None
// 10. Wait for sub to have status condition SubscriptionInstallPlanPending true and reason InstallPlanNotYetReconciled
// 11. Get the latest IntallPlan and set the phase to InstallPlanPhaseRequiresApproval
// 12. Wait for sub to have status condition SubscriptionInstallPlanPending true and reason RequiresApproval
// 13. Get the latest InstallPlan and set the phase to InstallPlanPhaseInstalling
// 14. Wait for sub to have status condition SubscriptionInstallPlanPending true and reason Installing
// 15. Get the latest InstallPlan and set the phase to InstallPlanPhaseFailed and remove all status conditions
// 16. Wait for sub to have status condition SubscriptionInstallPlanFailed true and reason InstallPlanFailed
// 17. Get the latest InstallPlan and set status condition of type Installed to false with reason InstallComponentFailed
// 18. Wait for sub to have status condition SubscriptionInstallPlanFailed true and reason InstallComponentFailed
// 19. Delete the referenced InstallPlan
// 20. Wait for sub to have status condition SubscriptionInstallPlanMissing true
// 21. Ensure original non-InstallPlan status conditions remain after InstallPlan transitions
It("can reconcile InstallPlan status", func() {
c := newKubeClient()
crc := newCRClient()
// Create namespace ns
ns := &corev1.Namespace{
ObjectMeta: metav1.ObjectMeta{
Name: genName("ns-"),
},
}
Eventually(func() error {
_, err := c.KubernetesInterface().CoreV1().Namespaces().Create(context.Background(), ns, metav1.CreateOptions{})
return err
}).Should(Succeed())
defer func() {
Eventually(func() error {
return c.KubernetesInterface().CoreV1().Namespaces().Delete(context.Background(), ns.GetName(), metav1.DeleteOptions{})
}).Should(Succeed())
}()
// Create CatalogSource, cs, in ns
pkgName := genName("pkg-")
channelName := genName("channel-")
crd := newCRD(pkgName)
csv := newCSV(pkgName, ns.GetName(), "", semver.MustParse("0.1.0"), []apiextensions.CustomResourceDefinition{crd}, nil, nil)
manifests := []registry.PackageManifest{
{
PackageName: pkgName,
Channels: []registry.PackageChannel{
{Name: channelName, CurrentCSVName: csv.GetName()},
},
DefaultChannelName: channelName,
},
}
catalogName := genName("catalog-")
_, cleanupCatalogSource := createInternalCatalogSource(c, crc, catalogName, ns.GetName(), manifests, []apiextensions.CustomResourceDefinition{crd}, []v1alpha1.ClusterServiceVersion{csv})
defer cleanupCatalogSource()
_, err := fetchCatalogSourceOnStatus(crc, catalogName, ns.GetName(), catalogSourceRegistryPodSynced)
Expect(err).ToNot(HaveOccurred())
// Create OperatorGroup, og, in ns selecting its own namespace
og := newOperatorGroup(ns.GetName(), genName("og-"), nil, nil, []string{ns.GetName()}, false)
Eventually(func() error {
_, err = crc.OperatorsV1().OperatorGroups(og.GetNamespace()).Create(context.Background(), og, metav1.CreateOptions{})
return err
}).Should(Succeed())
// Create Subscription to a package of cs in ns, sub
subName := genName("sub-")
defer createSubscriptionForCatalog(crc, ns.GetName(), subName, catalogName, pkgName, channelName, pkgName, v1alpha1.ApprovalAutomatic)()
// Wait for the package from sub to install successfully with no remaining InstallPlan status conditions
sub, err := fetchSubscription(crc, ns.GetName(), subName, func(s *v1alpha1.Subscription) bool {
for _, cond := range s.Status.Conditions {
switch cond.Type {
case v1alpha1.SubscriptionInstallPlanMissing, v1alpha1.SubscriptionInstallPlanPending, v1alpha1.SubscriptionInstallPlanFailed:
return false
}
}
return subscriptionStateAtLatestChecker(s)
})
Expect(err).ToNot(HaveOccurred())
Expect(sub).ToNot(BeNil())
// Store conditions for later comparision
conds := sub.Status.Conditions
ref := sub.Status.InstallPlanRef
Expect(ref).ToNot(BeNil())
plan := &v1alpha1.InstallPlan{}
plan.SetNamespace(ref.Namespace)
plan.SetName(ref.Name)
// Set the InstallPlan's approval mode to Manual
Eventually(Apply(plan, func(p *v1alpha1.InstallPlan) error {
p.Spec.Approval = v1alpha1.ApprovalManual
p.Spec.Approved = false
return nil
})).Should(Succeed())
// Set the InstallPlan's phase to None
Eventually(Apply(plan, func(p *v1alpha1.InstallPlan) error {
p.Status.Phase = v1alpha1.InstallPlanPhaseNone
return nil
})).Should(Succeed())
// Wait for sub to have status condition SubscriptionInstallPlanPending true and reason InstallPlanNotYetReconciled
sub, err = fetchSubscription(crc, ns.GetName(), subName, func(s *v1alpha1.Subscription) bool {
cond := s.Status.GetCondition(v1alpha1.SubscriptionInstallPlanPending)
return cond.Status == corev1.ConditionTrue && cond.Reason == v1alpha1.InstallPlanNotYetReconciled