-
Notifications
You must be signed in to change notification settings - Fork 593
HDDS-8365. Admin SCM command to decommission SCM. #4563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b432c98
Commit new workflow def for repeated test of HDDS-5358.
neils-dev 304cb14
Merge remote-tracking branch 'upstream/master'
neils-dev 8eb2cba
ScmDecommissioning scm admin client command support. Includes removi…
neils-dev e54f95a
Minor changes for scm decommission cli. Renamed command to be consis…
neils-dev 7b7b0d6
Modifications made to scm decommission command client side to only re…
neils-dev 36b7aa2
Update to pickup required changes from HDDS-8452. Merge remote-track…
neils-dev e68e701
Merged to master to pick up needed changed for this PR from HDDS-8452…
neils-dev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 95 additions & 0 deletions
95
...rver-scm/src/test/java/org/apache/hadoop/hdds/scm/server/TestSCMClientProtocolServer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| /** | ||
| * 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 | ||
| * <p> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p> | ||
| * 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; | ||
|
|
||
| import org.apache.hadoop.hdds.HddsConfigKeys; | ||
| import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.DecommissionScmResponseProto; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.DecommissionScmRequestProto; | ||
| import org.apache.hadoop.hdds.scm.HddsTestUtils; | ||
| import org.apache.hadoop.hdds.scm.ha.SCMContext; | ||
| import org.apache.hadoop.hdds.scm.ha.SCMHAManagerStub; | ||
| import org.apache.hadoop.hdds.scm.protocol.StorageContainerLocationProtocolServerSideTranslatorPB; | ||
| import org.apache.hadoop.hdds.utils.ProtocolMessageMetrics; | ||
| import org.apache.ozone.test.GenericTestUtils; | ||
|
|
||
| import org.junit.jupiter.api.Test; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.mockito.Mockito; | ||
|
|
||
| import java.io.File; | ||
|
|
||
| /** | ||
| * Unit tests to validate the SCMClientProtocolServer | ||
| * servicing commands from the scm client. | ||
| */ | ||
| public class TestSCMClientProtocolServer { | ||
| private OzoneConfiguration config; | ||
| private SCMClientProtocolServer server; | ||
| private StorageContainerManager scm; | ||
| private StorageContainerLocationProtocolServerSideTranslatorPB service; | ||
|
|
||
| @BeforeEach | ||
| public void setUp() throws Exception { | ||
| config = new OzoneConfiguration(); | ||
| File dir = GenericTestUtils.getRandomizedTestDir(); | ||
| config.set(HddsConfigKeys.OZONE_METADATA_DIRS, dir.toString()); | ||
| SCMConfigurator configurator = new SCMConfigurator(); | ||
| configurator.setSCMHAManager(SCMHAManagerStub.getInstance(true)); | ||
| configurator.setScmContext(SCMContext.emptyContext()); | ||
| scm = HddsTestUtils.getScm(config, configurator); | ||
| scm.start(); | ||
| scm.exitSafeMode(); | ||
|
|
||
| server = scm.getClientProtocolServer(); | ||
| service = new StorageContainerLocationProtocolServerSideTranslatorPB(server, | ||
| scm, Mockito.mock(ProtocolMessageMetrics.class)); | ||
| } | ||
|
|
||
| @AfterEach | ||
| public void tearDown() throws Exception { | ||
| if (scm != null) { | ||
| scm.stop(); | ||
| scm.join(); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Tests decommissioning of scm. | ||
| */ | ||
| @Test | ||
| public void testScmDecommissionRemoveScmErrors() throws Exception { | ||
| String scmId = scm.getScmId(); | ||
| String err = "Cannot remove current leader."; | ||
|
|
||
| DecommissionScmRequestProto request = | ||
| DecommissionScmRequestProto.newBuilder() | ||
| .setScmId(scmId) | ||
| .build(); | ||
|
|
||
| DecommissionScmResponseProto resp = | ||
| service.decommissionScm(request); | ||
|
|
||
| // should have optional error message set in response | ||
| assertTrue(resp.hasErrorMsg()); | ||
| assertTrue(resp.getErrorMsg() | ||
| .equals(err)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
...zone/tools/src/main/java/org/apache/hadoop/ozone/admin/scm/DecommissionScmSubcommand.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * 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.ozone.admin.scm; | ||
|
|
||
| import org.apache.hadoop.hdds.cli.HddsVersionProvider; | ||
| import org.apache.hadoop.hdds.protocol.proto.StorageContainerLocationProtocolProtos.DecommissionScmResponseProto; | ||
| import org.apache.hadoop.hdds.scm.cli.ScmSubcommand; | ||
| import org.apache.hadoop.hdds.scm.client.ScmClient; | ||
| import picocli.CommandLine; | ||
|
|
||
| import java.io.IOException; | ||
|
|
||
| /** | ||
| * Handler of ozone admin scm decommission command. | ||
| */ | ||
| @CommandLine.Command( | ||
| name = "decommission", | ||
| description = "Decommission SCM <scmid>. Includes removing from ratis " | ||
| + "ring and removing its certificate from certStore", | ||
| mixinStandardHelpOptions = true, | ||
| versionProvider = HddsVersionProvider.class) | ||
|
|
||
|
|
||
| public class DecommissionScmSubcommand extends ScmSubcommand { | ||
| @CommandLine.ParentCommand | ||
| private ScmAdmin parent; | ||
|
|
||
| @CommandLine.Option(names = {"-nodeid", "--nodeid"}, | ||
| description = "NodeID of the SCM to be decommissioned.", | ||
| required = true) | ||
| private String nodeId; | ||
|
|
||
| @Override | ||
| public void execute(ScmClient scmClient) throws IOException { | ||
| DecommissionScmResponseProto response = scmClient.decommissionScm(nodeId); | ||
| if (!response.getSuccess()) { | ||
| System.out.println("Error decommissioning Scm " + nodeId); | ||
| if (response.hasErrorMsg()) { | ||
| System.out.println(response.getErrorMsg()); | ||
| } | ||
| } else { | ||
| System.out.println("Decommissioned Scm " + nodeId); | ||
| } | ||
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add some more tests here to verify other scenarios as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@neils-dev, thanks for working on this.
Please create a follow-up Jira to add more unit-tests.