Skip to content

fix: add OpenAPIModelName for all types referenced in OpenAPI schemas#476

Closed
jianzhangbjz wants to merge 1 commit intooperator-framework:masterfrom
jianzhangbjz:OCPBUGS-76460
Closed

fix: add OpenAPIModelName for all types referenced in OpenAPI schemas#476
jianzhangbjz wants to merge 1 commit intooperator-framework:masterfrom
jianzhangbjz:OCPBUGS-76460

Conversation

@jianzhangbjz
Copy link
Member

To address the issue of openshift/operator-framework-olm#1230.

% oc get pods -n hive -w                                                                                                     
NAME                             READY   STATUS    RESTARTS   AGE
hive-operator-7cbbd6cf7d-mfbtg   1/1     Running   0          111s
^C%                                                                                                                                                                  mihuang@mihuang-mac hive % oc get hiveconfig hive -o yaml                                                                                             
apiVersion: hive.openshift.io/v1
kind: HiveConfig
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"hive.openshift.io/v1","kind":"HiveConfig","metadata":{"annotations":{},"name":"hive"},"spec":{"logLevel":"debug","targetNamespace":"hive"}}
  creationTimestamp: "2026-02-13T04:00:37Z"
  generation: 1
  name: hive
  resourceVersion: "34559"
  uid: 2c53cbcb-0ecd-4a3c-a43f-1f83343216e4
spec:
  logLevel: debug
  targetNamespace: hive
status:
  conditions:
  - lastProbeTime: "2026-02-13T04:01:05Z"
    lastTransitionTime: "2026-02-13T04:01:05Z"
    message: 'error getting OpenAPISchema: SchemaError(com.github.operator-framework.operator-lifecycle-manager.pkg.package-server.apis.operators.v1.CSVDescription.apiservicedefinitions):
      unknown model in reference: "github.com~1operator-framework~1api~1pkg~1operators~1v1alpha1.APIServiceDefinitions"'
    reason: ErrorCreatingResourceHelper
    status: "False"
    type: Ready
  observedGeneration: 1
mihuang@mihuang-mac hive % 
mihuang@mihuang-mac hive % oc get clusterversion
NAME      VERSION                                                AVAILABLE   PROGRESSING   SINCE   STATUS
version   4.22.0-0-2026-02-13-030444-test-ci-ln-319mih2-latest   True        False         8m23s   Cluster version is 4.22.0-0-2026-02-13-030444-test-ci-ln-319mih2-latest
mihuang@mihuang-mac hive %

Description of the change:

This PR adds OpenAPIModelName() methods to all types in the operator-framework/api package that are referenced in OpenAPI schema definitions.

When Kubernetes serves OpenAPI schemas, the "/" character in type references gets URL-encoded to "~1". If the schema definition keys use the raw Go import path format
(e.g., github.com/operator-framework/api/...) but references are URL-encoded (e.g., github.com~1operator-framework~1api~1...), lookups fail with errors like:

error getting OpenAPISchema: SchemaError(...CSVDescription.apiservicedefinitions):
unknown model in reference: "github.com1operator-framework1api1pkg1operators~1v1alpha1.APIServiceDefinitions"

Adding OpenAPIModelName() makes openapi-gen use the canonical com.github... format for both definition keys and references, ensuring they match.

Motivation for the change:

This is a prerequisite fix for https://issues.redhat.com/browse/OCPBUGS-76460

PR operator-framework/operator-lifecycle-manager#3765 added OpenAPIModelName() for types defined in the OLM package-server, but operators like
Hive still fail because CSVDescription references types from this package (operator-framework/api) that don't have the method.

Types updated:

pkg/lib/version:

  • OperatorVersion

pkg/operators/v1alpha1:

  • APIResourceReference, APIServiceDefinitions, APIServiceDescription
  • ActionDescriptor, AppLink, CRDDescription
  • CleanupSpec, CleanupStatus, ClusterServiceVersionCondition
  • ClusterServiceVersionSpec, ClusterServiceVersionStatus
  • CustomResourceDefinitions, DependentStatus, Icon, InstallMode
  • Maintainer, NamedInstallStrategy, RelatedImage, RequirementStatus
  • ResourceInstance, ResourceList, SpecDescriptor, StatusDescriptor
  • StrategyDeploymentPermissions, StrategyDeploymentSpec
  • StrategyDetailsDeployment, WebhookDescription

Related to operator-framework/operator-lifecycle-manager#3765
Assisted-By: Claude-Code

@openshift-ci openshift-ci bot requested review from oceanc80 and tmshort February 13, 2026 05:11
@openshift-ci
Copy link

openshift-ci bot commented Feb 13, 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 joelanford 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

@codecov
Copy link

codecov bot commented Feb 13, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.62%. Comparing base (884ff95) to head (ab66946).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #476      +/-   ##
==========================================
+ Coverage   37.86%   38.62%   +0.75%     
==========================================
  Files          57       59       +2     
  Lines        4563     4619      +56     
==========================================
+ Hits         1728     1784      +56     
  Misses       2678     2678              
  Partials      157      157              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
Copy link
Contributor

@camilamacedo86 camilamacedo86 Feb 13, 2026

Choose a reason for hiding this comment

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

We do not add license in this project
So I think we should keep all as it is in the other files.
Could you please remove from all? And keep the current standards

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor

Choose a reason for hiding this comment

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

The root Apache license should be sufficient. As pointed out, there's no copyright/licensing in individual files.

Copy link
Contributor

@camilamacedo86 camilamacedo86 left a comment

Choose a reason for hiding this comment

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

@pedjak did a PR which I understand that would address this one in the right place : controller-gen, see: kubernetes-sigs/controller-tools#1335

So, can we not wait that lands?

@tmshort
Copy link
Contributor

tmshort commented Feb 13, 2026

@pedjak did a PR which I understand that would address this one in the right place : controller-gen, see: kubernetes-sigs/controller-tools#1335

So, can we not wait that lands?

It may take some time for that to land.

@camilamacedo86
Copy link
Contributor

Hi @jianzhangbjz

After looking it properly I got better the issue

Anyway, It does not seems the right way to fix it.
We should not need to implement all those OpenAPI interfaces for every spec, for every API, in every project.
WHY? Reduce the maintainability of all. Burn in long term.

So, seems that @tmshort found the right way to address the need: https://redhat-internal.slack.com/archives/C06KP34REFJ/p1771002335868269?thread_ts=1770960532.333679&cid=C06KP34REFJ

We need to use the right marker +k8s:openapi-model-package=<name> tags instead.

@jianzhangbjz
Copy link
Member Author

This uses the manual approach. I chose this method because it works immediately and doesn’t require any tooling changes, especially since it’s currently blocking the Hive operator team. That said, I agree it would increase the maintenance burden in the long run. I’ve closed it in favor of PR #477.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants