-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
HDDS-1603. Handle Ratis Append Failure in Container State Machine. Contributed by Supratim Deka #1019
Merged
Merged
HDDS-1603. Handle Ratis Append Failure in Container State Machine. Contributed by Supratim Deka #1019
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 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 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 |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
import org.apache.hadoop.hdds.conf.OzoneConfiguration; | ||
import org.apache.hadoop.hdds.protocol.DatanodeDetails; | ||
import org.apache.hadoop.hdds.protocol.proto.HddsProtos; | ||
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos; | ||
import org.apache.hadoop.hdds.protocol.proto.StorageContainerDatanodeProtocolProtos.PipelineReport; | ||
import org.apache.hadoop.hdds.scm.ScmConfigKeys; | ||
import org.apache.hadoop.hdds.scm.TestUtils; | ||
|
@@ -29,20 +30,27 @@ | |
import org.apache.hadoop.hdds.scm.container.ContainerManager; | ||
import org.apache.hadoop.hdds.scm.container.ContainerNotFoundException; | ||
import org.apache.hadoop.hdds.scm.container.common.helpers.ContainerWithPipeline; | ||
import org.apache.hadoop.hdds.scm.events.SCMEvents; | ||
import org.apache.hadoop.hdds.scm.server.SCMDatanodeHeartbeatDispatcher.PipelineActionsFromDatanode; | ||
import org.apache.hadoop.hdds.scm.server.StorageContainerManager; | ||
import org.apache.hadoop.hdds.server.events.EventPublisher; | ||
import org.apache.hadoop.hdds.server.events.EventQueue; | ||
import org.apache.hadoop.ozone.MiniOzoneCluster; | ||
import org.apache.hadoop.ozone.container.common.transport.server.ratis.XceiverServerRatis; | ||
import org.apache.hadoop.ozone.container.ozoneimpl.OzoneContainer; | ||
import org.apache.hadoop.test.GenericTestUtils; | ||
import org.apache.ratis.protocol.RaftGroupId; | ||
import org.junit.After; | ||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.ArgumentCaptor; | ||
import org.mockito.Mockito; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.UUID; | ||
import java.util.concurrent.TimeUnit; | ||
import java.util.concurrent.TimeoutException; | ||
|
||
|
@@ -180,4 +188,77 @@ public void testPipelineCloseWithPipelineAction() throws Exception { | |
} catch (PipelineNotFoundException e) { | ||
} | ||
} | ||
|
||
@Test | ||
public void testPipelineCloseWithLogFailure() throws IOException { | ||
|
||
EventQueue eventQ = (EventQueue) scm.getEventQueue(); | ||
PipelineActionHandler pipelineActionTest = | ||
Mockito.mock(PipelineActionHandler.class); | ||
eventQ.addHandler(SCMEvents.PIPELINE_ACTIONS, pipelineActionTest); | ||
ArgumentCaptor<PipelineActionsFromDatanode> actionCaptor = | ||
ArgumentCaptor.forClass(PipelineActionsFromDatanode.class); | ||
|
||
ContainerInfo containerInfo = containerManager | ||
.allocateContainer(RATIS, THREE, "testOwner"); | ||
ContainerWithPipeline containerWithPipeline = | ||
new ContainerWithPipeline(containerInfo, | ||
pipelineManager.getPipeline(containerInfo.getPipelineID())); | ||
Pipeline openPipeline = containerWithPipeline.getPipeline(); | ||
RaftGroupId groupId = RaftGroupId.valueOf(openPipeline.getId().getId()); | ||
|
||
try { | ||
pipelineManager.getPipeline(openPipeline.getId()); | ||
} catch (PipelineNotFoundException e) { | ||
Assert.assertTrue("pipeline should exist", false); | ||
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. In Junit, the test will exit if an uncaught exception is thrown, so this might not be needed. |
||
} | ||
|
||
DatanodeDetails datanodeDetails = openPipeline.getNodes().get(0); | ||
int index = cluster.getHddsDatanodeIndex(datanodeDetails); | ||
|
||
XceiverServerRatis xceiverRatis = | ||
(XceiverServerRatis) cluster.getHddsDatanodes().get(index) | ||
.getDatanodeStateMachine().getContainer().getWriteChannel(); | ||
|
||
/** | ||
* Notify Datanode Ratis Server endpoint of a Ratis log failure. | ||
* This is expected to trigger an immediate pipeline actions report to SCM | ||
*/ | ||
xceiverRatis.handleNodeLogFailure(groupId, null); | ||
|
||
// verify SCM receives a pipeline action report "immediately" | ||
Mockito.verify(pipelineActionTest, Mockito.timeout(100)) | ||
.onMessage( | ||
actionCaptor.capture(), | ||
Mockito.any(EventPublisher.class)); | ||
|
||
PipelineActionsFromDatanode actionsFromDatanode = | ||
actionCaptor.getValue(); | ||
|
||
// match the pipeline id | ||
verifyCloseForPipeline(openPipeline, actionsFromDatanode); | ||
} | ||
|
||
private boolean verifyCloseForPipeline(Pipeline pipeline, | ||
PipelineActionsFromDatanode report) { | ||
UUID uuidToFind = pipeline.getId().getId(); | ||
|
||
boolean found = false; | ||
for (StorageContainerDatanodeProtocolProtos.PipelineAction action : | ||
report.getReport().getPipelineActionsList()) { | ||
if (action.getAction() == | ||
StorageContainerDatanodeProtocolProtos.PipelineAction.Action.CLOSE) { | ||
PipelineID closedPipelineId = PipelineID. | ||
getFromProtobuf(action.getClosePipeline().getPipelineID()); | ||
|
||
if (closedPipelineId.getId().equals(uuidToFind)) { | ||
found = true; | ||
} | ||
} | ||
} | ||
|
||
Assert.assertTrue("SCM did not receive a Close action for the Pipeline", | ||
found); | ||
return found; | ||
} | ||
} |
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.
Lets have 2 Reasons, a) candidate failed, b) leader failed