You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Xushaohong (via GitHub)" <gi...@apache.org> on 2023/02/15 04:05:36 UTC
[GitHub] [ozone] Xushaohong opened a new pull request, #4276: HDDS-7971. Support SCM transfer Ratis leadership
Xushaohong opened a new pull request, #4276:
URL: https://github.com/apache/ozone/pull/4276
## What changes were proposed in this pull request?
Support SCM transfer Ratis leadership.
Split From https://issues.apache.org/jira/browse/HDDS-5686
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-7971
## How was this patch tested?
CI and Manual Test

--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
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
[GitHub] [ozone] szetszwo commented on a diff in pull request #4276: HDDS-7971. Support SCM transfer Ratis leadership
Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo commented on code in PR #4276:
URL: https://github.com/apache/ozone/pull/4276#discussion_r1107681156
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -782,6 +795,89 @@ public ScmInfo getScmInfo() throws IOException {
}
}
+ @Override
+ public void transferLeadership(String newLeaderId)
+ throws IOException {
+ getScm().checkAdminAccess(getRemoteUser());
+ if (!SCMHAUtils.isSCMHAEnabled(getScm().getConfiguration())) {
+ throw new SCMException("SCM HA not enabled.", ResultCodes.INTERNAL_ERROR);
+ }
+ boolean auditSuccess = true;
+ final Map<String, String> auditMap = Maps.newHashMap();
+ auditMap.put("newLeaderId", newLeaderId);
+ try {
+ SCMRatisServer scmRatisServer = scm.getScmHAManager().getRatisServer();
+ RaftGroup group = scmRatisServer.getDivision().getGroup();
+ RaftPeerId targetPeerId;
+ if (newLeaderId.isEmpty()) {
+ RaftPeer curLeader = ((SCMRatisServerImpl) scm.getScmHAManager()
+ .getRatisServer()).getLeader();
+ targetPeerId = group.getPeers()
+ .stream()
+ .filter(a -> !a.equals(curLeader)).findFirst()
+ .map(RaftPeer::getId)
+ .orElseThrow(() -> new IOException("Cannot" +
+ " find a new leader to transfer leadership."));
+ } else {
+ String ratisAddr = convertToRatisAddr(newLeaderId);
Review Comment:
Use `RaftPeerId.getRaftPeerId(newLeaderId)` to get `RaftPeerId`; see https://github.com/apache/ozone/blob/master/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMRatisServerImpl.java#L172
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
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
[GitHub] [ozone] Xushaohong commented on a diff in pull request #4276: HDDS-7971. Support SCM transfer Ratis leadership
Posted by "Xushaohong (via GitHub)" <gi...@apache.org>.
Xushaohong commented on code in PR #4276:
URL: https://github.com/apache/ozone/pull/4276#discussion_r1108057576
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -782,6 +795,89 @@ public ScmInfo getScmInfo() throws IOException {
}
}
+ @Override
+ public void transferLeadership(String newLeaderId)
+ throws IOException {
+ getScm().checkAdminAccess(getRemoteUser());
+ if (!SCMHAUtils.isSCMHAEnabled(getScm().getConfiguration())) {
+ throw new SCMException("SCM HA not enabled.", ResultCodes.INTERNAL_ERROR);
+ }
+ boolean auditSuccess = true;
+ final Map<String, String> auditMap = Maps.newHashMap();
+ auditMap.put("newLeaderId", newLeaderId);
+ try {
+ SCMRatisServer scmRatisServer = scm.getScmHAManager().getRatisServer();
+ RaftGroup group = scmRatisServer.getDivision().getGroup();
+ RaftPeerId targetPeerId;
+ if (newLeaderId.isEmpty()) {
+ RaftPeer curLeader = ((SCMRatisServerImpl) scm.getScmHAManager()
+ .getRatisServer()).getLeader();
+ targetPeerId = group.getPeers()
+ .stream()
+ .filter(a -> !a.equals(curLeader)).findFirst()
+ .map(RaftPeer::getId)
+ .orElseThrow(() -> new IOException("Cannot" +
+ " find a new leader to transfer leadership."));
+ } else {
+ String ratisAddr = convertToRatisAddr(newLeaderId);
Review Comment:
> What is the problem of using UUID? Too long?
Hi @szetszwo.
OM uses the OmNodeId in the conf as the **RaftPeerId**, so we can directly find the new leader in the Raft group info by the passed nodeId.
SCM uses the UUID as the **RaftPeerId**, we have no way to know the new leader's UUID, so I added the conversion from ScmNodeId to RatisAddress and then got the **RaftPeerId**.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
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
[GitHub] [ozone] Xushaohong commented on a diff in pull request #4276: HDDS-7971. Support SCM transfer Ratis leadership
Posted by "Xushaohong (via GitHub)" <gi...@apache.org>.
Xushaohong commented on code in PR #4276:
URL: https://github.com/apache/ozone/pull/4276#discussion_r1108349154
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -782,6 +795,89 @@ public ScmInfo getScmInfo() throws IOException {
}
}
+ @Override
+ public void transferLeadership(String newLeaderId)
+ throws IOException {
+ getScm().checkAdminAccess(getRemoteUser());
+ if (!SCMHAUtils.isSCMHAEnabled(getScm().getConfiguration())) {
+ throw new SCMException("SCM HA not enabled.", ResultCodes.INTERNAL_ERROR);
+ }
+ boolean auditSuccess = true;
+ final Map<String, String> auditMap = Maps.newHashMap();
+ auditMap.put("newLeaderId", newLeaderId);
+ try {
+ SCMRatisServer scmRatisServer = scm.getScmHAManager().getRatisServer();
+ RaftGroup group = scmRatisServer.getDivision().getGroup();
+ RaftPeerId targetPeerId;
+ if (newLeaderId.isEmpty()) {
+ RaftPeer curLeader = ((SCMRatisServerImpl) scm.getScmHAManager()
+ .getRatisServer()).getLeader();
+ targetPeerId = group.getPeers()
+ .stream()
+ .filter(a -> !a.equals(curLeader)).findFirst()
+ .map(RaftPeer::getId)
+ .orElseThrow(() -> new IOException("Cannot" +
+ " find a new leader to transfer leadership."));
+ } else {
+ String ratisAddr = convertToRatisAddr(newLeaderId);
Review Comment:
@szetszwo , We have had scmId in the urrent Role info. The sideeffect is the different shell usage between OM and SCM, but seems not a big problem. I have updated the code.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
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
[GitHub] [ozone] szetszwo commented on a diff in pull request #4276: HDDS-7971. Support SCM transfer Ratis leadership
Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo commented on code in PR #4276:
URL: https://github.com/apache/ozone/pull/4276#discussion_r1108014593
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -782,6 +795,89 @@ public ScmInfo getScmInfo() throws IOException {
}
}
+ @Override
+ public void transferLeadership(String newLeaderId)
+ throws IOException {
+ getScm().checkAdminAccess(getRemoteUser());
+ if (!SCMHAUtils.isSCMHAEnabled(getScm().getConfiguration())) {
+ throw new SCMException("SCM HA not enabled.", ResultCodes.INTERNAL_ERROR);
+ }
+ boolean auditSuccess = true;
+ final Map<String, String> auditMap = Maps.newHashMap();
+ auditMap.put("newLeaderId", newLeaderId);
+ try {
+ SCMRatisServer scmRatisServer = scm.getScmHAManager().getRatisServer();
+ RaftGroup group = scmRatisServer.getDivision().getGroup();
+ RaftPeerId targetPeerId;
+ if (newLeaderId.isEmpty()) {
+ RaftPeer curLeader = ((SCMRatisServerImpl) scm.getScmHAManager()
+ .getRatisServer()).getLeader();
+ targetPeerId = group.getPeers()
+ .stream()
+ .filter(a -> !a.equals(curLeader)).findFirst()
+ .map(RaftPeer::getId)
+ .orElseThrow(() -> new IOException("Cannot" +
+ " find a new leader to transfer leadership."));
+ } else {
+ String ratisAddr = convertToRatisAddr(newLeaderId);
Review Comment:
> ... as it uses UUID as raftPeerId, ...
What is the problem of using UUID? Too long?
If we want to support passing an address, we should have a `--newLeaderAddress` option.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
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
[GitHub] [ozone] szetszwo merged pull request #4276: HDDS-7971. Support SCM transfer Ratis leadership
Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo merged PR #4276:
URL: https://github.com/apache/ozone/pull/4276
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
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
[GitHub] [ozone] Xushaohong commented on a diff in pull request #4276: HDDS-7971. Support SCM transfer Ratis leadership
Posted by "Xushaohong (via GitHub)" <gi...@apache.org>.
Xushaohong commented on code in PR #4276:
URL: https://github.com/apache/ozone/pull/4276#discussion_r1107948006
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -782,6 +795,89 @@ public ScmInfo getScmInfo() throws IOException {
}
}
+ @Override
+ public void transferLeadership(String newLeaderId)
+ throws IOException {
+ getScm().checkAdminAccess(getRemoteUser());
+ if (!SCMHAUtils.isSCMHAEnabled(getScm().getConfiguration())) {
+ throw new SCMException("SCM HA not enabled.", ResultCodes.INTERNAL_ERROR);
+ }
+ boolean auditSuccess = true;
+ final Map<String, String> auditMap = Maps.newHashMap();
+ auditMap.put("newLeaderId", newLeaderId);
+ try {
+ SCMRatisServer scmRatisServer = scm.getScmHAManager().getRatisServer();
+ RaftGroup group = scmRatisServer.getDivision().getGroup();
+ RaftPeerId targetPeerId;
+ if (newLeaderId.isEmpty()) {
+ RaftPeer curLeader = ((SCMRatisServerImpl) scm.getScmHAManager()
+ .getRatisServer()).getLeader();
+ targetPeerId = group.getPeers()
+ .stream()
+ .filter(a -> !a.equals(curLeader)).findFirst()
+ .map(RaftPeer::getId)
+ .orElseThrow(() -> new IOException("Cannot" +
+ " find a new leader to transfer leadership."));
+ } else {
+ String ratisAddr = convertToRatisAddr(newLeaderId);
Review Comment:
Hi @szetszwo , SCM is different from OM as it uses UUID as raftPeerId, See
```
public String getScmId() {
return getScmStorageConfig().getScmId();
}
```
https://github.com/apache/ozone/blob/e7d57b9f911ca9878f2255cf79d8b23b9c2562f3/hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMStorageConfig.java#L90-L98
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
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
[GitHub] [ozone] szetszwo commented on a diff in pull request #4276: HDDS-7971. Support SCM transfer Ratis leadership
Posted by "szetszwo (via GitHub)" <gi...@apache.org>.
szetszwo commented on code in PR #4276:
URL: https://github.com/apache/ozone/pull/4276#discussion_r1108179340
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -782,6 +795,89 @@ public ScmInfo getScmInfo() throws IOException {
}
}
+ @Override
+ public void transferLeadership(String newLeaderId)
+ throws IOException {
+ getScm().checkAdminAccess(getRemoteUser());
+ if (!SCMHAUtils.isSCMHAEnabled(getScm().getConfiguration())) {
+ throw new SCMException("SCM HA not enabled.", ResultCodes.INTERNAL_ERROR);
+ }
+ boolean auditSuccess = true;
+ final Map<String, String> auditMap = Maps.newHashMap();
+ auditMap.put("newLeaderId", newLeaderId);
+ try {
+ SCMRatisServer scmRatisServer = scm.getScmHAManager().getRatisServer();
+ RaftGroup group = scmRatisServer.getDivision().getGroup();
+ RaftPeerId targetPeerId;
+ if (newLeaderId.isEmpty()) {
+ RaftPeer curLeader = ((SCMRatisServerImpl) scm.getScmHAManager()
+ .getRatisServer()).getLeader();
+ targetPeerId = group.getPeers()
+ .stream()
+ .filter(a -> !a.equals(curLeader)).findFirst()
+ .map(RaftPeer::getId)
+ .orElseThrow(() -> new IOException("Cannot" +
+ " find a new leader to transfer leadership."));
+ } else {
+ String ratisAddr = convertToRatisAddr(newLeaderId);
Review Comment:
@Xushaohong , we should provide some way to get the scmId. We may show it on the web UI, print it in the log or add a command to get the entire RaftGroup.
--
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.
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
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