|
17 | 17 | import io.fabric8.kubernetes.client.dsl.Resource;
|
18 | 18 | import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
|
19 | 19 | import io.javaoperatorsdk.operator.OperatorException;
|
| 20 | +import io.javaoperatorsdk.operator.ReconcilerUtils; |
20 | 21 | import io.javaoperatorsdk.operator.api.config.Cloner;
|
21 | 22 | import io.javaoperatorsdk.operator.api.config.ConfigurationServiceProvider;
|
22 | 23 | import io.javaoperatorsdk.operator.api.config.ResourceConfiguration;
|
@@ -104,14 +105,15 @@ private InformerWrapper<T> createEventSource(
|
104 | 105 |
|
105 | 106 | @Override
|
106 | 107 | public void stop() {
|
107 |
| - for (InformerWrapper<T> source : sources.values()) { |
| 108 | + log.info("Stopping {}", this); |
| 109 | + sources.forEach((ns, source) -> { |
108 | 110 | try {
|
109 |
| - log.info("Stopping informer {} -> {}", this, source); |
| 111 | + log.debug("Stopping informer for namespace: {} -> {}", ns, source); |
110 | 112 | source.stop();
|
111 | 113 | } catch (Exception e) {
|
112 |
| - log.warn("Error stopping informer {} -> {}", this, source, e); |
| 114 | + log.warn("Error stopping informer for namespace: {} -> {}", ns, source, e); |
113 | 115 | }
|
114 |
| - } |
| 116 | + }); |
115 | 117 | }
|
116 | 118 |
|
117 | 119 | @Override
|
@@ -167,4 +169,14 @@ public List<T> byIndex(String indexName, String indexKey) {
|
167 | 169 | return sources.values().stream().map(s -> s.byIndex(indexName, indexKey))
|
168 | 170 | .flatMap(List::stream).collect(Collectors.toList());
|
169 | 171 | }
|
| 172 | + |
| 173 | + @Override |
| 174 | + public String toString() { |
| 175 | + final var selector = configuration.getLabelSelector(); |
| 176 | + return "InformerManager [" |
| 177 | + + ReconcilerUtils.getResourceTypeNameWithVersion(configuration.getResourceClass()) |
| 178 | + + "] watching: " |
| 179 | + + configuration.getEffectiveNamespaces() |
| 180 | + + (selector != null ? " selector: " + selector : ""); |
| 181 | + } |
170 | 182 | }
|
0 commit comments