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 1 commit
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 @@ -99,6 +99,9 @@ public void onResourceDeleted(R resource) {

private void checkAndRegisterTask(R resource) {
var resourceID = ResourceID.fromResource(resource);
// Events are coming always from the same thread, no need for explicit locking for timerTasks
// related
// (multiple) operations in this method
Copy link
Collaborator

Choose a reason for hiding this comment

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

This comment is not quite clear to me…

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

improved, at least hope so :)

if (timerTasks.get(resourceID) == null && (registerPredicate == null
|| registerPredicate.test(resource))) {
var task = new TimerTask() {
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