ChenSammi commented on code in PR #3930:
URL: https://github.com/apache/ozone/pull/3930#discussion_r1015387400


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/security/x509/certificate/client/DefaultCertificateClient.java:
##########
@@ -705,13 +708,28 @@ public synchronized InitResponse init() throws 
CertificateException {
     if (certificate != null) {
       initCase = initCase | 1;
     }
+
+    Calendar shouldRenewAfter = Calendar.getInstance();
+    shouldRenewAfter
+        .add(Calendar.DAY_OF_YEAR, securityConfig.getRenewalGraceDays());
+    if (initCase == InitCase.ALL.ordinal() &&
+        handleExpiration() && certificate != null &&
+        certificate.getNotAfter().before(shouldRenewAfter.getTime())) {
+      InitCase init = InitCase.EXPIRES;
+      return handleCase(init);
+    }
+
     getLogger().info("Certificate client init case: {}", initCase);
     Preconditions.checkArgument(initCase < 8, "Not a " +
         "valid case.");
     InitCase init = InitCase.values()[initCase];
     return handleCase(init);
   }
 
+  protected boolean handleExpiration() {

Review Comment:
   Probably we can remove this API. Return cert expiration state from init(), 
and let handleCase handle the cert expiration. SCMCertificateClient and 
DefaultCertificateClient have its own  handleCase implementation. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to