@@ -3145,162 +3145,6 @@ var _ = Describe("Install Plan", func() {
3145
3145
require .Equal (GinkgoT (), 1 , len (ips .Items ), "If this test fails it should be taken seriously and not treated as a flake. \n %v" , ips .Items )
3146
3146
})
3147
3147
3148
- It ("should fail an InstallPlan when no OperatorGroup is present" , func () {
3149
-
3150
- ns := & corev1.Namespace {}
3151
- ns .SetName (genName ("ns-" ))
3152
-
3153
- c := newKubeClient ()
3154
- crc := newCRClient ()
3155
-
3156
- // Create a namespace
3157
- ns , err := c .KubernetesInterface ().CoreV1 ().Namespaces ().Create (context .TODO (), ns , metav1.CreateOptions {})
3158
- Expect (err ).NotTo (HaveOccurred ())
3159
-
3160
- deleteOpts := & metav1.DeleteOptions {}
3161
- defer func () {
3162
- err := c .KubernetesInterface ().CoreV1 ().Namespaces ().Delete (context .TODO (), ns .GetName (), * deleteOpts )
3163
- Expect (err ).NotTo (HaveOccurred ())
3164
- }()
3165
-
3166
- // Create InstallPlan
3167
- installPlanName := "ip"
3168
- ip := newInstallPlanWithDummySteps (installPlanName , ns .GetName (), operatorsv1alpha1 .InstallPlanPhaseNone )
3169
- outIP , err := crc .OperatorsV1alpha1 ().InstallPlans (ns .GetName ()).Create (context .TODO (), ip , metav1.CreateOptions {})
3170
- Expect (err ).NotTo (HaveOccurred ())
3171
- Expect (outIP ).NotTo (BeNil ())
3172
-
3173
- // The status gets ignored on create so we need to update it else the InstallPlan sync ignores
3174
- // InstallPlans without any steps or bundle lookups
3175
- outIP .Status = ip .Status
3176
- _ , err = crc .OperatorsV1alpha1 ().InstallPlans (ns .GetName ()).UpdateStatus (context .TODO (), outIP , metav1.UpdateOptions {})
3177
- Expect (err ).NotTo (HaveOccurred ())
3178
-
3179
- fetchedInstallPlan , err := fetchInstallPlanWithNamespace (GinkgoT (), crc , installPlanName , ns .GetName (), buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseFailed ))
3180
- Expect (err ).NotTo (HaveOccurred ())
3181
- Expect (fetchedInstallPlan ).NotTo (BeNil ())
3182
- ctx .Ctx ().Logf (fmt .Sprintf ("Install plan %s fetched with phase %s" , fetchedInstallPlan .GetName (), fetchedInstallPlan .Status .Phase ))
3183
- ctx .Ctx ().Logf (fmt .Sprintf ("Install plan %s fetched with conditions %+v" , fetchedInstallPlan .GetName (), fetchedInstallPlan .Status .Conditions ))
3184
- })
3185
-
3186
- It ("should fail an InstallPlan when multiple OperatorGroups are present" , func () {
3187
-
3188
- ns := & corev1.Namespace {}
3189
- ns .SetName (genName ("ns-" ))
3190
-
3191
- c := newKubeClient ()
3192
- crc := newCRClient ()
3193
-
3194
- // Create a namespace
3195
- ns , err := c .KubernetesInterface ().CoreV1 ().Namespaces ().Create (context .TODO (), ns , metav1.CreateOptions {})
3196
- Expect (err ).NotTo (HaveOccurred ())
3197
- deleteOpts := & metav1.DeleteOptions {}
3198
- defer func () {
3199
- err = c .KubernetesInterface ().CoreV1 ().Namespaces ().Delete (context .TODO (), ns .GetName (), * deleteOpts )
3200
- Expect (err ).ToNot (HaveOccurred ())
3201
- }()
3202
-
3203
- // Create 2 operatorgroups in the same namespace
3204
- og1 := & operatorsv1.OperatorGroup {
3205
- ObjectMeta : metav1.ObjectMeta {
3206
- Name : "og1" ,
3207
- },
3208
- Spec : operatorsv1.OperatorGroupSpec {
3209
- TargetNamespaces : []string {ns .GetName ()},
3210
- },
3211
- }
3212
- og2 := & operatorsv1.OperatorGroup {
3213
- ObjectMeta : metav1.ObjectMeta {
3214
- Name : "og2" ,
3215
- },
3216
- Spec : operatorsv1.OperatorGroupSpec {
3217
- TargetNamespaces : []string {ns .GetName ()},
3218
- },
3219
- }
3220
- _ , err = crc .OperatorsV1 ().OperatorGroups (ns .GetName ()).Create (context .TODO (), og1 , metav1.CreateOptions {})
3221
- Expect (err ).ToNot (HaveOccurred ())
3222
- _ , err = crc .OperatorsV1 ().OperatorGroups (ns .GetName ()).Create (context .TODO (), og2 , metav1.CreateOptions {})
3223
- Expect (err ).ToNot (HaveOccurred ())
3224
-
3225
- installPlanName := "ip"
3226
- ip := newInstallPlanWithDummySteps (installPlanName , ns .GetName (), operatorsv1alpha1 .InstallPlanPhaseNone )
3227
- outIP , err := crc .OperatorsV1alpha1 ().InstallPlans (ns .GetName ()).Create (context .TODO (), ip , metav1.CreateOptions {})
3228
- Expect (err ).NotTo (HaveOccurred ())
3229
- Expect (outIP ).NotTo (BeNil ())
3230
-
3231
- // The status gets ignored on create so we need to update it else the InstallPlan sync ignores
3232
- // InstallPlans without any steps or bundle lookups
3233
- outIP .Status = ip .Status
3234
- _ , err = crc .OperatorsV1alpha1 ().InstallPlans (ns .GetName ()).UpdateStatus (context .TODO (), outIP , metav1.UpdateOptions {})
3235
- Expect (err ).NotTo (HaveOccurred ())
3236
-
3237
- fetchedInstallPlan , err := fetchInstallPlanWithNamespace (GinkgoT (), crc , installPlanName , ns .GetName (), buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseFailed ))
3238
- Expect (err ).ToNot (HaveOccurred ())
3239
- Expect (fetchedInstallPlan ).NotTo (BeNil ())
3240
- ctx .Ctx ().Logf (fmt .Sprintf ("Install plan %s fetched with status %s" , fetchedInstallPlan .GetName (), fetchedInstallPlan .Status .Phase ))
3241
- ctx .Ctx ().Logf (fmt .Sprintf ("Install plan %s fetched with conditions %+v" , fetchedInstallPlan .GetName (), fetchedInstallPlan .Status .Conditions ))
3242
- })
3243
-
3244
- It ("should fail an InstallPlan when an OperatorGroup specifies an unsynced ServiceAccount with no ServiceAccountRef" , func () {
3245
-
3246
- ns := & corev1.Namespace {}
3247
- ns .SetName (genName ("ns-" ))
3248
-
3249
- c := newKubeClient ()
3250
- crc := newCRClient ()
3251
-
3252
- // Create a namespace
3253
- ns , err := c .KubernetesInterface ().CoreV1 ().Namespaces ().Create (context .TODO (), ns , metav1.CreateOptions {})
3254
- Expect (err ).NotTo (HaveOccurred ())
3255
- deleteOpts := & metav1.DeleteOptions {}
3256
- defer func () {
3257
- err = c .KubernetesInterface ().CoreV1 ().Namespaces ().Delete (context .TODO (), ns .GetName (), * deleteOpts )
3258
- Expect (err ).ToNot (HaveOccurred ())
3259
- }()
3260
-
3261
- // OperatorGroup with serviceaccount specified
3262
- og := & operatorsv1.OperatorGroup {
3263
- ObjectMeta : metav1.ObjectMeta {
3264
- Name : "og" ,
3265
- },
3266
- Spec : operatorsv1.OperatorGroupSpec {
3267
- TargetNamespaces : []string {ns .GetName ()},
3268
- ServiceAccountName : "foobar" ,
3269
- },
3270
- }
3271
- og , err = crc .OperatorsV1 ().OperatorGroups (ns .GetName ()).Create (context .TODO (), og , metav1.CreateOptions {})
3272
- Expect (err ).ToNot (HaveOccurred ())
3273
- Expect (og ).NotTo (BeNil ())
3274
-
3275
- // Update OperatorGroup status with namespace but no service account reference
3276
- now := metav1 .Now ()
3277
- og .Status = operatorsv1.OperatorGroupStatus {
3278
- Namespaces : []string {ns .GetName ()},
3279
- ServiceAccountRef : nil ,
3280
- LastUpdated : & now ,
3281
- }
3282
- _ , err = crc .OperatorsV1 ().OperatorGroups (ns .GetName ()).UpdateStatus (context .TODO (), og , metav1.UpdateOptions {})
3283
- Expect (err ).ToNot (HaveOccurred ())
3284
-
3285
- installPlanName := "ip"
3286
- ip := newInstallPlanWithDummySteps (installPlanName , ns .GetName (), operatorsv1alpha1 .InstallPlanPhaseNone )
3287
- outIP , err := crc .OperatorsV1alpha1 ().InstallPlans (ns .GetName ()).Create (context .TODO (), ip , metav1.CreateOptions {})
3288
- Expect (err ).NotTo (HaveOccurred ())
3289
- Expect (outIP ).NotTo (BeNil ())
3290
-
3291
- // The status gets ignored on create so we need to update it else the InstallPlan sync ignores
3292
- // InstallPlans without any steps or bundle lookups
3293
- outIP .Status = ip .Status
3294
- _ , err = crc .OperatorsV1alpha1 ().InstallPlans (ns .GetName ()).UpdateStatus (context .TODO (), outIP , metav1.UpdateOptions {})
3295
- Expect (err ).NotTo (HaveOccurred ())
3296
-
3297
- fetchedInstallPlan , err := fetchInstallPlanWithNamespace (GinkgoT (), crc , installPlanName , ns .GetName (), buildInstallPlanPhaseCheckFunc (operatorsv1alpha1 .InstallPlanPhaseFailed ))
3298
- Expect (err ).NotTo (HaveOccurred ())
3299
- Expect (fetchedInstallPlan ).NotTo (BeNil ())
3300
- ctx .Ctx ().Logf (fmt .Sprintf ("Install plan %s fetched with status %s" , fetchedInstallPlan .GetName (), fetchedInstallPlan .Status .Phase ))
3301
- ctx .Ctx ().Logf (fmt .Sprintf ("Install plan %s fetched with conditions %+v" , fetchedInstallPlan .GetName (), fetchedInstallPlan .Status .Conditions ))
3302
- })
3303
-
3304
3148
When ("waiting on the bundle unpacking job" , func () {
3305
3149
var (
3306
3150
ns * corev1.Namespace
@@ -3345,17 +3189,6 @@ var _ = Describe("Install Plan", func() {
3345
3189
return ctx .Ctx ().Client ().Create (context .Background (), og )
3346
3190
}, timeout , interval ).Should (Succeed (), "could not create OperatorGroup" )
3347
3191
3348
- // Wait for the OperatorGroup to be synced so the InstallPlan doesn't fail due to an invalid OperatorGroup
3349
- Eventually (
3350
- func () ([]string , error ) {
3351
- err := ctx .Ctx ().Client ().Get (context .Background (), client .ObjectKeyFromObject (og ), og )
3352
- ctx .Ctx ().Logf ("Waiting for OperatorGroup(%v) to be synced with status.namespaces: %v" , og .Name , og .Status .Namespaces )
3353
- return og .Status .Namespaces , err
3354
- },
3355
- 1 * time .Minute ,
3356
- interval ,
3357
- ).Should (ContainElement (ns .GetName ()))
3358
-
3359
3192
now := metav1 .Now ()
3360
3193
ip = & operatorsv1alpha1.InstallPlan {
3361
3194
ObjectMeta : metav1.ObjectMeta {
@@ -3639,18 +3472,6 @@ var _ = Describe("Install Plan", func() {
3639
3472
_ , err = crc .OperatorsV1 ().OperatorGroups (ns .GetName ()).Create (context .TODO (), og , metav1.CreateOptions {})
3640
3473
Expect (err ).ToNot (HaveOccurred ())
3641
3474
3642
- // Wait for the OperatorGroup to be synced and have a status.ServiceAccountRef
3643
- // before moving on. Otherwise the catalog operator treats it as an invalid OperatorGroup
3644
- // and fails the InstallPlan
3645
- Eventually (func () (* corev1.ObjectReference , error ) {
3646
- outOG , err := crc .OperatorsV1 ().OperatorGroups (ns .GetName ()).Get (context .TODO (), og .Name , metav1.GetOptions {})
3647
- if err != nil {
3648
- return nil , err
3649
- }
3650
- ctx .Ctx ().Logf ("[DEBUG] Operator Group Status: %+v\n " , outOG .Status )
3651
- return outOG .Status .ServiceAccountRef , nil
3652
- }).ShouldNot (BeNil ())
3653
-
3654
3475
crd := apiextensionsv1.CustomResourceDefinition {
3655
3476
ObjectMeta : metav1.ObjectMeta {
3656
3477
Name : "ins" + ".cluster.com" ,
@@ -3895,18 +3716,6 @@ var _ = Describe("Install Plan", func() {
3895
3716
_ , err = crc .OperatorsV1 ().OperatorGroups (ns .GetName ()).Create (context .TODO (), og , metav1.CreateOptions {})
3896
3717
Expect (err ).ToNot (HaveOccurred ())
3897
3718
3898
- // Wait for the OperatorGroup to be synced and have a status.ServiceAccountRef
3899
- // before moving on. Otherwise the catalog operator treats it as an invalid OperatorGroup
3900
- // and fails the InstallPlan
3901
- Eventually (func () (* corev1.ObjectReference , error ) {
3902
- outOG , err := crc .OperatorsV1 ().OperatorGroups (ns .GetName ()).Get (context .TODO (), og .Name , metav1.GetOptions {})
3903
- if err != nil {
3904
- return nil , err
3905
- }
3906
- ctx .Ctx ().Logf ("[DEBUG] Operator Group Status: %+v\n " , outOG .Status )
3907
- return outOG .Status .ServiceAccountRef , nil
3908
- }).ShouldNot (BeNil ())
3909
-
3910
3719
By ("using the OLM client to install CRDs from the installplan and the scoped client for other resources" )
3911
3720
3912
3721
crd := apiextensionsv1.CustomResourceDefinition {
@@ -4072,7 +3881,7 @@ func validateCRDVersions(t GinkgoTInterface, c operatorclient.ClientInterface, n
4072
3881
4073
3882
func buildInstallPlanPhaseCheckFunc (phases ... operatorsv1alpha1.InstallPlanPhase ) checkInstallPlanFunc {
4074
3883
return func (fip * operatorsv1alpha1.InstallPlan ) bool {
4075
- ctx .Ctx ().Logf ("installplan is %s" , fip .Status .Phase )
3884
+ ctx .Ctx ().Logf ("installplan %v is in phase %v" , fip . GetName () , fip .Status .Phase )
4076
3885
satisfiesAny := false
4077
3886
for _ , phase := range phases {
4078
3887
satisfiesAny = satisfiesAny || fip .Status .Phase == phase
@@ -4298,34 +4107,3 @@ func newCSV(name, namespace, replaces string, version semver.Version, owned []ap
4298
4107
4299
4108
return csv
4300
4109
}
4301
-
4302
- func newInstallPlanWithDummySteps (name , namespace string , phase operatorsv1alpha1.InstallPlanPhase ) * operatorsv1alpha1.InstallPlan {
4303
- return & operatorsv1alpha1.InstallPlan {
4304
- ObjectMeta : metav1.ObjectMeta {
4305
- Name : name ,
4306
- Namespace : namespace ,
4307
- },
4308
- Spec : operatorsv1alpha1.InstallPlanSpec {
4309
- ClusterServiceVersionNames : []string {"foobar" },
4310
- Approval : operatorsv1alpha1 .ApprovalAutomatic ,
4311
- Approved : true ,
4312
- },
4313
- Status : operatorsv1alpha1.InstallPlanStatus {
4314
- CatalogSources : []string {"catalog" },
4315
- Phase : phase ,
4316
- Plan : []* operatorsv1alpha1.Step {
4317
- {
4318
- Resource : operatorsv1alpha1.StepResource {
4319
- CatalogSource : "catalog" ,
4320
- CatalogSourceNamespace : namespace ,
4321
- Group : "" ,
4322
- Version : "v1" ,
4323
- Kind : "Foo" ,
4324
- Name : "bar" ,
4325
- },
4326
- Status : operatorsv1alpha1 .StepStatusUnknown ,
4327
- },
4328
- },
4329
- },
4330
- }
4331
- }
0 commit comments