Skip to content
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

improve: remove deprecated APIs #2375

Merged
merged 3 commits into from
May 16, 2024
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 @@ -59,20 +59,6 @@ public class MicrometerMetrics implements Metrics {
private final Map<String, AtomicInteger> gauges = new ConcurrentHashMap<>();
private final Cleaner cleaner;

/**
* Creates a default micrometer-based Metrics implementation, collecting metrics on a per resource
* basis and not dealing with cleaning these after these resources are deleted. Note that this
* probably will change in a future release. If you want more control over what the implementation
* actually does, please use the static factory methods instead.
*
* @param registry the {@link MeterRegistry} instance to use for metrics recording
* @deprecated Use the factory methods / builders instead
*/
@Deprecated
public MicrometerMetrics(MeterRegistry registry) {
this(registry, Cleaner.NOOP, true);
}

/**
* Creates a MicrometerMetrics instance configured to not collect per-resource metrics, just
* aggregates per resource **type**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Operator() {
}

Operator(KubernetesClient kubernetesClient) {
this(kubernetesClient, null);
this(initConfigurationService(kubernetesClient, null));
}

/**
Expand Down Expand Up @@ -63,19 +63,7 @@ public Operator(ConfigurationService configurationService) {
* {@link ConfigurationService} values
*/
public Operator(Consumer<ConfigurationServiceOverrider> overrider) {
this(null, overrider);
}

/**
* @param client client to use to all Kubernetes related operations
* @param overrider a {@link ConfigurationServiceOverrider} consumer used to override the default
* {@link ConfigurationService} values
* @deprecated Use {@link Operator#Operator(Consumer)} instead, passing your custom client with
* {@link ConfigurationServiceOverrider#withKubernetesClient(KubernetesClient)}
*/
@Deprecated(since = "4.4.0")
public Operator(KubernetesClient client, Consumer<ConfigurationServiceOverrider> overrider) {
this(initConfigurationService(client, overrider));
this(initConfigurationService(null, overrider));
}

private static ConfigurationService initConfigurationService(KubernetesClient client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ default boolean checkCRDAndValidateLocalModel() {
}

int DEFAULT_RECONCILIATION_THREADS_NUMBER = 50;
/**
* @deprecated Not used anymore in the default implementation
*/
@Deprecated(forRemoval = true)
int MIN_DEFAULT_RECONCILIATION_THREADS_NUMBER = 10;

/**
* The number of threads the operator can spin out to dispatch reconciliation requests to
Expand All @@ -144,23 +139,7 @@ default int concurrentReconciliationThreads() {
return DEFAULT_RECONCILIATION_THREADS_NUMBER;
}

/**
* The minimum number of threads the operator starts in the thread pool for reconciliations.
*
* @deprecated not used anymore by default executor implementation
* @return the minimum number of concurrent reconciliation threads
*/
@Deprecated(forRemoval = true)
default int minConcurrentReconciliationThreads() {
return MIN_DEFAULT_RECONCILIATION_THREADS_NUMBER;
}

int DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER = DEFAULT_RECONCILIATION_THREADS_NUMBER;
/**
* @deprecated Not used anymore in the default implementation
*/
@Deprecated(forRemoval = true)
int MIN_DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER = MIN_DEFAULT_RECONCILIATION_THREADS_NUMBER;

/**
* Number of threads the operator can spin out to be used in the workflows with the default
Expand All @@ -172,17 +151,6 @@ default int concurrentWorkflowExecutorThreads() {
return DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER;
}

/**
* The minimum number of threads the operator starts in the thread pool for workflows.
*
* @deprecated not used anymore by default executor implementation
* @return the minimum number of concurrent workflow threads
*/
@Deprecated(forRemoval = true)
default int minConcurrentWorkflowExecutorThreads() {
return MIN_DEFAULT_WORKFLOW_EXECUTOR_THREAD_NUMBER;
}

default Metrics getMetrics() {
return Metrics.NOOP;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.function.Consumer;
import java.util.function.Function;

import org.slf4j.Logger;
Expand All @@ -23,9 +22,7 @@ public class ConfigurationServiceOverrider {
private Metrics metrics;
private Boolean checkCR;
private Integer concurrentReconciliationThreads;
private Integer minConcurrentReconciliationThreads;
private Integer concurrentWorkflowExecutorThreads;
private Integer minConcurrentWorkflowExecutorThreads;
private Cloner cloner;
private Boolean closeClientOnStop;
private KubernetesClient client;
Expand All @@ -42,6 +39,7 @@ public class ConfigurationServiceOverrider {
private Boolean parseResourceVersions;
private Boolean useSSAToPatchPrimaryResource;
private Boolean cloneSecondaryResourcesWhenGettingFromCache;
@SuppressWarnings("rawtypes")
private DependentResourceFactory dependentResourceFactory;

ConfigurationServiceOverrider(ConfigurationService original) {
Expand All @@ -63,24 +61,7 @@ public ConfigurationServiceOverrider withConcurrentWorkflowExecutorThreads(int t
return this;
}

private int minimumMaxValueFor(Integer minValue) {
return minValue != null ? (minValue < 0 ? 0 : minValue) + 1 : 1;
}

public ConfigurationServiceOverrider withMinConcurrentReconciliationThreads(int threadNumber) {
this.minConcurrentReconciliationThreads = Utils.ensureValid(threadNumber,
"minimum reconciliation threads", ExecutorServiceManager.MIN_THREAD_NUMBER,
original.minConcurrentReconciliationThreads());
return this;
}

public ConfigurationServiceOverrider withMinConcurrentWorkflowExecutorThreads(int threadNumber) {
this.minConcurrentWorkflowExecutorThreads = Utils.ensureValid(threadNumber,
"minimum workflow execution threads", ExecutorServiceManager.MIN_THREAD_NUMBER,
original.minConcurrentWorkflowExecutorThreads());
return this;
}

@SuppressWarnings("rawtypes")
public ConfigurationServiceOverrider withDependentResourceFactory(
DependentResourceFactory dependentResourceFactory) {
this.dependentResourceFactory = dependentResourceFactory;
Expand Down Expand Up @@ -219,7 +200,7 @@ public int concurrentReconciliationThreads() {
overriddenValueOrDefault(concurrentReconciliationThreads,
ConfigurationService::concurrentReconciliationThreads),
"maximum reconciliation threads",
minimumMaxValueFor(minConcurrentReconciliationThreads),
1,
original.concurrentReconciliationThreads());
}

Expand All @@ -229,30 +210,10 @@ public int concurrentWorkflowExecutorThreads() {
overriddenValueOrDefault(concurrentWorkflowExecutorThreads,
ConfigurationService::concurrentWorkflowExecutorThreads),
"maximum workflow execution threads",
minimumMaxValueFor(minConcurrentWorkflowExecutorThreads),
1,
original.concurrentWorkflowExecutorThreads());
}

/**
* @deprecated Not used anymore in the default implementation
*/
@Deprecated(forRemoval = true)
@Override
public int minConcurrentReconciliationThreads() {
return overriddenValueOrDefault(minConcurrentReconciliationThreads,
ConfigurationService::minConcurrentReconciliationThreads);
}

/**
* @deprecated Not used anymore in the default implementation
*/
@Override
@Deprecated(forRemoval = true)
public int minConcurrentWorkflowExecutorThreads() {
return overriddenValueOrDefault(minConcurrentWorkflowExecutorThreads,
ConfigurationService::minConcurrentWorkflowExecutorThreads);
}

@Override
public Metrics getMetrics() {
return overriddenValueOrDefault(metrics, ConfigurationService::getMetrics);
Expand Down Expand Up @@ -341,15 +302,4 @@ public boolean cloneSecondaryResourcesWhenGettingFromCache() {
};
}

/**
* @deprecated Use
* {@link ConfigurationService#newOverriddenConfigurationService(ConfigurationService, Consumer)}
* instead
* @param original that will be overridden
* @return current overrider
*/
@Deprecated(since = "2.2.0")
public static ConfigurationServiceOverrider override(ConfigurationService original) {
return new ConfigurationServiceOverrider(original);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
public class ExecutorServiceManager {

private static final Logger log = LoggerFactory.getLogger(ExecutorServiceManager.class);
public static final int MIN_THREAD_NUMBER = 0;
private ExecutorService executor;
private ExecutorService workflowExecutor;
private ExecutorService cachingExecutorService;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.javaoperatorsdk.operator.api.monitoring;

import java.util.Collections;
import java.util.Map;

import io.fabric8.kubernetes.api.model.HasMetadata;
Expand Down Expand Up @@ -37,16 +36,6 @@ default void controllerRegistered(Controller<? extends HasMetadata> controller)
*/
default void receivedEvent(Event event, Map<String, Object> metadata) {}

/**
* @param metadata additional metadata
* @param resourceID of primary resource
* @param retryInfo for current execution
* @deprecated Use {@link #reconcileCustomResource(HasMetadata, RetryInfo, Map)} instead
*/
@Deprecated(forRemoval = true)
@SuppressWarnings("unused")
default void reconcileCustomResource(ResourceID resourceID, RetryInfo retryInfo,
Map<String, Object> metadata) {}

/**
* Called right before a resource is dispatched to the ExecutorService for reconciliation.
Expand All @@ -56,19 +45,6 @@ default void reconcileCustomResource(ResourceID resourceID, RetryInfo retryInfo,
* @param metadata metadata associated with the resource being processed
*/
default void reconcileCustomResource(HasMetadata resource, RetryInfo retryInfo,
Map<String, Object> metadata) {
reconcileCustomResource(ResourceID.fromResource(resource), retryInfo, metadata);
}

/**
* @param exception actual exception
* @param metadata additional metadata
* @param resourceID of primary resource
* @deprecated Use {@link #failedReconciliation(HasMetadata, Exception, Map)} instead
*/
@Deprecated(forRemoval = true)
@SuppressWarnings("unused")
default void failedReconciliation(ResourceID resourceID, Exception exception,
Map<String, Object> metadata) {}

/**
Expand All @@ -81,24 +57,14 @@ default void failedReconciliation(ResourceID resourceID, Exception exception,
* @param metadata metadata associated with the resource being processed
*/
default void failedReconciliation(HasMetadata resource, Exception exception,
Map<String, Object> metadata) {
failedReconciliation(ResourceID.fromResource(resource), exception, metadata);
}
Map<String, Object> metadata) {}


default void reconciliationExecutionStarted(HasMetadata resource, Map<String, Object> metadata) {}

default void reconciliationExecutionFinished(HasMetadata resource,
Map<String, Object> metadata) {}

/**
* @param resourceID of primary resource
* @deprecated Use (and implement) {@link #cleanupDoneFor(ResourceID, Map)} instead
*/
@Deprecated
default void cleanupDoneFor(ResourceID resourceID) {
cleanupDoneFor(resourceID, Collections.emptyMap());
}

/**
* Called when the resource associated with the specified {@link ResourceID} has been successfully
Expand All @@ -109,24 +75,6 @@ default void cleanupDoneFor(ResourceID resourceID) {
*/
default void cleanupDoneFor(ResourceID resourceID, Map<String, Object> metadata) {}

/**
* @param resourceID of primary resource
* @deprecated Use (and implement) {@link #finishedReconciliation(ResourceID, Map)} instead
*/
@Deprecated
default void finishedReconciliation(ResourceID resourceID) {
finishedReconciliation(resourceID, Collections.emptyMap());
}

/**
* @param resourceID of primary resource
* @param metadata additional metadata
* @deprecated Use {@link #finishedReconciliation(HasMetadata, Map)} instead
*/
@Deprecated(forRemoval = true)
@SuppressWarnings("unused")
default void finishedReconciliation(ResourceID resourceID, Map<String, Object> metadata) {}

/**
* Called when the
* {@link io.javaoperatorsdk.operator.api.reconciler.Reconciler#reconcile(HasMetadata, Context)}
Expand All @@ -136,9 +84,7 @@ default void finishedReconciliation(ResourceID resourceID, Map<String, Object> m
* @param resource the {@link ResourceID} associated with the resource being processed
* @param metadata metadata associated with the resource being processed
*/
default void finishedReconciliation(HasMetadata resource, Map<String, Object> metadata) {
finishedReconciliation(ResourceID.fromResource(resource), metadata);
}
default void finishedReconciliation(HasMetadata resource, Map<String, Object> metadata) {}

/**
* Encapsulates the information about a controller execution i.e. a call to either
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,6 @@ public KubernetesDependentResourceConfig(Set<String> namespaces,
this.useSSA = useSSA;
}

// use builder instead
@Deprecated(forRemoval = true)
public KubernetesDependentResourceConfig(Set<String> namespaces, String labelSelector) {
this(namespaces, labelSelector, true, DEFAULT_CREATE_RESOURCE_ONLY_IF_NOT_EXISTING_WITH_SSA,
null, null,
null, null, null);
}

// use builder instead
@Deprecated(forRemoval = true)
public KubernetesDependentResourceConfig<R> setLabelSelector(String labelSelector) {
this.labelSelector = labelSelector;
return this;
}

public Set<String> namespaces() {
return namespaces;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource;
import io.javaoperatorsdk.operator.api.reconciler.dependent.EventSourceReferencer;
import io.javaoperatorsdk.operator.api.reconciler.dependent.NameSetter;
import io.javaoperatorsdk.operator.api.reconciler.dependent.managed.KubernetesClientAware;

import static io.javaoperatorsdk.operator.api.reconciler.Constants.NO_VALUE_SET;

Expand Down Expand Up @@ -112,10 +111,6 @@ private <R> DependentResource<R, P> resolve(DependentResourceSpec<R, P> spec,
((NameSetter) dependentResource).setName(name);
}

if (dependentResource instanceof KubernetesClientAware) {
((KubernetesClientAware) dependentResource).setKubernetesClient(client);
}

spec.getUseEventSourceWithName()
.ifPresent(esName -> {
if (dependentResource instanceof EventSourceReferencer) {
Expand Down
Loading
Loading