Galsza commented on code in PR #5163:
URL: https://github.com/apache/ozone/pull/5163#discussion_r1309894573


##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SequenceIdGenerator.java:
##########
@@ -393,20 +398,35 @@ public static void upgradeToSequenceId(SCMMetadataStore 
scmMetadataStore)
           CONTAINER_ID, sequenceIdTable.get(CONTAINER_ID));
     }
 
-    // upgrade root certificate ID
-    if (sequenceIdTable.get(ROOT_CERTIFICATE_ID) == null) {
-      long largestRootCertId = BigInteger.ONE.longValueExact();
+    upgradeToCertificateSequenceId(scmMetadataStore, false);
+  }
+
+  public static void upgradeToCertificateSequenceId(
+      SCMMetadataStore scmMetadataStore, boolean force) throws IOException {
+    Table<String, Long> sequenceIdTable = 
scmMetadataStore.getSequenceIdTable();
+
+    // upgrade certificate ID table
+    if (sequenceIdTable.get(CERTIFICATE_ID) == null || force) {
+      // Start from ID 2.
+      // ID 1 - root certificate, ID 2 - first SCM certificate.
+      long largestCertId = BigInteger.ONE.add(BigInteger.ONE).longValueExact();

Review Comment:
   Okay, thanks for explaining it.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SequenceIdGenerator.java:
##########
@@ -416,17 +436,13 @@ public static void upgradeToSequenceId(SCMMetadataStore 
scmMetadataStore)
         while (iterator.hasNext()) {
           X509Certificate cert =
               iterator.next().getValue().getX509Certificate();
-          if (HASecurityUtils.isSelfSignedCertificate(cert) &&
-              HASecurityUtils.isCACertificate(cert)) {
-            largestRootCertId =
-                Long.max(cert.getSerialNumber().longValueExact(),
-                    largestRootCertId);
-          }
+          largestCertId = Long.max(

Review Comment:
   Yes, that's what I mean. In some other place we have encountered such an 
issue before. 



-- 
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