Skip to content

Commit 619bf84

Browse files
committed
remove redundant logging
1 parent 51357a5 commit 619bf84

2 files changed

Lines changed: 1 addition & 38 deletions

File tree

src/main/java/com/uid2/operator/vertx/OperatorShutdownHandler.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@
1616
public class OperatorShutdownHandler {
1717
private static final Logger LOGGER = LoggerFactory.getLogger(OperatorShutdownHandler.class);
1818
private static final int SALT_FAILURE_LOG_INTERVAL_MINUTES = 10;
19-
private static final int KEYSET_KEY_FAILURE_LOG_INTERVAL_MINUTES = 10;
2019
private final Duration attestShutdownWaitTime;
2120
private final Duration saltShutdownWaitTime;
2221
private final Duration keysetKeyShutdownWaitTime;
2322
private final AtomicReference<Instant> attestFailureStartTime = new AtomicReference<>(null);
2423
private final AtomicReference<Instant> saltFailureStartTime = new AtomicReference<>(null);
2524
private final AtomicReference<Instant> keysetKeyFailureStartTime = new AtomicReference<>(null);
2625
private final AtomicReference<Instant> lastSaltFailureLogTime = new AtomicReference<>(null);
27-
private final AtomicReference<Instant> lastKeysetKeyFailureLogTime = new AtomicReference<>(null);
2826
private final Clock clock;
2927
private final ShutdownService shutdownService;
3028

@@ -65,7 +63,6 @@ public void handleKeysetKeyRefreshResponse(Boolean success) {
6563
keysetKeyFailureStartTime.set(null);
6664
LOGGER.debug("keyset keys sync successful");
6765
} else {
68-
logKeysetKeyFailureAtInterval();
6966
Instant t = keysetKeyFailureStartTime.get();
7067
if (t == null) {
7168
keysetKeyFailureStartTime.set(clock.instant());
@@ -84,14 +81,6 @@ public void handleKeysetKeyRefreshResponse(Boolean success) {
8481
}
8582
}
8683

87-
public void logKeysetKeyFailureAtInterval() {
88-
Instant t = lastKeysetKeyFailureLogTime.get();
89-
if (t == null || clock.instant().isAfter(t.plus(KEYSET_KEY_FAILURE_LOG_INTERVAL_MINUTES, ChronoUnit.MINUTES))) {
90-
LOGGER.error("keyset keys sync failing");
91-
lastKeysetKeyFailureLogTime.set(Instant.now());
92-
}
93-
}
94-
9584
public void handleAttestResponse(Pair<AttestationResponseCode, String> response) {
9685
if (response.left() == AttestationResponseCode.AttestationFailure) {
9786
LOGGER.error("core attestation failed with AttestationFailure, shutting down operator, core response: {}", response.right());

src/test/java/com/uid2/operator/OperatorShutdownHandlerTest.java

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ void shutdownOnKeysetKeyFailedTooLong(VertxTestContext testContext) {
174174
((Logger) LoggerFactory.getLogger(OperatorShutdownHandler.class)).addAppender(logWatcher);
175175

176176
this.operatorShutdownHandler.handleKeysetKeyRefreshResponse(false);
177-
Assertions.assertTrue(logWatcher.list.get(0).getFormattedMessage().contains("keyset keys sync failing"));
178-
Assertions.assertTrue(logWatcher.list.get(1).getFormattedMessage().contains("keyset keys sync started failing"));
177+
Assertions.assertTrue(logWatcher.list.get(0).getFormattedMessage().contains("keyset keys sync started failing"));
179178

180179
when(clock.instant()).thenAnswer(i -> Instant.now().plus(7, ChronoUnit.DAYS).plusSeconds(60));
181180
try {
@@ -203,31 +202,6 @@ void keysetKeyRecoverOnSuccess(VertxTestContext testContext) {
203202
testContext.completeNow();
204203
}
205204

206-
@Test
207-
void keysetKeyLogErrorAtInterval(VertxTestContext testContext) {
208-
ListAppender<ILoggingEvent> logWatcher = new ListAppender<>();
209-
logWatcher.start();
210-
((Logger) LoggerFactory.getLogger(OperatorShutdownHandler.class)).addAppender(logWatcher);
211-
212-
this.operatorShutdownHandler.handleKeysetKeyRefreshResponse(false);
213-
long errorLogCount1 = logWatcher.list.stream().filter(log ->
214-
log.getFormattedMessage().contains("keyset keys sync failing")).count();
215-
216-
when(clock.instant()).thenAnswer(i -> Instant.now().plus(9, ChronoUnit.MINUTES));
217-
this.operatorShutdownHandler.handleKeysetKeyRefreshResponse(false);
218-
long errorLogCount2 = logWatcher.list.stream().filter(log ->
219-
log.getFormattedMessage().contains("keyset keys sync failing")).count();
220-
Assertions.assertEquals(errorLogCount1, errorLogCount2);
221-
222-
when(clock.instant()).thenAnswer(i -> Instant.now().plus(11, ChronoUnit.MINUTES));
223-
this.operatorShutdownHandler.handleKeysetKeyRefreshResponse(false);
224-
long errorLogCount3 = logWatcher.list.stream().filter(log ->
225-
log.getFormattedMessage().contains("keyset keys sync failing")).count();
226-
Assertions.assertTrue(errorLogCount3 > errorLogCount2);
227-
228-
testContext.completeNow();
229-
}
230-
231205
@Test
232206
void keysetKeyNoShutdownWhenAlwaysSuccessful(VertxTestContext testContext) {
233207
this.operatorShutdownHandler.handleKeysetKeyRefreshResponse(true);

0 commit comments

Comments
 (0)