Skip to content

Conversation

@a-hilaly
Copy link
Member

@a-hilaly a-hilaly commented Mar 5, 2025

ResourceGraphDefinitions generate CRDs dynamically. Schema changes like
removing properties, changing types, or adding required fields can break
existing resources. This adds a compatibility layer that compares schemas
before CRD updates and blocks breaking changes.

Introduces a pkg/graph/crd/compat package with Compare() and
CompareVersions() functions that return a Report identifying breaking
vs non-breaking changes. The CRD wrapper now validates compatibility before
applying updates.

Resolves #186

Copy link
Contributor

@michaelhtm michaelhtm left a comment

Choose a reason for hiding this comment

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

Great job on this @a-hilaly!! 🚀🚀🚀
I left a few inline comments

Comment on lines 25 to 38
// Breaking change types
PropertyRemoved ChangeType = "PROPERTY_REMOVED"
TypeChanged ChangeType = "TYPE_CHANGED"
RequiredAdded ChangeType = "REQUIRED_ADDED"
EnumRestricted ChangeType = "ENUM_RESTRICTED"
PatternChanged ChangeType = "PATTERN_CHANGED"

// Non-breaking change types
PropertyAdded ChangeType = "PROPERTY_ADDED"
DescriptionChanged ChangeType = "DESCRIPTION_CHANGED"
DefaultChanged ChangeType = "DEFAULT_CHANGED"
RequiredRemoved ChangeType = "REQUIRED_REMOVED"
EnumExpanded ChangeType = "ENUM_EXPANDED"
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can add number changes as well..I saw a PR approved for adding maximum and minimum to the schema. We should also track those changes..

Copy link
Member Author

Choose a reason for hiding this comment

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

Are those considered breaking changes? should we really inspect the defaults/max/min and basically every attribute in https://kro.run/docs/concepts/simple-schema#supported-markers ? cc @jakobmoellerdev

@a-hilaly a-hilaly requested review from justinsb and matthchr March 12, 2025 20:17
Copy link
Contributor

@n3wscott n3wscott left a comment

Choose a reason for hiding this comment

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

LGTM

@matthchr matthchr added this to the 0.4 milestone Jul 9, 2025
@matthchr matthchr self-assigned this Jul 9, 2025
@a-hilaly a-hilaly modified the milestones: 0.4, 0.5 Jul 30, 2025
@k8s-triage-robot
Copy link

Unknown CLA label state. Rechecking for CLA labels.

Send feedback to sig-contributor-experience at kubernetes/community.

/check-cla
/easycla

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Sep 12, 2025
@a-hilaly a-hilaly modified the milestones: 0.5, 0.6 Oct 21, 2025
@a-hilaly a-hilaly modified the milestones: 0.6, 0.7 Oct 29, 2025
@a-hilaly a-hilaly modified the milestones: 0.7, 0.8 Nov 26, 2025
@crenshaw-dev
Copy link

Apologies for a very drive-by suggestion, but crdify might be useful to externalize some of the breaking change detection: https://github.com/kubernetes-sigs/crdify

@jakobmoellerdev
Copy link
Member

@crenshaw-dev I believe crdify is a CLI tool first. does it plan to support a library mode long term? If so lets take a look there!

@crenshaw-dev
Copy link

crenshaw-dev commented Dec 9, 2025

@jakobmoellerdev good question... I used it as a go lib for a small project, and it seemed to work fine: https://github.com/crenshaw-dev/miaka/blob/8d568300f998f1028942ceee66d65cace12b8f09/pkg/build/validation/breaking_changes.go#L45

I'm not sure whether they plan to maintain stable APIs for use as a go library, but I asked the question here: kubernetes-sigs/crdify#52

@a-hilaly
Copy link
Member Author

a-hilaly commented Dec 9, 2025

Thanks for the suggestion @crenshaw-dev! I actaully looked at crdify before writing this PR. At that time, it didn't strike me as something designed for library usage and looked primarily a CLI tool [global registries, log.Fatalf in erorr paths and heavy transitive dependencies].

That said, thank you for opening the github issue - happy to reconsider this in favor of using crdify. And since I was here, I just rebased this PR!

@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Dec 9, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: a-hilaly, n3wscott

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 9, 2025
ResourceGraphDefinitions generate CRDs dynamically. Schema changes like
removing properties, changing types, or adding required fields can break
existing resources. This adds a compatibility layer that compares schemas
before CRD updates and blocks breaking changes.

Introduces a `pkg/graph/crd/compat` package with `Compare()` and
`CompareVersions()` functions that return a `Report` identifying breaking
vs non-breaking changes. The CRD wrapper now validates compatibility before
applying updates.

Resolves: 186
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Dec 9, 2025
@crenshaw-dev
Copy link

Looks like crdify is usable as a library!

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

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

detect and handle CRD breaking changes

8 participants