Skip to content

Commit b437fef

Browse files
csviriiocaneldependabot[bot]metacosmlburgazzoli
committed
Informer based CustomResourceEventSource and caching (#581)
feat: This is a major change and backbone of v2. We change also how the Resources are addressed both internally and from event source with CustomResourceID. Additional improvements also added. * chore: renaming vars named k8sClient to kubernetsClient * chore(deps): bump jandex-maven-plugin from 1.1.1 to 1.2.1 (#592) Bumps [jandex-maven-plugin](https://github.com/wildfly/jandex-maven-plugin) from 1.1.1 to 1.2.1. - [Release notes](https://github.com/wildfly/jandex-maven-plugin/releases) - [Commits](wildfly/jandex-maven-plugin@1.1.1...1.2.1) --- updated-dependencies: - dependency-name: org.jboss.jandex:jandex-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * chore(deps-dev): bump mockito-core from 3.12.4 to 4.0.0 (#591) Bumps [mockito-core](https://github.com/mockito/mockito) from 3.12.4 to 4.0.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](mockito/mockito@v3.12.4...v4.0.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * feature: Build PR on v2 * chore(ci): use Java 17 * chore(ci): use only Temurin distribution * chore: add generics to PostExecutionControl to reduce IDEs noise (#594) * chore: polish the junit5 extension (#593) * feat: Use informers as CustomResourceEventSource backbone and cache Co-authored-by: Ioannis Canellos <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Chris Laprun <[email protected]> Co-authored-by: Luca Burgazzoli <[email protected]>
1 parent f188473 commit b437fef

File tree

48 files changed

+579
-877
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+579
-877
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ target/
1010

1111
# VSCode
1212
.factorypath
13+
14+
.mvn/wrapper/maven-wrapper.jar

micrometer-support/src/main/java/io/javaoperatorsdk/operator/micrometer/MicrometerMetrics.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import io.javaoperatorsdk.operator.Metrics;
77
import io.javaoperatorsdk.operator.processing.DefaultEventHandler.EventMonitor;
8+
import io.javaoperatorsdk.operator.processing.event.CustomResourceID;
89
import io.javaoperatorsdk.operator.processing.event.Event;
910
import io.micrometer.core.instrument.MeterRegistry;
1011
import io.micrometer.core.instrument.Timer;
@@ -15,12 +16,12 @@ public class MicrometerMetrics implements Metrics {
1516
private final MeterRegistry registry;
1617
private final EventMonitor monitor = new EventMonitor() {
1718
@Override
18-
public void processedEvent(String uid, Event event) {
19+
public void processedEvent(CustomResourceID uid, Event event) {
1920
incrementProcessedEventsNumber();
2021
}
2122

2223
@Override
23-
public void failedEvent(String uid, Event event) {
24+
public void failedEvent(CustomResourceID uid, Event event) {
2425
incrementControllerRetriesNumber();
2526
}
2627
};

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/ControllerUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static String getNameFor(Class<? extends ResourceController> controllerCl
1818
final var annotation = controllerClass.getAnnotation(Controller.class);
1919
if (annotation != null) {
2020
final var name = annotation.name();
21-
if (!Controller.NULL.equals(name)) {
21+
if (!Controller.EMPTY_STRING.equals(name)) {
2222
return name;
2323
}
2424
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/EventListUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import java.util.List;
44

5-
import io.fabric8.kubernetes.client.Watcher;
65
import io.javaoperatorsdk.operator.processing.event.Event;
76
import io.javaoperatorsdk.operator.processing.event.internal.CustomResourceEvent;
7+
import io.javaoperatorsdk.operator.processing.event.internal.ResourceAction;
88

99
public class EventListUtils {
1010

@@ -13,7 +13,7 @@ public static boolean containsCustomResourceDeletedEvent(List<Event> events) {
1313
.anyMatch(
1414
e -> {
1515
if (e instanceof CustomResourceEvent) {
16-
return ((CustomResourceEvent) e).getAction() == Watcher.Action.DELETED;
16+
return ((CustomResourceEvent) e).getAction() == ResourceAction.DELETED;
1717
} else {
1818
return false;
1919
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/Controller.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
@Target({ElementType.TYPE})
1212
public @interface Controller {
1313

14-
String NULL = "";
14+
String EMPTY_STRING = "";
1515
String WATCH_CURRENT_NAMESPACE = "JOSDK_WATCH_CURRENT";
1616
String NO_FINALIZER = "JOSDK_NO_FINALIZER";
1717

18-
String name() default NULL;
18+
String name() default EMPTY_STRING;
1919

2020
/**
2121
* Optional finalizer name, if it is not provided, one will be automatically generated. If the
@@ -24,7 +24,7 @@
2424
*
2525
* @return the finalizer name
2626
*/
27-
String finalizerName() default NULL;
27+
String finalizerName() default EMPTY_STRING;
2828

2929
/**
3030
* If true, will dispatch new event to the controller if generation increased since the last
@@ -50,7 +50,7 @@
5050
*
5151
* @return the label selector
5252
*/
53-
String labelSelector() default NULL;
53+
String labelSelector() default EMPTY_STRING;
5454

5555

5656
/**

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/AbstractControllerConfiguration.java

Lines changed: 0 additions & 35 deletions
This file was deleted.

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/DefaultControllerConfiguration.java

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public class DefaultControllerConfiguration<R extends CustomResource<?, ?>>
1919
private final RetryConfiguration retryConfiguration;
2020
private final String labelSelector;
2121
private final CustomResourceEventFilter<R> customResourceEventFilter;
22-
private Class<R> customResourceClass;
22+
private final Class<R> customResourceClass;
2323
private ConfigurationService service;
2424

2525
public DefaultControllerConfiguration(
@@ -54,29 +54,6 @@ public DefaultControllerConfiguration(
5454
setConfigurationService(service);
5555
}
5656

57-
@Deprecated
58-
public DefaultControllerConfiguration(
59-
String associatedControllerClassName,
60-
String name,
61-
String crdName,
62-
String finalizer,
63-
boolean generationAware,
64-
Set<String> namespaces,
65-
RetryConfiguration retryConfiguration) {
66-
this(
67-
associatedControllerClassName,
68-
name,
69-
crdName,
70-
finalizer,
71-
generationAware,
72-
namespaces,
73-
retryConfiguration,
74-
null,
75-
null,
76-
null,
77-
null);
78-
}
79-
8057
@Override
8158
public String getName() {
8259
return name;

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/CustomResourceCache.java

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)