You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/02/19 06:20:07 UTC

[GitHub] [ozone] bharatviswa504 commented on a change in pull request #1921: HDDS-4822. Implement scm --bootstrap command.

bharatviswa504 commented on a change in pull request #1921:
URL: https://github.com/apache/ozone/pull/1921#discussion_r578954612



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java
##########
@@ -681,6 +688,60 @@ public static String buildRpcServerStartMessage(String description,
     return rpcServer;
   }
 
+  /**
+   * Routine to bootstrap the StorageContainerManager. Thsi will connect to a
+   * running SCM instance which has valid cluster id and fetch the cluster id
+   * from there. SCM ids will be also be exchanged here.
+   *
+   * TODO: once SCM HA security is enabled, CSR cerificates will be fetched from
+   * running scm leader instance as well.
+   *
+   * @param conf OzoneConfiguration
+   * @return true if SCM bootstrap is successful, false otherwise.
+   * @throws IOException if init fails due to I/O error
+   */
+  public static boolean scmBootstrap(OzoneConfiguration conf)
+      throws IOException {
+    if (!SCMHAUtils.isSCMHAEnabled(conf)) {
+      LOG.error("Bootstrap is not supported without SCM HA.");
+      return false;
+    }
+    // The node here will try to fetch the cluster id from any of existing
+    // running SCM instances.
+    // TODO: need to avoid failover to local SCM Node here
+    final ScmInfo scmInfo = HAUtils.getScmInfo(conf);
+    SCMStorageConfig scmStorageConfig = new SCMStorageConfig(conf);
+    final String persistedClusterId = scmStorageConfig.getClusterID();
+    final String fetchedId = scmInfo.getClusterId();
+    Preconditions.checkNotNull(fetchedId);
+    StorageState state = scmStorageConfig.getState();
+    if (state != StorageState.INITIALIZED) {
+      Preconditions.checkNotNull(scmStorageConfig.getScmId());
+      if (fetchedId != persistedClusterId) {
+        LOG.error(
+            "Could not bootstrap as SCM is already initialized with cluster "
+                + "id {} but cluster id for existing running SCM instance "
+                + "is {}", persistedClusterId, fetchedId);
+        return false;
+      }
+    } else {
+      try {
+        scmStorageConfig.setClusterId(fetchedId);
+        // It will write down the cluster Id fetched from already
+        // running SCM as well as the local SCM Id.
+
+        // SCM Node info containing hostname to scm Id mappings
+        // will be persisted into the version file once this node gets added
+        // to existing SCM ring post node regular start up.

Review comment:
       Question: Now we have scmId and scmNodeInfo with scmId and host mapping.
   Do we plan to remove scmId for the newer version or how it will be handled for upgrade?
   
   




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org