-
Notifications
You must be signed in to change notification settings - Fork 587
HDDS-11136. Some containers affected by HDDS-8129 may still be in the DELETING state incorrectly #6967
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
HDDS-11136. Some containers affected by HDDS-8129 may still be in the DELETING state incorrectly #6967
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5ba6fd6
HDDS-1136. Some containers affected by HDDS-8129 may still be in the …
siddhantsangwan cc03549
Merge branch 'refs/heads/master' into HDDS-11136
siddhantsangwan 6c0c587
address review comments
siddhantsangwan c189cce
add integration test
siddhantsangwan 869a9e6
add integration test for SCM HA
siddhantsangwan 6b5dacb
fix operators bug
siddhantsangwan 85fb626
split out integration tests into different files
siddhantsangwan b8c9512
fix checkstyle
siddhantsangwan 55a429d
use only CLOSED replicas to determine state
siddhantsangwan 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,12 +41,14 @@ | |
| import org.apache.hadoop.hdds.scm.pipeline.PipelineManager; | ||
| import org.apache.hadoop.hdds.utils.db.DBStore; | ||
| import org.apache.hadoop.hdds.utils.db.DBStoreBuilder; | ||
| import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException; | ||
| import org.apache.hadoop.ozone.container.common.SCMTestUtils; | ||
| import org.junit.jupiter.api.AfterEach; | ||
| import org.junit.jupiter.api.BeforeEach; | ||
| import org.junit.jupiter.api.Test; | ||
| import org.junit.jupiter.api.io.TempDir; | ||
|
|
||
| import static org.junit.jupiter.api.Assertions.assertThrows; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.times; | ||
| import static org.mockito.Mockito.verify; | ||
|
|
@@ -132,6 +134,62 @@ void testUpdateContainerState() throws Exception { | |
| assertEquals(LifeCycleState.CLOSED, containerManager.getContainer(cid).getState()); | ||
| } | ||
|
|
||
| @Test | ||
| void testTransitionDeletingToClosedState() throws IOException, InvalidStateTransitionException { | ||
|
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. nit. Can we parameterize this by container type instead of duplicating each line for each container? |
||
| // allocate OPEN Ratis and Ec containers, and do a series of state changes to transition them to DELETING | ||
| final ContainerInfo container = containerManager.allocateContainer( | ||
| RatisReplicationConfig.getInstance( | ||
| ReplicationFactor.THREE), "admin"); | ||
| ContainerInfo ecContainer = containerManager.allocateContainer(new ECReplicationConfig(3, 2), "admin"); | ||
| final ContainerID cid = container.containerID(); | ||
| final ContainerID ecCid = ecContainer.containerID(); | ||
| assertEquals(LifeCycleState.OPEN, containerManager.getContainer(cid).getState()); | ||
| assertEquals(LifeCycleState.OPEN, containerManager.getContainer(ecCid).getState()); | ||
|
|
||
| // OPEN -> CLOSING | ||
| containerManager.updateContainerState(cid, | ||
| HddsProtos.LifeCycleEvent.FINALIZE); | ||
| containerManager.updateContainerState(ecCid, HddsProtos.LifeCycleEvent.FINALIZE); | ||
| assertEquals(LifeCycleState.CLOSING, containerManager.getContainer(cid).getState()); | ||
| assertEquals(LifeCycleState.CLOSING, containerManager.getContainer(ecCid).getState()); | ||
|
|
||
| // CLOSING -> CLOSED | ||
| containerManager.updateContainerState(cid, HddsProtos.LifeCycleEvent.CLOSE); | ||
| containerManager.updateContainerState(ecCid, HddsProtos.LifeCycleEvent.CLOSE); | ||
| assertEquals(LifeCycleState.CLOSED, containerManager.getContainer(cid).getState()); | ||
| assertEquals(LifeCycleState.CLOSED, containerManager.getContainer(ecCid).getState()); | ||
|
|
||
| // CLOSED -> DELETING | ||
| containerManager.updateContainerState(cid, HddsProtos.LifeCycleEvent.DELETE); | ||
| containerManager.updateContainerState(ecCid, HddsProtos.LifeCycleEvent.DELETE); | ||
| assertEquals(LifeCycleState.DELETING, containerManager.getContainer(cid).getState()); | ||
| assertEquals(LifeCycleState.DELETING, containerManager.getContainer(ecCid).getState()); | ||
|
|
||
| // DELETING -> CLOSED | ||
| containerManager.transitionDeletingToClosedState(cid); | ||
| containerManager.transitionDeletingToClosedState(ecCid); | ||
| // the containers should be back in CLOSED state now | ||
| assertEquals(LifeCycleState.CLOSED, containerManager.getContainer(cid).getState()); | ||
| assertEquals(LifeCycleState.CLOSED, containerManager.getContainer(ecCid).getState()); | ||
| } | ||
|
|
||
| @Test | ||
| void testTransitionDeletingToClosedStateAllowsOnlyDeletingContainers() throws IOException { | ||
| // test for RATIS container | ||
| final ContainerInfo container = containerManager.allocateContainer( | ||
| RatisReplicationConfig.getInstance( | ||
| ReplicationFactor.THREE), "admin"); | ||
| final ContainerID cid = container.containerID(); | ||
| assertEquals(LifeCycleState.OPEN, containerManager.getContainer(cid).getState()); | ||
| assertThrows(IOException.class, () -> containerManager.transitionDeletingToClosedState(cid)); | ||
|
|
||
| // test for EC container | ||
| final ContainerInfo ecContainer = containerManager.allocateContainer(new ECReplicationConfig(3, 2), "admin"); | ||
| final ContainerID ecCid = ecContainer.containerID(); | ||
| assertEquals(LifeCycleState.OPEN, containerManager.getContainer(ecCid).getState()); | ||
| assertThrows(IOException.class, () -> containerManager.transitionDeletingToClosedState(ecCid)); | ||
| } | ||
|
|
||
| @Test | ||
| void testGetContainers() throws Exception { | ||
| assertEquals(emptyList(), containerManager.getContainers()); | ||
|
|
||
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
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.
Uh oh!
There was an error while loading. Please reload this page.