Skip to content

fix: minor improvements #799

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

Merged
merged 4 commits into from
Jan 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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