-
Notifications
You must be signed in to change notification settings - Fork 25
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
Feature csi 5536 add fence implementation #679
Open
ArbelNathan
wants to merge
9
commits into
task/CSI-5277_add_unittests_to_identity_servicer
Choose a base branch
from
feature/CSI-5536_fence_design_tests
base: task/CSI-5277_add_unittests_to_identity_servicer
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+325
−23
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0de475c
add fence sidecar to controller
9dc6a79
Merge branch 'task/CSI-5277_add_unittests_to_identity_servicer' into …
24bfa53
merge with csi_addon brunch
69d7740
add fence servicer
fab8432
add fence capabilities and implementation in mediator
b457d45
logger, consts and fixes
cdcd250
Merge remote-tracking branch 'origin/task/CSI-5277_add_unittests_to_i…
ArbelNathan 0f87272
format cleanup
ArbelNathan 5e778b3
add validation for parameters
ArbelNathan 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 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from abc import ABC, abstractmethod | ||
|
||
|
||
class FenceInterface(ABC): | ||
|
||
@abstractmethod | ||
def is_fenced(self, fence_ownership_group): | ||
""" | ||
This function should check if the fence_ownership_group is already fenced (no pools in the og) | ||
|
||
Args: | ||
fence_ownership_group : name of the ownership group that should be fenced | ||
|
||
Returns: | ||
bool | ||
|
||
Raises: | ||
None | ||
""" | ||
raise NotImplementedError | ||
|
||
@abstractmethod | ||
def fence(self, fence_ownership_group, unfence_ownership_group): | ||
""" | ||
This function should fence the fence_ownership_group and unfence the unfence_ownership_group | ||
|
||
Args: | ||
fence_ownership_group : name of the ownership group that should be fenced | ||
unfence_ownership_group : name of the ownership group that should be unfenced | ||
|
||
Returns: | ||
None | ||
|
||
Raises: | ||
None | ||
""" | ||
raise NotImplementedError |
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
Empty file.
47 changes: 47 additions & 0 deletions
47
controllers/servers/csi/csi_addons_server/fence_controller_servicer.py
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from csi_general import fence_pb2_grpc, fence_pb2 | ||
|
||
from controllers.array_action.storage_agent import get_agent, detect_array_type | ||
from controllers.common.csi_logger import get_stdout_logger | ||
from controllers.servers import utils | ||
from controllers.servers.csi.decorators import csi_fence_method | ||
|
||
logger = get_stdout_logger() | ||
|
||
|
||
def _is_already_handled(mediator, fence_ownership_group): | ||
return mediator.is_fenced(fence_ownership_group) | ||
|
||
|
||
def _fence_cluster_network(mediator, fence_ownership_group, unfence_ownership_group): | ||
logger.info("fencing {}".format(fence_ownership_group)) | ||
mediator.fence(fence_ownership_group, unfence_ownership_group) | ||
|
||
|
||
def handle_fencing(request): | ||
utils.validate_fencing_request(request) | ||
fence_ownership_group = request.parameters["fenceToken"] | ||
leonid-s-usov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
unfence_ownership_group = request.parameters["unfenceToken"] | ||
|
||
connection_info = utils.get_array_connection_info_from_secrets(request.secrets) | ||
array_type = detect_array_type(connection_info.array_addresses) | ||
with get_agent(connection_info, array_type).get_mediator() as mediator: | ||
# idempotence - check if the fence_ownership_group is already fenced (no pools in the og) | ||
if _is_already_handled(mediator, fence_ownership_group): | ||
logger.info("{} is fenced".format(fence_ownership_group)) | ||
return fence_pb2.FenceClusterNetworkResponse() | ||
_fence_cluster_network(mediator, fence_ownership_group, unfence_ownership_group) | ||
return fence_pb2.FenceClusterNetworkResponse() | ||
|
||
|
||
class FenceControllerServicer(fence_pb2_grpc.FenceControllerServicer): | ||
@csi_fence_method(error_response_type=fence_pb2.FenceClusterNetworkResponse) | ||
def FenceClusterNetwork(self, request, context): | ||
return handle_fencing(request) | ||
|
||
@csi_fence_method(error_response_type=fence_pb2.UnfenceClusterNetworkResponse) | ||
def UnfenceClusterNetwork(self, request, context): | ||
return handle_fencing(request) | ||
|
||
@csi_fence_method(error_response_type=fence_pb2.ListClusterFenceResponse) | ||
def ListClusterFence(self, request, context): | ||
raise NotImplementedError() |
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
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.
you can export this code into some functions, it can make it more cleaner IMO, but it's not important, it's not a blocker for the PR