Skip to content

improve: blocklist of problematic resources for previous version annotation #2774

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 16, 2025

Conversation

csviri
Copy link
Collaborator

@csviri csviri commented Apr 28, 2025

Signed-off-by: Attila Mészáros [email protected]

@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 Apr 28, 2025
@csviri csviri changed the title feat: blacklist of problematic resources for previous version annotation improve: blacklist of problematic resources for previous version annotation Apr 28, 2025
@csviri
Copy link
Collaborator Author

csviri commented Apr 29, 2025

related issues:
#2509
#2553

@csviri csviri changed the title improve: blacklist of problematic resources for previous version annotation improve: blocklist of problematic resources for previous version annotation Apr 29, 2025
@csviri csviri marked this pull request as ready for review April 29, 2025 13:00
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 29, 2025
*
* @return blocklist of resource classes where the previous version annotation won't be used.
*/
default List<Class<? extends HasMetadata>> previousAnnotationUsageBlocklist() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I would suggest also documenting the default implementation in the javadoc.

Copy link
Collaborator Author

@csviri csviri Apr 29, 2025

Choose a reason for hiding this comment

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

Not sure that is needed / that helpful since users can just open the code and see the defaults, also we don't do it for other configs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

What would make more sense, though, is to explain what is the consequence for a resource type to be in the block list because this isn't clear at all and people might be hesitant adding a resource to the block list without more details of what happens when they do.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, this should probably be a set rather than a list as the order is meaningless whereas we only want one instance of a given resource type in this collection.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Explained the consequence and changed it to set, thank you!

*
* @return blocklist of resource classes where the previous version annotation won't be used.
*/
default List<Class<? extends HasMetadata>> previousAnnotationUsageBlocklist() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What would make more sense, though, is to explain what is the consequence for a resource type to be in the block list because this isn't clear at all and people might be hesitant adding a resource to the block list without more details of what happens when they do.

* @return blocklist of resource classes where the previous version annotation won't be used.
*/
default List<Class<? extends HasMetadata>> previousAnnotationUsageBlocklist() {
return List.of(Deployment.class, StatefulSet.class);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Another aspect is whether or not these 2 classes should always be added to the block list regardless of what the user might set this list to (i.e. what is returned by this method should be added to the default list, not replace it completely).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Those should not be always added, if the user is sure that the matcher is right those can be removed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I understand. From what I understand, Deployment and StatefulSet are always problematic for the matcher, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No, only if it uses fields that are normalized later by the API, (and maybe if some defaults filled in, not sure about that)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

In the light of this, it is debatable if those resource should be opt-in or opt-out. WDYT?

*
* @return blocklist of resource classes where the previous version annotation won't be used.
*/
default List<Class<? extends HasMetadata>> previousAnnotationUsageBlocklist() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, this should probably be a set rather than a list as the order is meaningless whereas we only want one instance of a given resource type in this collection.

@@ -188,6 +190,12 @@ public ConfigurationServiceOverrider withCloneSecondaryResourcesWhenGettingFromC
return this;
}

public ConfigurationServiceOverrider previousAnnotationUsageBlocklist(
List<Class<? extends HasMetadata>> previousAnnotationUsageBlacklist) {
this.previousAnnotationUsageBlocklist = previousAnnotationUsageBlacklist;
Copy link
Collaborator

Choose a reason for hiding this comment

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

See the previous comment on how this should probably be adding to the default set rather than completely replace it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Responded above.

.build();
}

// for testing purposes replicating the matching logic but with the special matcher
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should use the configuration option from #2760 instead.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If that is merged, can change it (might be a new PR). thx!

@csviri csviri requested review from metacosm and xstefank May 8, 2025 07:43
LocallyRunOperatorExtension.builder()
// Removing resource from blocklist List would result in test failure
// .withConfigurationService(
// o -> o.previousAnnotationUsageBlocklist(Collections.emptyList()))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be a new test then?

Copy link
Collaborator Author

@csviri csviri May 12, 2025

Choose a reason for hiding this comment

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

It could be an additional test, I did not add that since I did not find it important to show that something is not working.

@csviri
Copy link
Collaborator Author

csviri commented May 13, 2025

@metacosm are there any other concerns or we can merge this?

@csviri csviri force-pushed the blacklist-prev-annotation branch from 228f8d2 to 7a1902b Compare May 14, 2025 07:23
@@ -474,7 +474,8 @@ default boolean previousAnnotationForDependentResourcesEventFiltering() {
*
* @return a Set of resource classes where the previous version annotation won't be used.
*/
default Set<Class<? extends HasMetadata>> previousAnnotationUsageBlocklist() {
default Set<Class<? extends HasMetadata>>
previousAnnotationForDependentResourcesEventFilteringBlocklist() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this is fine to have also with shorter form and keep it consistent. (withPreviousAnnotationForDependentResourcesBlocklist)

Signed-off-by: Attila Mészáros <[email protected]>
@metacosm metacosm merged commit e3c828f into main May 16, 2025
25 checks passed
@metacosm metacosm deleted the blacklist-prev-annotation branch May 16, 2025 13:56
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.

4 participants