-
Notifications
You must be signed in to change notification settings - Fork 219
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
Conversation
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…cile should be triggered operator-framework#430
@@ -163,6 +165,16 @@ public CustomResourceCache getCache() { | |||
return getCache().getLatestResource(customResourceUid); | |||
} | |||
|
|||
// todo: remove |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above…
Thank you! |
Fixes #430