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/05/18 17:23:19 UTC

[GitHub] [ozone] errose28 commented on a change in pull request #2257: HDDS-5226. Do not fail SCM HA pre-finalize validation if SCM HA was already being used.

errose28 commented on a change in pull request #2257:
URL: https://github.com/apache/ozone/pull/2257#discussion_r634601649



##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java
##########
@@ -1158,6 +1158,8 @@ public String getDatanodeRpcPort() {
    */
   @Override
   public void start() throws IOException {
+    upgradeFinalizer.runPrefinalizeStateActions(scmStorageConfig, this);

Review comment:
       In the current implementation init will succeed but start will fail. Init does not need to be run in the new version before the new bits are started, but it shouldn't hurt either. I did not realize we were also starting a ratis server in SCM init, so we should probably run the upgrade actions there too, yes. This shouldn't affect new SCMs since they will be finalized and the actions will not run.

##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/ScmHAUnfinalizedStateValidationAction.java
##########
@@ -37,13 +45,22 @@
   public void execute(StorageContainerManager scm) throws Exception {
     boolean isHAEnabled =
         scm.getConfiguration().getBoolean(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY,
-        ScmConfigKeys.OZONE_SCM_HA_ENABLE_DEFAULT);
+            ScmConfigKeys.OZONE_SCM_HA_ENABLE_DEFAULT);
 
     if (isHAEnabled) {
-      throw new UpgradeException(String.format("Configuration %s cannot be " +
-          "used until SCM upgrade has been finalized",
-          ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY),
-          UpgradeException.ResultCodes.PREFINALIZE_ACTION_VALIDATION_FAILED);
+      long lastIndex = scm.getScmHAManager()

Review comment:
       Oh I did not realize we were already saving a marker that SCM HA was in use to the disk. That is much better I will use that.

##########
File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/upgrade/TestScmHAUnfinalizedStateValidationAction.java
##########
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ *
+ */
+
+package org.apache.hadoop.hdds.upgrade;
+
+import static org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature.INITIAL_VERSION;
+import org.apache.hadoop.hdds.conf.OzoneConfiguration;
+import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
+import org.apache.hadoop.hdds.scm.server.upgrade.ScmHAUnfinalizedStateValidationAction;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
+import org.apache.hadoop.ozone.MiniOzoneClusterImpl;
+import org.apache.hadoop.ozone.MiniOzoneHAClusterImpl;
+import org.apache.hadoop.ozone.upgrade.UpgradeException;
+import org.apache.hadoop.test.LambdaTestUtils;
+import org.junit.Ignore;
+import org.junit.Test;
+
+/**
+ * Tests that the SCM HA pre-finalize validation action is only triggered in
+ * pre-finalize startup if SCM HA was not already being used in the cluster,
+ * but has been turned on after.
+ *
+ * Starting a new SCM HA cluster finalized should not trigger the action. This
+ * is tested by all other tests that use SCM HA from the latest version of the
+ * code.
+ *
+ * Starting a new cluster finalized without SCM HA enabled should not trigger
+ * the action. This is tested by all other tests that run non-HA clusters.
+ */
+// Tests are ignored to speed up CI runs. Run manually if changes are made
+// relating to the SCM HA validation action.
+@Ignore
+public class TestScmHAUnfinalizedStateValidationAction {
+  private static final OzoneConfiguration CONF = new OzoneConfiguration();
+
+  @Test
+  public void testHAEnabledAlreadyUsedFinalized() throws Exception {
+    // Verification should pass.
+    MiniOzoneCluster cluster = new MiniOzoneHAClusterImpl.Builder(CONF)
+        .setNumDatanodes(1)
+        .setNumOfStorageContainerManagers(3)
+        .setNumOfOzoneManagers(1)
+        .setSCMServiceId("id1")
+        .setOMServiceId("id2")
+        .build();
+
+    // Manually trigger the upgrade action after setup, to see if it detects
+    // that HA is being used based on disk structures.
+    // This avoids saving disk state between mini ozone cluster restart.
+    ScmHAUnfinalizedStateValidationAction action =
+        new ScmHAUnfinalizedStateValidationAction();
+    for (StorageContainerManager scm:
+        ((MiniOzoneHAClusterImpl) cluster).getStorageContainerManagers()) {
+      action.execute(scm);
+    }
+
+    cluster.shutdown();
+  }
+
+  @Test
+  public void testHAEnabledNotAlreadyUsedPreFinalized() throws Exception {
+    // Verification should fail.
+    MiniOzoneCluster.Builder builder = new MiniOzoneHAClusterImpl.Builder(CONF)
+        .setNumDatanodes(1)
+        .setNumOfStorageContainerManagers(3)
+        .setNumOfOzoneManagers(1)
+        .setSCMServiceId("id1")
+        .setOMServiceId("id2")
+        .setScmLayoutVersion(INITIAL_VERSION.layoutVersion())

Review comment:
       With the current implementation yes, but after your comment above I will modify it so that init will also fail if it is run when the cluster is pre-finalized for SCM HA.




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