|
7 | 7 | import io.javaoperatorsdk.operator.api.reconciler.Context;
|
8 | 8 | import io.javaoperatorsdk.operator.api.reconciler.dependent.DependentResource;
|
9 | 9 |
|
10 |
| -/** |
11 |
| - * A condition implementation meant to be used as a delete post-condition on Kubernetes dependent |
12 |
| - * resources to prevent the workflow from proceeding until the associated resource is actually |
13 |
| - * deleted from the server (or, at least, doesn't have any finalizers anymore). This is needed in |
14 |
| - * cases where a cleaning process depends on resources being actually removed from the server |
15 |
| - * because, by default, workflows simply request the deletion but do NOT wait for the resources to |
16 |
| - * be actually deleted. |
17 |
| - */ |
18 |
| -public class KubernetesResourceDeletedCondition implements Condition<HasMetadata, HasMetadata> { |
19 | 10 |
|
20 |
| - private static final Logger logger = |
21 |
| - LoggerFactory.getLogger(KubernetesResourceDeletedCondition.class); |
| 11 | +public class KubernetesResourceDeletedCondition implements Condition<HasMetadata, HasMetadata> { |
22 | 12 |
|
23 | 13 | @Override
|
24 | 14 | public boolean isMet(
|
25 | 15 | DependentResource<HasMetadata, HasMetadata> dependentResource,
|
26 | 16 | HasMetadata primary,
|
27 | 17 | Context<HasMetadata> context) {
|
28 | 18 | var optionalResource = dependentResource.getSecondaryResource(primary, context);
|
29 |
| - if (optionalResource.isEmpty()) { |
30 |
| - if (logger.isDebugEnabled()) { |
31 |
| - logger.debug( |
32 |
| - "Resource not found in cache, considering it deleted. " |
33 |
| - + "Dependent resource name: {}, primary resource name: {}", |
34 |
| - dependentResource.name(), |
35 |
| - primary.getMetadata().getName()); |
36 |
| - } |
37 |
| - return true; |
38 |
| - } else { |
39 |
| - var finalizers = optionalResource.orElseThrow().getMetadata().getFinalizers(); |
40 |
| - if (logger.isDebugEnabled()) { |
41 |
| - logger.debug( |
42 |
| - "finalizers: {}, dependent resource name: {}, primary resource name: {}\"", |
43 |
| - finalizers, |
44 |
| - dependentResource.name(), |
45 |
| - primary.getMetadata().getName()); |
46 |
| - } |
47 |
| - return finalizers.isEmpty(); |
48 |
| - } |
| 19 | + return optionalResource.isEmpty(); |
49 | 20 | }
|
50 | 21 | }
|
0 commit comments