|
2 | 2 |
|
3 | 3 | import io.fabric8.kubernetes.api.model.HasMetadata;
|
4 | 4 | import io.javaoperatorsdk.operator.api.reconciler.Context;
|
| 5 | +import org.slf4j.Logger; |
| 6 | +import org.slf4j.LoggerFactory; |
5 | 7 |
|
6 | 8 | public abstract class AbstractDependentResource<R, P extends HasMetadata>
|
7 | 9 | implements DependentResource<R, P> {
|
| 10 | + private static final Logger log = LoggerFactory.getLogger(AbstractDependentResource.class); |
8 | 11 |
|
9 | 12 | private final boolean creatable = this instanceof Creator;
|
10 | 13 | private final boolean updatable = this instanceof Updater;
|
@@ -33,14 +36,22 @@ public void reconcile(P primary, Context context) {
|
33 | 36 | var desired = desired(primary, context);
|
34 | 37 | if (maybeActual.isEmpty()) {
|
35 | 38 | if (creatable) {
|
| 39 | + log.debug("Creating dependent {} for primary {}", desired, primary); |
36 | 40 | creator.create(desired, primary, context);
|
37 | 41 | }
|
38 | 42 | } else {
|
39 | 43 | final var actual = maybeActual.get();
|
40 | 44 | if (updatable && !updater.match(actual, desired, context)) {
|
| 45 | + log.debug("Updating dependent {} for primary {}", desired, primary); |
41 | 46 | updater.update(actual, desired, primary, context);
|
| 47 | + } else { |
| 48 | + log.debug("Update skipped for dependent {} as it matched the existing one", desired); |
42 | 49 | }
|
43 | 50 | }
|
| 51 | + } else { |
| 52 | + log.debug( |
| 53 | + "Dependent {} is read-only, implement Creator and/or Updater interfaces to modify it", |
| 54 | + getClass().getSimpleName()); |
44 | 55 | }
|
45 | 56 | }
|
46 | 57 |
|
|
0 commit comments