Skip to content

test/e2e: Wrap catalog template image adjustment test in eventually blocks #2397

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions test/e2e/catalog_e2e_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// +build !bare
//go:build !bare
// +build !bare

package e2e

Expand Down Expand Up @@ -1056,27 +1057,31 @@ var _ = Describe("Catalog represents a store of bundles which OLM can use to ins
}

By("creating a catalog source")
source, err := crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.TODO(), source, metav1.CreateOptions{})
Expect(err).ToNot(HaveOccurred())

By("update the catalog source with template annotation")

source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(HaveOccurred(), "error getting catalog source")

// create an annotation using the kube templates
var err error
Eventually(func() error {
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Create(context.TODO(), source, metav1.CreateOptions{})
return err
}).Should(Succeed())

source.SetAnnotations(map[string]string{catalogsource.CatalogImageTemplateAnnotation: fmt.Sprintf("quay.io/olmtest/catsrc-update-test:%s.%s.%s", catalogsource.TemplKubeMajorV, catalogsource.TemplKubeMinorV, catalogsource.TemplKubePatchV)})
By("update the catalog source with template annotation")

// Update the catalog image
Eventually(func() error {
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
if err != nil {
return err
}
// create an annotation using the kube templates
source.SetAnnotations(map[string]string{catalogsource.CatalogImageTemplateAnnotation: fmt.Sprintf("quay.io/olmtest/catsrc-update-test:%s.%s.%s", catalogsource.TemplKubeMajorV, catalogsource.TemplKubeMinorV, catalogsource.TemplKubePatchV)})

Comment on lines +1071 to +1077
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revisiting this as it's been sitting for a while: poking at this locally, it looks like the real issue is we're overwriting this shared source variable in the GET and UPDATE calls. Speculatively, it looks like anytime the update call fails, the source variable will be essentially nil:

catalogsource info: catalog-9t8pz/openshift-operators
catalogsource info: &v1alpha1.CatalogSource{TypeMeta:v1.TypeMeta{Kind:"", APIVersion:""}, ObjectMeta:v1.ObjectMeta{Name:"catalog-9t8pz", GenerateName:"", Namespace:"openshift-operators", SelfLink:"", UID:"1151883a-39f2-44a0-9d42-8c2e28505b47", ResourceVersion:"32421", Generation:1, CreationTimestamp:v1.Time{Time:time.Time{wall:0x0, ext:63772780625, loc:(*time.Location)(0x46b9aa0)}}, DeletionTimestamp:(*v1.Time)(nil), DeletionGracePeriodSeconds:(*int64)(nil), Labels:map[string]string{"olm.catalogSource":"catalog-9t8pz"}, Annotations:map[string]string(nil), OwnerReferences:[]v1.OwnerReference(nil), Finalizers:[]string(nil), ClusterName:"", ManagedFields:[]v1.ManagedFieldsEntry{v1.ManagedFieldsEntry{Manager:"e2e.test", Operation:"Update", APIVersion:"operators.coreos.com/v1alpha1", Time:(*v1.Time)(0xc0001be498), FieldsType:"FieldsV1", FieldsV1:(*v1.FieldsV1)(0xc0001be480), Subresource:""}}}, Spec:v1alpha1.CatalogSourceSpec{SourceType:"grpc", Priority:0, ConfigMap:"", Address:"", Image:"quay.io/olmtest/catsrc-update-test:old", UpdateStrategy:(*v1alpha1.UpdateStrategy)(nil), Secrets:[]string(nil), DisplayName:"", Description:"", Publisher:"", Icon:v1alpha1.Icon{Data:"", MediaType:""}}, Status:v1alpha1.CatalogSourceStatus{Message:"", Reason:"", LatestImageRegistryPoll:(*v1.Time)(nil), ConfigMapResource:(*v1alpha1.ConfigMapResourceReference)(nil), RegistryServiceStatus:(*v1alpha1.RegistryServiceStatus)(nil), GRPCConnectionState:(*v1alpha1.GRPCConnectionState)(nil), Conditions:[]v1.Condition(nil)}}
catalogsource info: /
catalogsource info: /
...

One solution is to just avoid overwriting this source resource by suppressing the variable returned from the update call. I tested out this variation locally and I wasn't able to reproduce this issue anymore.

source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Update(context.TODO(), source, metav1.UpdateOptions{})
return err
}).Should(Succeed())

// wait for status condition to show up
Eventually(func() (bool, error) {
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), sourceName, metav1.GetOptions{})
source, err = crc.OperatorsV1alpha1().CatalogSources(source.GetNamespace()).Get(context.TODO(), source.GetName(), metav1.GetOptions{})
if err != nil {
return false, err
}
Expand Down