Skip to content

Commit

Permalink
fix: minor improvements (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
csviri authored Jan 7, 2022
1 parent 3061d2b commit fd6e493
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ public class EventSourceManager<R extends HasMetadata> implements LifecycleAware
EventSourceManager(EventProcessor<R> eventProcessor) {
this.eventProcessor = eventProcessor;
controller = null;
registerEventSource(eventSources.initRetryEventSource());
registerEventSource(eventSources.retryEventSource());
}

public EventSourceManager(Controller<R> controller) {
this.controller = controller;
// controller event source needs to be available before we create the event processor
final var controllerEventSource = eventSources.initControllerEventSource(controller);
this.eventProcessor = new EventProcessor<>(this);
registerEventSource(eventSources.initRetryEventSource());
registerEventSource(eventSources.retryEventSource());
registerEventSource(controllerEventSource);
}

Expand Down Expand Up @@ -184,7 +184,7 @@ ControllerResourceEventSource<R> initControllerEventSource(Controller<R> control
return controllerResourceEventSource;
}

TimerEventSource<R> initRetryEventSource() {
TimerEventSource<R> retryEventSource() {
return retryAndRescheduleTimerEventSource;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public final class ResourceEventFilters {
private static final ResourceEventFilter<HasMetadata> GENERATION_AWARE =
(configuration, oldResource, newResource) -> {
final var generationAware = configuration.isGenerationAware();
// todo: change this to check for HasStatus (or similar) when
// https://github.com/fabric8io/kubernetes-client/issues/3586 is fixed
if (newResource instanceof CustomResource<?, ?>) {
var newCustomResource = (CustomResource<?, ?>) newResource;
final var status = newCustomResource.getStatus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ public void onResourceDeleted(R resource) {
cache.remove(resourceID);
}

// This method is always called from the same Thread for the same resource,
// since events from ResourceEventAware are propagated from the thread of the informer. This is
// important
// because otherwise there will be a race condition related to the timerTasks.
private void checkAndRegisterTask(R resource) {
var resourceID = ResourceID.fromResource(resource);
if (timerTasks.get(resourceID) == null && (registerPredicate == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ public static void main(String[] args) throws IOException {
KubernetesClient client = new DefaultKubernetesClient(config);
Operator operator = new Operator(client, DefaultConfigurationService.instance());
operator.register(new MySQLSchemaReconciler(client, MySQLDbConfig.loadFromEnvironmentVars()));
operator.installShutdownHook();
operator.start();


new FtBasic(new TkFork(new FkRegex("/health", "ALL GOOD!")), 8080).start(Exit.NEVER);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static void main(String[] args) throws IOException {
Operator operator = new Operator(client, DefaultConfigurationService.instance());
operator.register(new TomcatReconciler(client));
operator.register(new WebappReconciler(client));
operator.installShutdownHook();
operator.start();

new FtBasic(new TkFork(new FkRegex("/health", "ALL GOOD.")), 8080).start(Exit.NEVER);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public static void main(String[] args) throws IOException {
KubernetesClient client = new DefaultKubernetesClient(config);
Operator operator = new Operator(client, DefaultConfigurationService.instance());
operator.register(new WebPageReconciler(client));
operator.installShutdownHook();
operator.start();

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

0 comments on commit fd6e493

Please sign in to comment.