Skip to content

fix: skip CRD check for built-in Kubernetes API groups in crdNameFromGVK#191

Merged
tiraboschi merged 1 commit into
openshift-virtualization:mainfrom
tiraboschi:fix/crd-name-from-gvk-builtin-groups
May 25, 2026
Merged

fix: skip CRD check for built-in Kubernetes API groups in crdNameFromGVK#191
tiraboschi merged 1 commit into
openshift-virtualization:mainfrom
tiraboschi:fix/crd-name-from-gvk-builtin-groups

Conversation

@tiraboschi
Copy link
Copy Markdown
Member

Summary

Fixes a bug where built-in Kubernetes API groups (apps, batch, rbac.authorization.k8s.io, etc.) were incorrectly treated as CRDs, causing assets using these APIs to be skipped with "CRD not installed" errors.

Root cause

crdNameFromGVK in pkg/assets/registry.go treated every apiVersion containing / as a CRD. So apps/v1 produced deployments.apps, rbac.authorization.k8s.io/v1 produced clusterroles.rbac.authorization.k8s.io, etc.

Fix

  • Recognise all Kubernetes-owned API groups by their .k8s.io / .apiserver.k8s.io suffix and return "" (no CRD required).
  • Add an explicit allowlist for the legacy built-in groups that predate that convention: apps, batch, policy, autoscaling.
  • Guard IsManagedCRD against an empty crdName to avoid a false match if any asset has an empty RequiredCRD field.

Test plan

  • TestCrdNameFromGVK added covering core v1, all major .k8s.io groups, legacy groups, and a representative set of real CRD groups (kubevirt, forklift, metallb, monitoring, openshift, medik8s).
  • go test ./pkg/assets/... passes.

Cherry-picked from #180 (authored by @nirdothan).

crdNameFromGVK was treating any apiVersion with a "/" as a CRD,
so groups like apps, batch, and rbac.authorization.k8s.io would
produce spurious CRD names (e.g. "deployments.apps") and cause
assets to be skipped with "CRD not installed" errors.

Fix uses the .k8s.io/.apiserver.k8s.io suffix to identify
Kubernetes-owned groups, with an explicit allowlist for the
legacy groups (apps, batch, policy, autoscaling) that predate
that naming convention.

Also guard IsManagedCRD against an empty crdName to avoid a
false match if any asset has an empty RequiredCRD field.

Co-Authored-By: Nir Dothan <nirdothan@users.noreply.github.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tiraboschi
Copy link
Copy Markdown
Member Author

/approve

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 25, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tiraboschi

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

The pull request process is described 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

@openshift-ci
Copy link
Copy Markdown

openshift-ci Bot commented May 25, 2026

@nirdothan: changing LGTM is restricted to collaborators

Details

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@tiraboschi tiraboschi merged commit a9f6209 into openshift-virtualization:main May 25, 2026
6 of 7 checks passed
@tiraboschi tiraboschi deleted the fix/crd-name-from-gvk-builtin-groups branch May 25, 2026 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants