diff --git a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/client/DefaultCertificateClient.java b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/client/DefaultCertificateClient.java index 8cf5e9d50b08..698b44ac9ac1 100644 --- a/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/client/DefaultCertificateClient.java +++ b/hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/client/DefaultCertificateClient.java @@ -1343,7 +1343,9 @@ public synchronized void startCertificateRenewerService() { this.executorService.scheduleAtFixedRate( new CertificateRenewerService(false, () -> { }), - timeBeforeGracePeriod, interval, TimeUnit.MILLISECONDS); + // The Java mills resolution is 1ms, add 1ms to avoid task scheduled + // ahead of time. + timeBeforeGracePeriod + 1, interval, TimeUnit.MILLISECONDS); getLogger().info("CertificateRenewerService for {} is started with " + "first delay {} ms and interval {} ms.", component, timeBeforeGracePeriod, interval); @@ -1376,6 +1378,9 @@ public void run() { Duration timeLeft = timeBeforeExpiryGracePeriod(currentCert); if (!forceRenewal && !timeLeft.isZero()) { + getLogger().info("Current certificate {} hasn't entered the " + + "renew grace period. Remaining period is {}. ", + currentCert.getSerialNumber().toString(), timeLeft); return; } String newCertId;