-
Notifications
You must be signed in to change notification settings - Fork 569
fix: add OpenAPIModelName for PackageManifest to fix oc explain #3755
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
base: master
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
| // OpenAPIModelName returns the OpenAPI model name for this type. | ||
| // This is used by openapi-gen to register the GVK extension. | ||
| // The format matches what k8s.io/apimachinery/pkg/runtime.Scheme.ToOpenAPIDefinitionName would generate. | ||
| func (PackageManifestList) OpenAPIModelName() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason this is only done for these two resources? I see k8s now has functions as well, with similar returns, but many of our types are still using the domain/path model, rather than the reverse.domain.path model
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question! The reason this is only done for PackageManifest and PackageManifestList is that these are the only resources served by the package-server aggregated API, rather than being actual CRDs. All other OLM types (Subscription, ClusterServiceVersion, CatalogSource, etc.) are true CRDs under operators.coreos.com. For CRDs, Kubernetes automatically handles the OpenAPI schema generation and adds the x-kubernetes-group-version-kind extension through its CRD controller.
jiazha-mac:~ jiazha$ oc get apiservice |grep package
v1.packages.operators.coreos.com openshift-operator-lifecycle-manager/packageserver-service True 65m
jiazha-mac:~ jiazha$ oc get crd |grep operators.coreos.com
catalogsources.operators.coreos.com 2026-02-03T02:47:35Z
clusterserviceversions.operators.coreos.com 2026-02-03T02:47:37Z
installplans.operators.coreos.com 2026-02-03T02:47:39Z
olmconfigs.operators.coreos.com 2026-02-03T02:47:43Z
operatorconditions.operators.coreos.com 2026-02-03T02:47:45Z
operatorgroups.operators.coreos.com 2026-02-03T02:47:46Z
operators.operators.coreos.com 2026-02-03T02:47:47Z
subscriptions.operators.coreos.com 2026-02-03T02:47:57ZRegarding the reverse.domain.path format (com.github.operator-framework...) - this matches what k8s.io/apimachinery/pkg/runtime.Scheme.ToOpenAPIDefinitionName() generates, which is required for the name lookup to succeed. The other OLM types don't need this because the CRD mechanism handles it automatically.
Why did the test start failing now?
After upgrading to kube-openapi v0.0.0-20250910181357 in PR #3707, the mix of types with and without OpenAPIModelName() caused the model name lookup to fail for PackageManifest, preventing the GVK extension from being added to its OpenAPI schema.
|
/lgtm |
Description of the change:
The
oc explain packagemanifests --api-version=packages.operators.coreos.com/v1command was failing because:Motivation for the change:
To address openshift/operator-framework-olm#1208 (comment)
{ fail [github.com/openshift/origin/test/extended/cli/explain.go:608]: Unexpected error: <*errors.errorString | 0xc0015b8140>: Error running oc --namespace=e2e-test-oc-explain-2xzmz --kubeconfig=/tmp/configfile168747619 explain packagemanifests --api-version=packages.operators.coreos.com/v1: StdOut> GROUP: packages.operators.coreos.com KIND: PackageManifest VERSION: v1 StdErr> error: GVK map[group:packages.operators.coreos.com kind:PackageManifest version:v1] not found in OpenAPI schema exit status 1 : error: GVK map[group:packages.operators.coreos.com kind:PackageManifest version:v1] not found in OpenAPI schema { s: "Error running oc --namespace=e2e-test-oc-explain-2xzmz --kubeconfig=/tmp/configfile168747619 explain packagemanifests --api-version=packages.operators.coreos.com/v1:\nStdOut>\nGROUP: packages.operators.coreos.com\nKIND: PackageManifest\nVERSION: v1\nStdErr>\nerror: GVK map[group:packages.operators.coreos.com kind:PackageManifest version:v1] not found in OpenAPI schema\nexit status 1\n: error: GVK map[group:packages.operators.coreos.com kind:PackageManifest version:v1] not found in OpenAPI schema", }Architectural changes:
With this fix:
Testing remarks:
Reviewer Checklist
/doc[FLAKE]are truly flaky and have an issueAssisted-By: Claude-Code