Skip to content

[Registry] Model generation drops CRDs that share a Kind with another CRD in a different API group #1145

Open
meshery/schemas
#1350

Description

@Anand-240

Current Behavior

When a source (Helm chart, GitHub repo or URL) contains two CRDs with the same spec.names.kind in different API groups, model generation writes only one of them. The other is dropped with no error and no log line.

This already affects published models on meshery/meshery master:

  • linkerd (models/linkerd/edge-26.11.1): the chart has 14 CRDs, the model has 13 components. HTTPRoute.json is the Gateway API HTTPRoute (gateway.networking.k8s.io/v1). Linkerd's own policy.linkerd.io HTTPRoute (served, not deprecated) is missing. Same in edge-26.6.2, edge-26.9.1 and edge-26.10.2.
  • crossplane (models/crossplane/v2.4.3): 21 CRDs, 20 components. Usage.json is apiextensions.crossplane.io/v1alpha1, which upstream marks deprecated: true ("migrate to protection.crossplane.io"). Its replacement, the namespaced protection.crossplane.io/v1beta1 Usage, is missing, while its sibling ClusterUsage is present. Same in v2.3.2 and v2.4.0.

Which CRD survives depends only on file order.

Expected Behavior

Every CRD in the source becomes a component. Kubernetes allows the same Kind in different groups, and the rest of the pipeline already supports it:

  • component IDs are random UUIDs (GenerateID in schemas component_helper.go:28), so nothing in the DB requires Kind to be unique within a model;
  • the registry's unique-component count keys on Kind + apiVersion + model + model version (models/meshmodel/registry/v1beta1/component_filter.go:60);
  • directory registration (models/registration/dir.go:74, used by server seeding and import) reads every .json file regardless of its name.

So both components should be written and registered.

Root cause

  • ComponentDefinition.WriteComponentDefinition (meshery/schemas models/v1beta3/component/component_helper.go:84-98, same on schemas master today) names the file <Kind>.json. If that file already exists it returns alreadyExists = true and writes nothing.
  • meshkit treats that as "already generated on an earlier run" and only decrements the written count:
    • registry/model.go:640-646 (GenerateComponentsFromPkg)
    • registry/model.go:998-1001 (InvokeGenerationFromSheetWithOptions, which is what the nightly model-generator.yml job runs through mesheryctl registry generate)
    • registry/model.go:1138-1148
  • The generators keep both CRDs: utils/component/generator.go:126 sets component.version = <group>/<version>, so the two components differ only in apiVersion. The loss happens at write time.

Screenshots/Logs

Output of the test below (trimmed):

generated: HTTPRoute    gateway.networking.k8s.io/v1
generated: HTTPRoute    policy.linkerd.io/v1alpha1
total=14 written=13 err=<nil>
on disk: HTTPRoute.json   gateway.networking.k8s.io/v1

