Skip to content

Commit c05e1b1

Browse files
committed
wip
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
1 parent 5e09a95 commit c05e1b1

File tree

8 files changed

+23
-27
lines changed

8 files changed

+23
-27
lines changed

docs/content/en/docs/migration/v5-3-migration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Migrating from v5.2 to v5.3
44
---
55

66

7-
## Renamed JUnit Module
7+
## Rename of JUnit module
88

99
If you use JUnit extension in your test just rename it from:
1010

@@ -44,7 +44,7 @@ The following table shows the relevant method renames:
4444
| `finishedReconciliation` | `reconciliationFinished` |
4545
| `cleanupDoneFor` | `cleanupDone` |
4646
| `receivedEvent` | `eventReceived` |
47-
| `timeControllerExecution` | `timedControllerExecution` |
47+
4848

4949
Other changes:
5050
- `reconciliationFinished(..)` method is extended with `RetryInfo`

micrometer-support/src/main/java/io/javaoperatorsdk/operator/monitoring/micrometer/MicrometerMetrics.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public void controllerRegistered(Controller<? extends HasMetadata> controller) {
146146
}
147147

148148
@Override
149-
public <T> T timedControllerExecution(ControllerExecution<T> execution) {
149+
public <T> T timeControllerExecution(ControllerExecution<T> execution) {
150150
final var name = execution.controllerName();
151151
final var execName = PREFIX + CONTROLLERS_EXECUTION + execution.name();
152152
final var resourceID = execution.resourceID();

micrometer-support/src/main/java/io/javaoperatorsdk/operator/monitoring/micrometer/MicrometerMetricsV2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ private String numberOfResourcesRefName(String name) {
156156
}
157157

158158
@Override
159-
public <T> T timedControllerExecution(ControllerExecution<T> execution) {
159+
public <T> T timeControllerExecution(ControllerExecution<T> execution) {
160160
final var name = execution.controllerName();
161161
final var timer = executionTimers.get(name);
162162
return timer.record(

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/monitoring/AggregatedMetrics.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* All method calls are delegated to each metrics instance in the list in the order they were
3535
* provided to the constructor.
3636
*
37-
* <p><strong>Important:</strong> The {@link #timedControllerExecution(ControllerExecution)} method
37+
* <p><strong>Important:</strong> The {@link #timeControllerExecution(ControllerExecution)} method
3838
* is handled specially - it is only invoked on the first metrics instance in the list, since it's
3939
* not an idempotent operation and can only be executed once. The controller execution cannot be
4040
* repeated multiple times as it would produce side effects and potentially inconsistent results.
@@ -110,7 +110,7 @@ public void reconciliationSucceeded(HasMetadata resource, Map<String, Object> me
110110
}
111111

112112
@Override
113-
public <T> T timedControllerExecution(ControllerExecution<T> execution) throws Exception {
114-
return metricsList.get(0).timedControllerExecution(execution);
113+
public <T> T timeControllerExecution(ControllerExecution<T> execution) throws Exception {
114+
return metricsList.get(0).timeControllerExecution(execution);
115115
}
116116
}

operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/monitoring/Metrics.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ default void cleanupDone(ResourceID resourceID, Map<String, Object> metadata) {}
115115
* {@link io.javaoperatorsdk.operator.api.reconciler.Cleaner#cleanup(HasMetadata, Context)}. Note
116116
* that instances are automatically created for you by the SDK and passed to your Metrics
117117
* implementation at the appropriate time to the {@link
118-
* #timedControllerExecution(ControllerExecution)} method.
118+
* #timeControllerExecution(ControllerExecution)} method.
119119
*
120120
* @param <T> the outcome type associated with the controller execution. Currently, one of {@link
121121
* io.javaoperatorsdk.operator.api.reconciler.UpdateControl} or {@link
@@ -184,7 +184,7 @@ interface ControllerExecution<T> {
184184
* @throws Exception if an error occurred during the controller's execution, usually this should
185185
* just be a pass-through of whatever the controller returned
186186
*/
187-
default <T> T timedControllerExecution(ControllerExecution<T> execution) throws Exception {
187+
default <T> T timeControllerExecution(ControllerExecution<T> execution) throws Exception {
188188
return execution.execute();
189189
}
190190
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public Controller(
143143

144144
@Override
145145
public UpdateControl<P> reconcile(P resource, Context<P> context) throws Exception {
146-
return metrics.timedControllerExecution(
146+
return metrics.timeControllerExecution(
147147
new ControllerExecution<>() {
148148
@Override
149149
public String name() {
@@ -196,7 +196,7 @@ public UpdateControl<P> execute() throws Exception {
196196
@Override
197197
public DeleteControl cleanup(P resource, Context<P> context) {
198198
try {
199-
return metrics.timedControllerExecution(
199+
return metrics.timeControllerExecution(
200200
new ControllerExecution<>() {
201201
@Override
202202
public String name() {

operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/monitoring/AggregatedMetricsTest.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,30 +150,30 @@ void reconciliationSucceeded_shouldDelegateToAllMetricsInOrder() {
150150
}
151151

152152
@Test
153-
void timedControllerExecution_shouldOnlyDelegateToFirstMetrics() throws Exception {
153+
void timeControllerExecution_shouldOnlyDelegateToFirstMetrics() throws Exception {
154154
final var expectedResult = "execution result";
155-
when(metrics1.timedControllerExecution(controllerExecution)).thenReturn(expectedResult);
155+
when(metrics1.timeControllerExecution(controllerExecution)).thenReturn(expectedResult);
156156

157-
final var result = aggregatedMetrics.timedControllerExecution(controllerExecution);
157+
final var result = aggregatedMetrics.timeControllerExecution(controllerExecution);
158158

159159
assertThat(result).isEqualTo(expectedResult);
160-
verify(metrics1).timedControllerExecution(controllerExecution);
161-
verify(metrics2, never()).timedControllerExecution(any());
162-
verify(metrics3, never()).timedControllerExecution(any());
160+
verify(metrics1).timeControllerExecution(controllerExecution);
161+
verify(metrics2, never()).timeControllerExecution(any());
162+
verify(metrics3, never()).timeControllerExecution(any());
163163
verifyNoMoreInteractions(metrics1, metrics2, metrics3);
164164
}
165165

166166
@Test
167-
void timedControllerExecution_shouldPropagateException() throws Exception {
167+
void timeControllerExecution_shouldPropagateException() throws Exception {
168168
final var expectedException = new RuntimeException("Controller execution failed");
169-
when(metrics1.timedControllerExecution(controllerExecution)).thenThrow(expectedException);
169+
when(metrics1.timeControllerExecution(controllerExecution)).thenThrow(expectedException);
170170

171-
assertThatThrownBy(() -> aggregatedMetrics.timedControllerExecution(controllerExecution))
171+
assertThatThrownBy(() -> aggregatedMetrics.timeControllerExecution(controllerExecution))
172172
.isSameAs(expectedException);
173173

174-
verify(metrics1).timedControllerExecution(controllerExecution);
175-
verify(metrics2, never()).timedControllerExecution(any());
176-
verify(metrics3, never()).timedControllerExecution(any());
174+
verify(metrics1).timeControllerExecution(controllerExecution);
175+
verify(metrics2, never()).timeControllerExecution(any());
176+
verify(metrics3, never()).timeControllerExecution(any());
177177
verifyNoMoreInteractions(metrics1, metrics2, metrics3);
178178
}
179179
}

sample-operators/metrics-processing/src/test/java/io/javaoperatorsdk/operator/sample/metrics/MetricsHandlingE2E.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,12 @@ class MetricsHandlingE2E {
5252
static final Logger log = LoggerFactory.getLogger(MetricsHandlingE2E.class);
5353
static final String OBSERVABILITY_NAMESPACE = "observability";
5454
static final int PROMETHEUS_PORT = 9090;
55-
static final int GRAFANA_PORT = 3000;
5655
static final int OTEL_COLLECTOR_PORT = 4318;
5756
public static final Duration TEST_DURATION = Duration.ofSeconds(60);
5857
public static final String NAME_LABEL_KEY = "app.kubernetes.io/name";
5958

6059
private LocalPortForward prometheusPortForward;
6160
private LocalPortForward otelCollectorPortForward;
62-
private LocalPortForward grafanaPortForward;
6361

6462
static final KubernetesClient client = new KubernetesClientBuilder().build();
6563

@@ -90,7 +88,6 @@ void setupObservability() throws InterruptedException {
9088
if (isLocal()) {
9189
otelCollectorPortForward =
9290
portForward(NAME_LABEL_KEY, "otel-collector-collector", OTEL_COLLECTOR_PORT);
93-
grafanaPortForward = portForward(NAME_LABEL_KEY, "grafana", GRAFANA_PORT);
9491
}
9592
Thread.sleep(2000);
9693
}
@@ -99,7 +96,6 @@ void setupObservability() throws InterruptedException {
9996
void cleanup() throws IOException {
10097
closePortForward(prometheusPortForward);
10198
closePortForward(otelCollectorPortForward);
102-
closePortForward(grafanaPortForward);
10399
}
104100

105101
private LocalPortForward portForward(String labelKey, String labelValue, int port) {

0 commit comments

Comments
 (0)