Skip to content

Conversation

@ryanzhang-oss
Copy link
Contributor

@ryanzhang-oss ryanzhang-oss commented Nov 27, 2024

Description of your changes

Fixes #

I have:

  • Run make reviewable to ensure this PR is ready for review.

How has this code been tested

Special notes for your reviewer

@ryanzhang-oss ryanzhang-oss marked this pull request as draft November 27, 2024 00:06
@ryanzhang-oss ryanzhang-oss changed the title Add delete override feat: Add delete override implementation Nov 27, 2024
@ryanzhang-oss ryanzhang-oss marked this pull request as ready for review December 3, 2024 02:20
}
}
}
switch rule.OverrideType {
Copy link
Contributor

Choose a reason for hiding this comment

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

can be replaced by using cel

for example,

// +kubebuilder:validation:XValidation:rule="self.overrideType == 'JSONPatch' || self.jsonPatchOverrides.size() == 0 ",message="jsonPatchOverrides must be empty when type is not JSONPatch"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good to know but unless we remove this validator, we need to fix it even with the CEL, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

yeah, but the fix is much simpler, just need to add the type check.

Copy link
Contributor Author

@ryanzhang-oss ryanzhang-oss Dec 4, 2024

Choose a reason for hiding this comment

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

I think there is some advantage to keep all the validation logics (and test) together instead of splitting them into two places.


// If the resource is selected by both ClusterResourceOverride and ResourceOverride, ResourceOverride will win when
// resolving conflicts.
// If the resource is selected by both ClusterResourceOverride and ResourceOverride, ResourceOverride will win when resolving conflicts.
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens for a namespace scope resource which is selected by both cro and ro?

for example, cro deletes the resource, and ro overrides the resource.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we actually have the same problem now when a CRO deletes a field and a ro wants to replace it. This can happen even between any CRO or RO.

}: true,
},
IsClusterScopedResource: false,
IsClusterScopedResource: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

should be "false"? deployment is not a cluster scoped resource.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the fakeInformer logic is weird that this field is not what it's name is about. I think some of the tests were passing simply because this flag were set wrong (so the CROs are skipped).

Copy link
Contributor

Choose a reason for hiding this comment

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

Finally figured out where's the bug. The bug is in line 1064. The deployment group should be "app". If you correct there, this value should be set as false.

},
wantErr: controller.ErrUserError,
},
{
Copy link
Contributor

Choose a reason for hiding this comment

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

add more tests about delete type:

  • cro delete, ro patch
  • cro patch, ro delete
  • cro delete, ro delete

}: true,
},
IsClusterScopedResource: false,
IsClusterScopedResource: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Finally figured out where's the bug. The bug is in line 1064. The deployment group should be "app". If you correct there, this value should be set as false.

wantErr: controller.ErrUserError,
},
{
name: "delete during the clusterResourceOverride",
Copy link
Contributor

Choose a reason for hiding this comment

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

add one more test, delete after patch?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isn't test 1719 the delete after patch. There is another delete after patch case for a field earlier.

@zhiying-lin zhiying-lin merged commit a5e882f into Azure:main Dec 5, 2024
12 checks passed
@ryanzhang-oss ryanzhang-oss deleted the add-delete-override branch April 22, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants