1616public 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 ;
1920 private final Duration attestShutdownWaitTime ;
2021 private final Duration saltShutdownWaitTime ;
2122 private final Duration keysetKeyShutdownWaitTime ;
2223 private final AtomicReference <Instant > attestFailureStartTime = new AtomicReference <>(null );
2324 private final AtomicReference <Instant > saltFailureStartTime = new AtomicReference <>(null );
2425 private final AtomicReference <Instant > keysetKeyFailureStartTime = new AtomicReference <>(null );
2526 private final AtomicReference <Instant > lastSaltFailureLogTime = new AtomicReference <>(null );
27+ private final AtomicReference <Instant > lastKeysetKeyFailureLogTime = new AtomicReference <>(null );
2628 private final Clock clock ;
2729 private final ShutdownService shutdownService ;
2830
@@ -61,18 +63,17 @@ public void logSaltFailureAtInterval() {
6163 public void handleKeysetKeyRefreshResponse (Boolean success ) {
6264 if (success ) {
6365 keysetKeyFailureStartTime .set (null );
66+ lastKeysetKeyFailureLogTime .set (null );
6467 LOGGER .debug ("keyset keys sync successful" );
6568 } else {
6669 Instant t = keysetKeyFailureStartTime .get ();
6770 if (t == null ) {
6871 keysetKeyFailureStartTime .set (clock .instant ());
72+ lastKeysetKeyFailureLogTime .set (clock .instant ());
6973 LOGGER .warn ("keyset keys sync started failing. shutdown timer started" );
7074 } else {
75+ logKeysetKeyFailureProgressAtInterval (t );
7176 Duration elapsed = Duration .between (t , clock .instant ());
72- LOGGER .debug ("keyset keys sync still failing - elapsed time: {}d {}h {}m" ,
73- elapsed .toDays (),
74- elapsed .toHoursPart (),
75- elapsed .toMinutesPart ());
7677 if (elapsed .compareTo (this .keysetKeyShutdownWaitTime ) > 0 ) {
7778 LOGGER .error ("keyset keys have been failing to sync for too long. shutting down operator" );
7879 this .shutdownService .Shutdown (1 );
@@ -81,6 +82,18 @@ public void handleKeysetKeyRefreshResponse(Boolean success) {
8182 }
8283 }
8384
85+ private void logKeysetKeyFailureProgressAtInterval (Instant failureStartTime ) {
86+ Instant lastLogTime = lastKeysetKeyFailureLogTime .get ();
87+ if (lastLogTime == null || clock .instant ().isAfter (lastLogTime .plus (KEYSET_KEY_FAILURE_LOG_INTERVAL_MINUTES , ChronoUnit .MINUTES ))) {
88+ Duration elapsed = Duration .between (failureStartTime , clock .instant ());
89+ LOGGER .warn ("keyset keys sync still failing - elapsed time: {}d {}h {}m" ,
90+ elapsed .toDays (),
91+ elapsed .toHoursPart (),
92+ elapsed .toMinutesPart ());
93+ lastKeysetKeyFailureLogTime .set (clock .instant ());
94+ }
95+ }
96+
8497 public void handleAttestResponse (Pair <AttestationResponseCode , String > response ) {
8598 if (response .left () == AttestationResponseCode .AttestationFailure ) {
8699 LOGGER .error ("core attestation failed with AttestationFailure, shutting down operator, core response: {}" , response .right ());
0 commit comments