Skip to content

Conversation

@chrischdi
Copy link
Contributor

No description provided.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Oct 10, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Oct 10, 2025

@chrischdi: This pull request references OCPCLOUD-3172 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.21.0" version, but no target version was set.

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 openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 10, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 10, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 10, 2025

[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 racheljpg for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@coderabbitai
Copy link

coderabbitai bot commented Oct 10, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@chrischdi
Copy link
Contributor Author

/test unit
/test lint
/test build

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Oct 10, 2025

@chrischdi: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/lint ac815fd link true /test lint

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Copy link
Contributor

@mdbooth mdbooth left a comment

Choose a reason for hiding this comment

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

I think this is great and a clear improvement. I have some follow-on ideas, but I would personally gladly merge this and iterate on it in the unlikely event it ever became worth it.

I shared a thought inline based on something similar we did in ORC with field indexers.

Not at all important, but I also feel that Unstructured is an internal implementation detail: e.g. the Diff method could be implemented with reflection and the signature would not change.

Comment on lines +93 to +100
differ := UnstructuredDiffer[clusterv1.MachineSetStatus]{
customDiff: []func(a clusterv1.MachineSetStatus, b clusterv1.MachineSetStatus) ([]string, error){
func(a, b clusterv1.MachineSetStatus) ([]string, error) {
return compareCAPIMachineSetConditions(a.Conditions, b.Conditions), nil
},
},
ignoreFields: [][]string{{"conditions"}},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

differ := UnstructuredDiffer[clusterv1.MachineSetStatus]()

differ = WithCustomDiff(differ,
    "conditions",
    func(x *clusterv1.MachineSetStatus) []clusterv1.Condition {return x.conditions},
    compareCAPIConditions)

func compareCAPIConditions(a, b []clusterv1.Conditions) []string {
    ...
}

WithCustomDiff unfortunately can't be a method on UnstructuredDiffer as it has an additional type argument([]clusterv1.Condition).

Advantages of this approach:

  • ignoreField is a required argument of CustomDiff, removing a footgun
  • compareCAPIConditions is now reusable by all types with CAPI conditions

Disadvantages:

  • The argument to pull a field out is a bit ugly

Copy link
Contributor

Choose a reason for hiding this comment

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

ignoreField is a required argument of CustomDiff, removing a footgun

Are there cases when we want to ignore fields without custom diffs no? Maybe around deprecated fields?

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 10, 2025
@openshift-merge-robot
Copy link
Contributor

PR needs rebase.

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.

"k8s.io/apimachinery/pkg/runtime"
)

type UnstructuredDiffer[T any] struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

Godoc missing

"k8s.io/apimachinery/pkg/runtime"
)

type UnstructuredDiffer[T any] struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is unstructured, why is it also generic? Does it make this simpler than using runtime.Object for the a, b arguments?


diff := deep.Equal(unstructuredA, unstructuredB)
if len(diff) > 0 {
diffs["deep.Equal"] = diff
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the deep.Equal key? Does this get exposed to end users? Is this a magic word?

Comment on lines +85 to +91
// Maybe we can also have it this way:
// differ := NewUnstructuredDiffer(
// WithIgnoreField[clusterv1.MachineSetStatus]("conditions"),
// WithCustomDiff(func(a, b clusterv1.MachineSetStatus) ([]string, error) {
// return compareCAPIMachineSetConditions(a.Conditions, b.Conditions), nil
// }),
// )
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer this

Comment on lines +93 to +100
differ := UnstructuredDiffer[clusterv1.MachineSetStatus]{
customDiff: []func(a clusterv1.MachineSetStatus, b clusterv1.MachineSetStatus) ([]string, error){
func(a, b clusterv1.MachineSetStatus) ([]string, error) {
return compareCAPIMachineSetConditions(a.Conditions, b.Conditions), nil
},
},
ignoreFields: [][]string{{"conditions"}},
}
Copy link
Contributor

Choose a reason for hiding this comment

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

ignoreField is a required argument of CustomDiff, removing a footgun

Are there cases when we want to ignore fields without custom diffs no? Maybe around deprecated fields?

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

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants