diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java index b6c41c7dcf0f..5f76b1a0161a 100644 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java +++ b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/StorageContainerManager.java @@ -76,7 +76,6 @@ import org.apache.hadoop.hdds.scm.ha.StatefulServiceStateManager; import org.apache.hadoop.hdds.scm.ha.StatefulServiceStateManagerImpl; import org.apache.hadoop.hdds.scm.server.upgrade.SCMUpgradeFinalizationContext; -import org.apache.hadoop.hdds.scm.server.upgrade.ScmHAUnfinalizedStateValidationAction; import org.apache.hadoop.hdds.scm.pipeline.WritableContainerFactory; import org.apache.hadoop.hdds.security.symmetric.SecretKeyManager; import org.apache.hadoop.hdds.security.token.ContainerTokenGenerator; @@ -160,7 +159,6 @@ import org.apache.hadoop.ozone.lease.LeaseManager; import org.apache.hadoop.ozone.lease.LeaseManagerNotRunningException; import org.apache.hadoop.ozone.upgrade.DefaultUpgradeFinalizationExecutor; -import org.apache.hadoop.ozone.upgrade.LayoutVersionManager; import org.apache.hadoop.ozone.upgrade.UpgradeFinalizationExecutor; import org.apache.hadoop.security.AccessControlException; import org.apache.hadoop.security.SecurityUtil; @@ -1314,18 +1312,6 @@ public static boolean scmInit(OzoneConfiguration conf, return false; } } else { - // If SCM HA was not being used before pre-finalize, and is being used - // when the cluster is pre-finalized for the SCM HA feature, init - // should fail. - final LayoutVersionManager layoutVersionManager = - new HDDSLayoutVersionManager(scmStorageConfig.getLayoutVersion()); - try { - ScmHAUnfinalizedStateValidationAction.checkScmHA(conf, scmStorageConfig, - layoutVersionManager); - } finally { - layoutVersionManager.close(); - } - clusterId = scmStorageConfig.getClusterID(); final boolean isSCMHAEnabled = scmStorageConfig.isSCMHAEnabled(); diff --git a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/ScmHAUnfinalizedStateValidationAction.java b/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/ScmHAUnfinalizedStateValidationAction.java deleted file mode 100644 index 7e086ad56519..000000000000 --- a/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/upgrade/ScmHAUnfinalizedStateValidationAction.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * 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.scm.server.upgrade; - -import static org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature.SCM_HA; -import static org.apache.hadoop.ozone.upgrade.LayoutFeature.UpgradeActionType.VALIDATE_IN_PREFINALIZE; -import static org.apache.hadoop.ozone.upgrade.UpgradeActionHdds.Component.SCM; - -import org.apache.hadoop.hdds.conf.OzoneConfiguration; -import org.apache.hadoop.hdds.scm.ha.SCMHAUtils; -import org.apache.hadoop.hdds.scm.server.SCMStorageConfig; -import org.apache.hadoop.hdds.upgrade.HDDSUpgradeAction; -import org.apache.hadoop.ozone.upgrade.LayoutVersionManager; -import org.apache.hadoop.ozone.upgrade.UpgradeActionHdds; -import org.apache.hadoop.ozone.upgrade.UpgradeException; - -import java.io.IOException; - -/** - * Checks that SCM HA cannot be used in a pre-finalized cluster, unless it - * was already being used before this action was run. - */ -@UpgradeActionHdds(feature = SCM_HA, component = SCM, - type = VALIDATE_IN_PREFINALIZE) -public class ScmHAUnfinalizedStateValidationAction - implements HDDSUpgradeAction { - - @Override - public void execute(SCMUpgradeFinalizationContext context) - throws IOException { - checkScmHA(context.getConfiguration(), context.getStorage(), - context.getLayoutVersionManager()); - } - - /** - * Allows checking that SCM HA is not enabled while pre-finalized in both - * scm init and the upgrade action run on start. - */ - public static void checkScmHA(OzoneConfiguration conf, - SCMStorageConfig storageConf, LayoutVersionManager versionManager) - throws IOException { - - // Since this action may need to be called outside the upgrade framework - // during init, it needs to check for pre-finalized state. - if (!versionManager.isAllowed(SCM_HA) && - SCMHAUtils.isSCMHAEnabled(conf) && - !storageConf.isSCMHAEnabled()) { - throw new UpgradeException("Ratis cannot be " + - "used until SCM upgrade has been finalized", - UpgradeException.ResultCodes.PREFINALIZE_ACTION_VALIDATION_FAILED); - } - } -} diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/upgrade/TestSCMHAUnfinalizedStateValidationAction.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/upgrade/TestSCMHAUnfinalizedStateValidationAction.java deleted file mode 100644 index c8c2e039aebf..000000000000 --- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/upgrade/TestSCMHAUnfinalizedStateValidationAction.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.scm.upgrade; - -import org.apache.hadoop.hdds.conf.OzoneConfiguration; -import org.apache.hadoop.hdds.scm.HddsTestUtils; -import org.apache.hadoop.hdds.scm.ScmConfig; -import org.apache.hadoop.hdds.scm.ScmConfigKeys; -import org.apache.hadoop.hdds.scm.server.StorageContainerManager; -import org.apache.hadoop.hdds.upgrade.HDDSLayoutFeature; -import org.apache.hadoop.ozone.OzoneConfigKeys; -import org.apache.hadoop.ozone.upgrade.UpgradeFinalizer; -import org.apache.ratis.util.ExitUtils; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.io.TempDir; - -import java.nio.file.Path; -import java.util.UUID; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -/** - * 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. - */ -public class TestSCMHAUnfinalizedStateValidationAction { - - private static final String CLUSTER_ID = UUID.randomUUID().toString(); - - @BeforeAll - public static void setup() { - ExitUtils.disableSystemExit(); - } - - @Test - public void testUpgrade(@TempDir Path dataPath) throws Exception { - // Write version file for original version. - OzoneConfiguration conf = new OzoneConfiguration(); - conf.setInt(ScmConfig.ConfigStrings.HDDS_SCM_INIT_DEFAULT_LAYOUT_VERSION, - HDDSLayoutFeature.INITIAL_VERSION.layoutVersion()); - conf.set(ScmConfigKeys.OZONE_SCM_DB_DIRS, dataPath.toString()); - conf.set(OzoneConfigKeys.OZONE_METADATA_DIRS, dataPath.toString()); - // This init should always succeed, since SCM is not pre-finalized yet. - boolean initResult1 = StorageContainerManager.scmInit(conf, CLUSTER_ID); - assertTrue(initResult1); - - StorageContainerManager scm = HddsTestUtils.getScm(conf); - - assertEquals(UpgradeFinalizer.Status.FINALIZATION_REQUIRED, - scm.getFinalizationManager().getUpgradeFinalizer().getStatus()); - - - boolean initResult2 = StorageContainerManager.scmInit(conf, CLUSTER_ID); - assertTrue(initResult2); - scm.start(); - scm.stop(); - - } -}