Running the same pipeline on the source URIs of the published models (git://github.com/linkerd/linkerd2/main/charts/linkerd-crds/ and git://github.com/crossplane/crossplane/master/cluster/crds) writes 13 and 20 components, the same counts as the published models, and keeps the same files.

Environment

  • Host OS: Mac
  • Platform: N/A (model generation, no running server)
  • meshkit: master @ 2157006 (registry/model.go is identical to v1.0.24, the release meshery master uses)
  • meshery/schemas: v1.3.115 (meshkit master) and v1.3.37 (meshery master); WriteComponentDefinition is the same in both and on schemas master
  • meshery/meshery: master, commit meshery/meshery@8ad258e7 (meshkit v1.0.24, schemas v1.3.37)

To Reproduce

  1. Download the linkerd-crds chart for edge-26.11.1: https://helm.linkerd.io/edge/linkerd-crds-2026.11.1.tgz
  2. Run it through GitHubPackageManager.GetPackage() -> pkg.GenerateComponents("") -> registry.GenerateComponentsFromPkg(...) with the test below.
  3. 14 components are generated but only 13 files are written. There is no file for the policy.linkerd.io HTTPRoute.
Test used
package github_test

import (
	"encoding/json"
	"net/http"
	"net/http/httptest"
	"net/url"
	"os"
	"path/filepath"
	"testing"

	"github.com/meshery/meshkit/generators/github"
	"github.com/meshery/meshkit/registry"
	_model "github.com/meshery/schemas/models/v1beta1/model"
	"github.com/meshery/schemas/models/v1beta3/component"
)

func TestSameKindDifferentGroup(t *testing.T) {
	dir := os.Getenv("REPRO_DIR") // contains linkerd-crds-2026.11.1.tgz
	if dir == "" {
		t.Skip("REPRO_DIR not set")
	}
	srv := httptest.NewServer(http.FileServer(http.Dir(dir)))
	defer srv.Close()

	u, _ := url.Parse(srv.URL + "/linkerd-crds-2026.11.1.tgz")
	pkg, err := github.GitHubPackageManager{PackageName: "repro", SourceURL: u.String()}.GetPackage()
	if err != nil {
		t.Fatal(err)
	}
	comps, _ := pkg.GenerateComponents("")
	for _, c := range comps {
		t.Logf("generated: %-12s %s", c.Component.Kind, c.Component.Version)
	}
	out := t.TempDir()
	total, written, err := registry.GenerateComponentsFromPkg(pkg, out, "v1.0.0", _model.ModelDefinition{Name: "repro"}, "")
	t.Logf("total=%d written=%d err=%v", total, written, err)
	files, _ := filepath.Glob(filepath.Join(out, "*.json"))
	for _, f := range files {
		var c component.ComponentDefinition
		b, _ := os.ReadFile(f)
		_ = json.Unmarshal(b, &c)
		t.Logf("on disk: %-16s %s", filepath.Base(f), c.Component.Version)
	}
}

Run: REPRO_DIR=<dir> go test -count=1 -run TestSameKindDifferentGroup -v ./generators/github/

Proposed fix

Fix it in the writer in meshery/schemas, so every caller gets it: the three generation paths in meshkit registry/model.go, and ExportModel in meshery (server/handlers/component_handler.go:1465), which would drop one of the two in the same way when exporting a model that has both.

  • The first component keeps <Kind>.json, so existing models and file paths do not change.
  • A component of the same Kind from another API group is written to <Kind>.<group>.json (core for the core group), for example HTTPRoute.policy.linkerd.io.json.
  • A component from the same group, in any version, still returns "already exists", so re-running generation into an existing directory works as it does today.
  • The signature and return values stay the same, so no caller has to change.

I tried this with a replace to the patched schemas, running the same pipeline: linkerd writes 14 of 14 components (HTTPRoute.json and HTTPRoute.policy.linkerd.io.json) and crossplane 21 of 21 (Usage.json and Usage.protection.crossplane.io.json). Same-group duplicates are still skipped: the linkerd git:// source returns 70 entries and 14 files are written.

Why not the other options:

  • Naming every file <Kind>.<group>.json would rename every component file in every published model.
  • Keeping one component per Kind would still lose a real CRD.

After the schemas release:

  1. meshkit: a regression test with two same-Kind CRDs, once the schemas bump is merged.
  2. meshery/meshery: bump schemas, so the nightly model generator adds the missing linkerd and crossplane components.

Two things to keep in mind:

I have the schemas change ready and will open the PR there, linked to this issue.


Contributor Guides and Handbook

Activity

  1. added
    kind/bug
    on Nov 6, 2026
  2. Prakhar1Ojha commented on Nov 24, 2026

    @Prakhar1Ojha

    Hi maintainers @leecalcote,

    I would love to work on this issue!

    I have investigated the problem in model generation where CRDs sharing spec.names.kind across different API groups overwrite each other because components are mapped and keyed by bare Kind rather than group-qualified identifiers.

    My proposed plan:

    1. Update component collection and registration in MeshKit so that CRD components are indexed by a composite key (Group, Kind) rather than bare Kind alone.
    2. Ensure file writing and registry output preserve both CRDs when they belong to distinct API groups.
    3. Add unit tests in utils/component/generator_test.go with sample manifests containing identical Kinds in different API groups (matching the Linkerd/Crossplane scenario) to verify neither CRD is dropped.

    Could you please assign this issue to me? Thank you!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions