diff --git a/pkg/controller/operators/catalog/operator.go b/pkg/controller/operators/catalog/operator.go index 10d3187096..d15e67c582 100644 --- a/pkg/controller/operators/catalog/operator.go +++ b/pkg/controller/operators/catalog/operator.go @@ -2242,6 +2242,26 @@ func validateExistingCRs(dynamicClient dynamic.Interface, gr schema.GroupResourc return fmt.Errorf("error creating validator for schema version %s: %s", version, err) } gvr := schema.GroupVersionResource{Group: gr.Group, Version: version, Resource: gr.Resource} + + results := make(map[string]*unstructured.Unstructured) + + crList, err := dynamicClient.Resource(gvr).List(context.TODO(), metav1.ListOptions{}) + if err != nil { + return fmt.Errorf("error listing resources in GroupVersionResource %#v: %s", gvr, err) + } + for _, cr := range crList.Items { + var namespacedName string + if cr.GetNamespace() == "" { + namespacedName = cr.GetName() + } else { + namespacedName = fmt.Sprintf("%s/%s", cr.GetNamespace(), cr.GetName()) + } + if err := validation.ValidateCustomResource(field.NewPath(""), &cr, validator).ToAggregate(); err != nil { + return validationError{fmt.Errorf("error validating %s %q: updated validation is too restrictive: %v", cr.GroupVersionKind(), namespacedName, err)} + } + results[namespacedName] = &cr + } + pager := pager.New(pager.SimplePageFunc(func(opts metav1.ListOptions) (runtime.Object, error) { return dynamicClient.Resource(gvr).List(context.TODO(), opts) })) @@ -2257,7 +2277,9 @@ func validateExistingCRs(dynamicClient dynamic.Interface, gr schema.GroupResourc } else { namespacedName = fmt.Sprintf("%s/%s", cr.GetNamespace(), cr.GetName()) } - return validationError{fmt.Errorf("error validating %s %q: updated validation is too restrictive: %v", cr.GroupVersionKind(), namespacedName, err)} + return validationError{fmt.Errorf("error validating %s %q: simple list succeeded where paginated failed:\nsimple:\n%#v\npaginated:\n%#v\n %v", + gvr, namespacedName, results[namespacedName], obj, err)} + // return validationError{fmt.Errorf("error validating %s %q: updated validation is too restrictive: %v", cr.GroupVersionKind(), namespacedName, err)} } return nil }