fix: minor improvements (#799) · andreaTP/java-operator-sdk@fd6e493 · GitHub
Skip to content

Commit fd6e493

Browse files
authored
fix: minor improvements (operator-framework#799)
1 parent 3061d2b commit fd6e493

6 files changed

Lines changed: 11 additions & 5 deletions

File tree

‎operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/EventSourceManager.java‎

Lines changed: 3 additions & 3 deletions

‎operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/controller/ResourceEventFilters.java‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ public final class ResourceEventFilters {
2525
private static final ResourceEventFilter<HasMetadata> GENERATION_AWARE =
2626
(configuration, oldResource, newResource) -> {
2727
final var generationAware = configuration.isGenerationAware();
28-
// todo: change this to check for HasStatus (or similar) when
29-
// https://github.com/fabric8io/kubernetes-client/issues/3586 is fixed
3028
if (newResource instanceof CustomResource<?, ?>) {
3129
var newCustomResource = (CustomResource<?, ?>) newResource;
3230
final var status = newCustomResource.getStatus();

‎operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/polling/PerResourcePollingEventSource.java‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ public void onResourceDeleted(R resource) {
9797
cache.remove(resourceID);
9898
}
9999

100+
// This method is always called from the same Thread for the same resource,
101+
// since events from ResourceEventAware are propagated from the thread of the informer. This is
102+
// important
103+
// because otherwise there will be a race condition related to the timerTasks.
100104
private void checkAndRegisterTask(R resource) {
101105
var resourceID = ResourceID.fromResource(resource);
102106
if (timerTasks.get(resourceID) == null && (registerPredicate == null

‎sample-operators/mysql-schema/src/main/java/io/javaoperatorsdk/operator/sample/MySQLSchemaOperator.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ public static void main(String[] args) throws IOException {
2727
KubernetesClient client = new DefaultKubernetesClient(config);
2828
Operator operator = new Operator(client, DefaultConfigurationService.instance());
2929
operator.register(new MySQLSchemaReconciler(client, MySQLDbConfig.loadFromEnvironmentVars()));
30+
operator.installShutdownHook();
3031
operator.start();
3132

33+
3234
new FtBasic(new TkFork(new FkRegex("/health", "ALL GOOD!")), 8080).start(Exit.NEVER);
3335
}
3436
}

‎sample-operators/tomcat-operator/src/main/java/io/javaoperatorsdk/operator/sample/TomcatOperator.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public static void main(String[] args) throws IOException {
2727
Operator operator = new Operator(client, DefaultConfigurationService.instance());
2828
operator.register(new TomcatReconciler(client));
2929
operator.register(new WebappReconciler(client));
30+
operator.installShutdownHook();
3031
operator.start();
3132

3233
new FtBasic(new TkFork(new FkRegex("/health", "ALL GOOD.")), 8080).start(Exit.NEVER);

‎sample-operators/webpage/src/main/java/io/javaoperatorsdk/operator/sample/WebPageOperator.java‎

Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)