Skip to content
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

Removing events from context #596

Merged
merged 48 commits into from
Oct 13, 2021
Merged

Removing events from context #596

merged 48 commits into from
Oct 13, 2021

Conversation

csviri
Copy link
Collaborator

@csviri csviri commented Oct 11, 2021

No description provided.

csviri and others added 30 commits September 30, 2021 17:02
# Conflicts:
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/Event.java
# Conflicts:
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/Operator.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/DefaultEventHandler.java
…/java-operator-sdk into informer-creventsource
# Conflicts:
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/DefaultEventHandler.java
@csviri csviri self-assigned this Oct 11, 2021
@csviri csviri marked this pull request as draft October 11, 2021 08:01
@csviri csviri marked this pull request as ready for review October 11, 2021 13:04
@csviri
Copy link
Collaborator Author

csviri commented Oct 11, 2021

pls review this first: #581

@metacosm @lburgazzoli

# Conflicts:
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/DefaultEventHandler.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/EventBuffer.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/ExecutionScope.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/DefaultEvent.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/DefaultEventSourceManager.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/internal/CustomResourceEvent.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/internal/CustomResourceEventSource.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/internal/InformerEvent.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/internal/InformerEventSource.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/internal/TimerEvent.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/internal/TimerEventSource.java
#	operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/DefaultEventHandlerTest.java
#	operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/EventBufferTest.java
#	operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/EventDispatcherTest.java
#	operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/EventListTest.java
#	operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/internal/CustomResourceEventFilterTest.java
#	operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/event/internal/CustomResourceEventSourceTest.java
#	operator-framework/src/main/java/io/javaoperatorsdk/operator/config/runtime/AnnotationConfiguration.java
@csviri csviri requested a review from metacosm October 12, 2021 15:27
}
return false;
}
}

private void markEvent(Event event) {
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 this be a method on EventMarker?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Did not want to put it there, since Event marker should not know that there is special CustomResourceEvent . Will renamet his method so it's more descriptive.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yes, good point!

eventMarker.markEventReceived(sampleCustomResourceID);

assertThat(eventMarker.getEventingState(sampleCustomResourceID))
.isEqualTo(DELETE_AND_NON_DELETE_EVENT_PRESENT);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is this situation supposed to happen? When would 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.

Good point. So if we state that delete events are retried only when if finalizer is used. Or even in more general the deleteResource method is called in case we use finalizers. This actually might not make sense. This is the case now. So we receive a delete event we don't call the deleteResource method.

Will document this on deleteResource method for now. And remove this test, also change the marker.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Pushed changes, event marker changed quite a bit

@@ -6,12 +6,15 @@
public interface ResourceController<R extends CustomResource> {

/**
* Note that this method is used in combination of finalizers. If automatic finalizer handling is
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, that's a significant change. So if you don't have a finalizer, you don't get a chance to clean up associated components? That seems wrong to me, the SDK should always give the users the opportunity to clean things up, regardless of finalizers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The thing is, that users either use finalizers or all dependent resources are cleaned up using owner reference by kubernetes. Otherwise it's not correct. Typically if the operator is down, the delete event will be missed, and cleanup would not happen anyways. So I think it is actually good to force this pattern.

@@ -188,23 +195,29 @@ void eventProcessingFinished(
postExecutionControl);
unsetUnderExecution(executionScope.getCustomResourceID());

if (retry != null && postExecutionControl.exceptionDuringExecution()) {
// If a delete event present it was received during reconciliation.
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 this comment… :(

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tried to rephrase it.

csviri and others added 7 commits October 13, 2021 15:07
…tor/processing/EventMarker.java

Co-authored-by: Chris Laprun <metacosm@users.noreply.github.com>
…tor/processing/EventMarker.java

Co-authored-by: Chris Laprun <metacosm@users.noreply.github.com>
# Conflicts:
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/ResourceController.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/DefaultEventHandler.java
#	operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/DefaultEventSourceManager.java
#	operator-framework-core/src/test/java/io/javaoperatorsdk/operator/processing/DefaultEventHandlerTest.java
@csviri csviri merged commit 1dc1993 into v2 Oct 13, 2021
@csviri csviri deleted the removing-events-from-context branch October 13, 2021 14:54
metacosm added a commit that referenced this pull request Oct 28, 2021
* fix: WIP

* fix: Addressing Custom Resource by Name and Namespace refactor + Informer Cache WIP

* fix: Build is fixed, (test failing)

* fix: Test fixes

* fix: minor update

* fix: EventSourceManager small fix

* fix: Unit tests fixed

* fix: DefaultEventHandler init from EventSourceManager

* fix: custom resource selector test improvement

* fix: wip test imrpovements

* fix: test improvements

* fix: further improvements

* fix: build

* feature: add mvn jar to gitignore

* Exposing CustomResourceEventSource and informers

* fix: cleanup

* fix: remove caching optimization since it not possible anymore with informer

* fix:  formatting

* refactor: make name/namespace final

* feature: Simple label selector support

* fix: formatting

* fix: code inspection reports

* fix: merge from v2

* fix: removed most deprecated apis

* wip: started to remove events from variouse layers

* fix: progress with implementation and tests

* fix: Updated informer mapping to CustomResourceID

* fix: imports

* fix: decorational changes

* fix: event marker unit test

* Default Event Handler Unit tests

* fix: fixes after merge

* fix: changes from code review

* fix: method naming

* Update operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/EventMarker.java

Co-authored-by: Chris Laprun <metacosm@users.noreply.github.com>

* Update operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/EventMarker.java

Co-authored-by: Chris Laprun <metacosm@users.noreply.github.com>

* fix: comment

* fix: fixes from merge

* fix: remove not used method

* fix: formatting

Co-authored-by: Chris Laprun <metacosm@gmail.com>
Co-authored-by: Chris Laprun <metacosm@users.noreply.github.com>
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.

None yet

2 participants