Skip to content
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

DNM: investigation #3442

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
24 changes: 23 additions & 1 deletion pkg/controller/operators/catalog/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}))
Expand All @@ -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
}
Expand Down