Skip to content

Conversation

@jianzhangbjz
Copy link
Member

@jianzhangbjz jianzhangbjz commented Jan 29, 2026

Description of the change:

The oc explain packagemanifests --api-version=packages.operators.coreos.com/v1 command was failing because:

  1. The OpenAPI schema didn't have the x-kubernetes-group-version-kind extension
  2. The NewDefinitionNamer couldn't find the matching model name in the OpenAPI definitions map

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:

  1. ToOpenAPIDefinitionName() calls OpenAPIModelName() which returns the canonical name
  2. The generated OpenAPI uses the same name via v1.PackageManifest{}.OpenAPIModelName()
  3. NewDefinitionNamer finds the match and adds the GVK extension
  4. oc explain can now find the schema by GVK

Testing remarks:

Reviewer Checklist

  • Implementation matches the proposed design, or proposal is updated to match implementation
  • Sufficient unit test coverage
  • Sufficient end-to-end test coverage
  • Bug fixes are accompanied by regression test(s)
  • e2e tests and flake fixes are accompanied evidence of flake testing, e.g. executing the test 100(0) times
  • tech debt/todo is accompanied by issue link(s) in comments in the surrounding code
  • Tests are comprehensible, e.g. Ginkgo DSL is being used appropriately
  • Docs updated or added to /doc
  • Commit messages sensible and descriptive
  • Tests marked as [FLAKE] are truly flaky and have an issue
  • Code is properly formatted

Assisted-By: Claude-Code

@openshift-ci openshift-ci bot requested review from anik120 and kevinrizza January 29, 2026 09:58
@openshift-ci
Copy link

openshift-ci bot commented Jan 29, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign oceanc80 for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

// 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 {
Copy link
Contributor

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

Copy link
Member Author

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:57Z

Regarding 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.

@tmshort
Copy link
Contributor

tmshort commented Feb 3, 2026

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants