Skip to content

Commit 2dab16e

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent 54a0838 commit 2dab16e

File tree

4 files changed

+20
-17
lines changed

4 files changed

+20
-17
lines changed

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/MDCUtils.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,9 @@ public class MDCUtils {
3737

3838
private static final String EVENT_RESOURCE_NAME = "eventsource.event.resource.name";
3939
private static final String EVENT_RESOURCE_UID = "eventsource.event.resource.uid";
40-
private static final String EVENT_RESOURCE_NAMESPACE =
41-
"eventsource.event.resource.namespace";
40+
private static final String EVENT_RESOURCE_NAMESPACE = "eventsource.event.resource.namespace";
4241
private static final String EVENT_RESOURCE_KIND = "eventsource.event.resource.kind";
43-
private static final String EVENT_RESOURCE_VERSION =
44-
"eventsource.event.resource.resourceVersion";
42+
private static final String EVENT_RESOURCE_VERSION = "eventsource.event.resource.resourceVersion";
4543
private static final String EVENT_ACTION = "eventsource.event.action";
4644
private static final String EVENT_SOURCE_NAME = "eventsource.name";
4745

@@ -70,11 +68,13 @@ public static void removeInformerEventInfo() {
7068
}
7169
}
7270

73-
public static void withMDCForEvent(HasMetadata resource, Runnable runnable, String nameSourceName) {
74-
withMDCForEvent(resource,null,runnable,nameSourceName);
71+
public static void withMDCForEvent(
72+
HasMetadata resource, Runnable runnable, String nameSourceName) {
73+
withMDCForEvent(resource, null, runnable, nameSourceName);
7574
}
7675

77-
public static void withMDCForEvent(HasMetadata resource, ResourceAction action, Runnable runnable, String nameSourceName) {
76+
public static void withMDCForEvent(
77+
HasMetadata resource, ResourceAction action, Runnable runnable, String nameSourceName) {
7878
try {
7979
MDCUtils.addInformerEventInfo(resource, action, nameSourceName);
8080
runnable.run();
@@ -83,7 +83,7 @@ public static void withMDCForEvent(HasMetadata resource, ResourceAction action,
8383
}
8484
}
8585

86-
public static void withMDCForResourceID(ResourceID resourceID,Runnable runnable) {
86+
public static void withMDCForResourceID(ResourceID resourceID, Runnable runnable) {
8787
try {
8888
MDCUtils.addResourceIDInfo(resourceID);
8989
runnable.run();
@@ -92,7 +92,7 @@ public static void withMDCForResourceID(ResourceID resourceID,Runnable runnable)
9292
}
9393
}
9494

95-
public static void withMDCForPrimary(HasMetadata primary,Runnable runnable) {
95+
public static void withMDCForPrimary(HasMetadata primary, Runnable runnable) {
9696
try {
9797
MDCUtils.addResourceInfo(primary);
9898
runnable.run();
@@ -101,7 +101,6 @@ public static void withMDCForPrimary(HasMetadata primary,Runnable runnable) {
101101
}
102102
}
103103

104-
105104
public static void addResourceIDInfo(ResourceID resourceID) {
106105
if (enabled) {
107106
MDC.put(NAME, resourceID.getName());

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/controller/ControllerEventSource.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ public class ControllerEventSource<T extends HasMetadata>
4242
implements ResourceEventHandler<T> {
4343

4444
private static final Logger log = LoggerFactory.getLogger(ControllerEventSource.class);
45-
public static final String ControllerResourceEventSource = "ControllerResourceEventSource";
45+
public static final String CONTROLLER_RESOURCE_EVENT_SOURCE = "ControllerResourceEventSource";
4646

4747
private final Controller<T> controller;
4848

4949
@SuppressWarnings({"unchecked", "rawtypes"})
5050
public ControllerEventSource(Controller<T> controller) {
5151
super(
52-
ControllerResourceEventSource,
52+
CONTROLLER_RESOURCE_EVENT_SOURCE,
5353
controller.getCRClient(),
5454
controller.getConfiguration(),
5555
controller.getConfiguration().getInformerConfig().isComparableResourceVersions());
@@ -186,6 +186,6 @@ public void setOnDeleteFilter(OnDeleteFilter<? super T> onDeleteFilter) {
186186

187187
@Override
188188
public String name() {
189-
return ControllerResourceEventSource;
189+
return CONTROLLER_RESOURCE_EVENT_SOURCE;
190190
}
191191
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/ManagedInformerEventSource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,6 @@ public void setControllerConfiguration(ControllerConfiguration<R> controllerConf
269269
}
270270

271271
protected void withMDC(R resource, ResourceAction action, Runnable runnable) {
272-
MDCUtils.withMDCForEvent(resource,action,runnable, name());
272+
MDCUtils.withMDCForEvent(resource, action, runnable, name());
273273
}
274274
}

operator-framework/src/test/java/io/javaoperatorsdk/operator/dependent/informerrelatedbehavior/InformerRelatedBehaviorITS.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private void assertInformerNotWatchingForAdditionalNamespace(Operator operator)
158158
InformerHealthIndicator controllerHealthIndicator =
159159
(InformerHealthIndicator)
160160
unhealthyEventSources
161-
.get(ControllerEventSource.ControllerResourceEventSource)
161+
.get(ControllerEventSource.CONTROLLER_RESOURCE_EVENT_SOURCE)
162162
.informerHealthIndicators()
163163
.get(additionalNamespace);
164164
assertThat(controllerHealthIndicator).isNotNull();
@@ -306,14 +306,18 @@ private void assertRuntimeInfoNoCRPermission(Operator operator) {
306306
.unhealthyEventSources()
307307
.get(INFORMER_RELATED_BEHAVIOR_TEST_RECONCILER);
308308
assertThat(unhealthyEventSources).isNotEmpty();
309-
assertThat(unhealthyEventSources.get(ControllerEventSource.ControllerResourceEventSource)).isNotNull();
309+
assertThat(unhealthyEventSources.get(ControllerEventSource.CONTROLLER_RESOURCE_EVENT_SOURCE))
310+
.isNotNull();
310311
var informerHealthIndicators =
311312
operator
312313
.getRuntimeInfo()
313314
.unhealthyInformerWrappingEventSourceHealthIndicator()
314315
.get(INFORMER_RELATED_BEHAVIOR_TEST_RECONCILER);
315316
assertThat(informerHealthIndicators).isNotEmpty();
316-
assertThat(informerHealthIndicators.get(ControllerEventSource.ControllerResourceEventSource).informerHealthIndicators())
317+
assertThat(
318+
informerHealthIndicators
319+
.get(ControllerEventSource.CONTROLLER_RESOURCE_EVENT_SOURCE)
320+
.informerHealthIndicators())
317321
.hasSize(1);
318322
}
319323

0 commit comments

Comments
 (0)