Skip to content

compDef pattern multi-match resolution is silent: sorted-last selection with no warning, condition, or event #10521

Description

@weicao

Current behavior

compDef references (ClusterDefinition topology components, ComponentVersion compatibilityRules, and other prefix/regex reference sites) resolve multi-matches by sorting candidate ComponentDefinition names and picking the last entry (controllers/apps/cluster/transformer_cluster_normalization.go:662-698, selection at :694, main @ aa7f8c8). Zero matches produce a hard error, but multiple matches produce no warning, condition, or event — the selection is invisible unless the user diffs the generated Component's resolved compDef against expectation.

Why it matters

Name-sort selection means an addon chart that ships a new ComponentDefinition (e.g. acmedb-storage-1.10.0 sorting after acmedb-storage-1.9.0) can silently change which definition existing patterns resolve to. Combined with prefix/regex patterns recommended for version management, drift is easy to introduce and hard to notice — today's mitigation is chart unit tests asserting name closure, which not every addon has.

Suggested fix

When a pattern matches more than one ComponentDefinition, surface the resolved choice and the candidate count as an event or condition on the Cluster/Component (e.g. "pattern ^acmedb-storage-.* matched 3 ComponentDefinitions, selected acmedb-storage-1.10.0"). This keeps current semantics but makes the tie-break observable and auditable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions