Skip to content

feat: use a predicate to select the custom resource for which a reconcile should be triggered #454

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 1 commit into from
Jul 13, 2021

Conversation

lburgazzoli
Copy link
Collaborator

Fixes #430

Copy link
Collaborator

@metacosm metacosm left a comment

Choose a reason for hiding this comment

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

Overall, looks OK, just some minor comments and improvements.

eventBuffer.addEvent(event);
executeBufferedEvents(event.getRelatedCustomResourceUid());

if (event.getRelatedCustomResourceUid() != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we replace this by creating a UID predicate so that we handle everything the same way?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Absolutely, the reason I left is that it could be slightly more efficient as it would avoid an extra lookup but I will fix 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.

done

} finally {
lock.unlock();
}
}

private void executeBufferedEvents(List<String> customResourceUids) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Both versions of the method should be merged into a single one, imo.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a leftover, I'll remove 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.

done

import java.util.function.Predicate;

@SuppressWarnings("rawtypes")
public class DefaultEvent extends AbstractEvent {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need this class?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We don't but I found a little bit annoying that AbstractEvent is declared abstract but in fact it does not have any abstract method so if you want to create a generic event, you'd need an anonymous class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll refactor AbstractEvent separately.

.hasSize(2)
.allSatisfy(
s -> {
assertThat(s.getEvents()).isNotEmpty().hasOnlyElementsOfType(DefaultEvent.class);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't we rather check that the events match cr1 and cr3 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.

done

@lburgazzoli lburgazzoli marked this pull request as ready for review July 13, 2021 13:10
@@ -163,6 +165,16 @@ public CustomResourceCache getCache() {
return getCache().getLatestResource(customResourceUid);
}

// todo: remove
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why are these methods marked as todo: remove?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

copied from the other methods that were there, I don't know what was the rationale of the old comments, should I remove the comment or you have a plan to remove thos methods ?

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, I'll try to figure out what's going on there… :)

public void setup() {
defaultEventHandler.setEventSourceManager(defaultEventSourceManagerMock);

// todo: remove
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same comment as above…

@metacosm metacosm merged commit 9bba3d1 into operator-framework:master Jul 13, 2021
@metacosm
Copy link
Collaborator

Thank you!

@lburgazzoli lburgazzoli deleted the github-430 branch July 13, 2021 13:41
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.

event source: use a predicate to select the custom resource for which a reconcile should be triggered
2 participants