-
Notifications
You must be signed in to change notification settings - Fork 593
HDDS-7853. Add support for RemoveSCM in SCMRatisServer. #4358
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,112 @@ | ||
|
|
||
| /* | ||
| * 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; | ||
|
|
||
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
|
|
||
| /** | ||
| * Request class using which SCM can be removed form the HA Ring. | ||
| */ | ||
| public class RemoveSCMRequest { | ||
|
|
||
| private final String clusterId; | ||
| private final String scmId; | ||
| private final String ratisAddr; | ||
|
|
||
| public RemoveSCMRequest(String clusterId, String scmId, String addr) { | ||
| this.clusterId = clusterId; | ||
| this.scmId = scmId; | ||
| this.ratisAddr = addr; | ||
| } | ||
|
|
||
| public static RemoveSCMRequest getFromProtobuf( | ||
| HddsProtos.RemoveScmRequestProto proto) { | ||
| return new Builder().setClusterId(proto.getClusterId()) | ||
| .setScmId(proto.getScmId()).setRatisAddr(proto.getRatisAddr()).build(); | ||
| } | ||
|
|
||
| public HddsProtos.RemoveScmRequestProto getProtobuf() { | ||
| return HddsProtos.RemoveScmRequestProto.newBuilder().setClusterId(clusterId) | ||
| .setScmId(scmId).setRatisAddr(ratisAddr).build(); | ||
| } | ||
| /** | ||
| * Builder for RemoveSCMRequest. | ||
| */ | ||
| public static class Builder { | ||
| private String clusterId; | ||
| private String scmId; | ||
| private String ratisAddr; | ||
|
|
||
|
|
||
| /** | ||
| * sets the cluster id. | ||
| * @param cid clusterId to be set | ||
| * @return Builder for RemoveSCMRequest | ||
| */ | ||
| public RemoveSCMRequest.Builder setClusterId(String cid) { | ||
| this.clusterId = cid; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * sets the scmId. | ||
| * @param id scmId | ||
| * @return Builder for RemoveSCMRequest | ||
| */ | ||
| public RemoveSCMRequest.Builder setScmId(String id) { | ||
| this.scmId = id; | ||
| return this; | ||
| } | ||
|
|
||
| /** | ||
| * Set ratis address in Scm HA. | ||
| * @param addr address in the format of [ip|hostname]:port | ||
| * @return Builder for RemoveSCMRequest | ||
| */ | ||
| public RemoveSCMRequest.Builder setRatisAddr(String addr) { | ||
| this.ratisAddr = addr; | ||
| return this; | ||
| } | ||
|
|
||
| public RemoveSCMRequest build() { | ||
| return new RemoveSCMRequest(clusterId, scmId, ratisAddr); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Gets the clusterId from the Version file. | ||
| * @return ClusterId | ||
| */ | ||
| public String getClusterId() { | ||
| return clusterId; | ||
| } | ||
|
|
||
| /** | ||
| * Gets the SCM Id from the Version file. | ||
| * @return SCM Id | ||
| */ | ||
| public String getScmId() { | ||
| return scmId; | ||
| } | ||
|
|
||
| public String getRatisAddr() { | ||
| return ratisAddr; | ||
| } | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,6 +41,7 @@ | |
| import org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeState; | ||
| import org.apache.hadoop.hdds.scm.PipelineChoosePolicy; | ||
| import org.apache.hadoop.hdds.scm.PlacementPolicy; | ||
| import org.apache.hadoop.hdds.scm.RemoveSCMRequest; | ||
| import org.apache.hadoop.hdds.scm.ScmUtils; | ||
| import org.apache.hadoop.hdds.scm.container.ContainerManager; | ||
| import org.apache.hadoop.hdds.scm.container.ContainerManagerImpl; | ||
|
|
@@ -2070,4 +2071,27 @@ private String reconfOzoneAdmins(String newVal) { | |
| newVal, admins); | ||
| return String.valueOf(newVal); | ||
| } | ||
|
|
||
| /** | ||
| * This will remove the given SCM node from HA Ring by removing it from | ||
| * Ratis Ring and deleting the related certificates from certificate store. | ||
| * | ||
| * @return true if remove was successful, else false. | ||
| */ | ||
| public boolean removePeerFromHARing(RemoveSCMRequest request) | ||
| throws IOException { | ||
| // We cannot remove a node if it's currently leader. | ||
| if (scmContext.isLeader() && request.getScmId().equals(getScmId())) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Q. If we need to perform maintenance on the current leader SCM node, how do we decommission it?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First, we have to stop the SCM service that we want to decommission. This will be part of SCM decommissioning documentation. |
||
| throw new IOException("Cannot remove current leader."); | ||
| } | ||
|
|
||
| // Currently we don't support removal of primordial node. | ||
| if (request.getScmId().equals(primaryScmNodeId)) { | ||
| throw new IOException("Removal of primordial node is not supported."); | ||
| } | ||
|
|
||
| // TODO: Remove the certificate from certificate store. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @nandakumar131 for the comment on certificate removal for node removed from ratis ring. What needs to be done to remove certificate? Are we blocked/waiting on something needed for this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There will be a new sub-task under HDDS-7852 for removing the SCM certificate form the database. |
||
| return scmHAManager.removeSCM(request); | ||
|
|
||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This removePeerFromHARing function is not used in the patch. We can remove it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the server-side code Sammi. There will be a follow-up change to introduce client-side code that will call this method. |
||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.