Skip to content

Commit

Permalink
fix one by one communication strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmular committed Jan 19, 2018
1 parent cbf7e42 commit 8b2665c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pcs/cli/common/console_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -1386,4 +1386,7 @@ def joined_list(item_list, optional_transformations=None):
"--Debug Content Start--\n{content}\n--Debug Content End--\n"
).format(**info)
,
codes.UNABLE_TO_PERFORM_OPERATION_ON_ANY_NODE:
"Unable to perform operation on any available node/host, therefore it "
"is not possible to continue."
}
1 change: 1 addition & 0 deletions pcs/common/report_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@
UNABLE_TO_READ_COROSYNC_CONFIG = "UNABLE_TO_READ_COROSYNC_CONFIG"
UNABLE_TO_GET_SBD_CONFIG = "UNABLE_TO_GET_SBD_CONFIG"
UNABLE_TO_GET_SBD_STATUS = "UNABLE_TO_GET_SBD_STATUS"
UNABLE_TO_PERFORM_OPERATION_ON_ANY_NODE = "UNABLE_TO_PERFORM_OPERATION_ON_ANY_NODE"
UNKNOWN_COMMAND = 'UNKNOWN_COMMAND'
WATCHDOG_INVALID = "WATCHDOG_INVALID"
UNSUPPORTED_OPERATION_ON_NON_SYSTEMD_SYSTEMS = "UNSUPPORTED_OPERATION_ON_NON_SYSTEMD_SYSTEMS"
Expand Down
5 changes: 4 additions & 1 deletion pcs/lib/communication/sbd.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ def _get_request_data(self):
return RequestData(self._get_request_action())

def _process_response(self, response):
report = response_to_report_item(response)
report = response_to_report_item(
response, severity=ReportItemSeverity.WARNING
)
if report is None:
self._on_success()
return
self._report(report)
return self._get_next_list()
Expand Down
10 changes: 10 additions & 0 deletions pcs/lib/communication/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from pcs.common import report_codes
from pcs.common.node_communicator import Request
from pcs.lib import reports
from pcs.lib.node_communication import response_to_report_item
from pcs.lib.errors import (
LibraryError,
Expand Down Expand Up @@ -173,6 +174,7 @@ class OneByOneStrategyMixin(StrategyBase):
"""
#pylint: disable=abstract-method
__iter = None
__successful = False

def get_initial_request_list(self):
"""
Expand All @@ -192,6 +194,14 @@ def _get_next_list(self):
except StopIteration:
return []

def _on_success(self):
self.__successful = True

def on_complete(self):
if not self.__successful:
self._report(reports.unable_to_perform_operation_on_any_node())
return None


class AllAtOnceStrategyMixin(StrategyBase):
"""
Expand Down
12 changes: 12 additions & 0 deletions pcs/lib/reports.py
Original file line number Diff line number Diff line change
Expand Up @@ -2856,3 +2856,15 @@ def tmp_file_write(file_path, content):
"content": content,
}
)


def unable_to_perform_operation_on_any_node():
"""
This report is raised whenever
pcs.lib.communication.tools.OneByOneStrategyMixin strategy mixin is used
for network communication and operation failed on all available hosts and
because of this it is not possible to continue.
"""
return ReportItem.error(
report_codes.UNABLE_TO_PERFORM_OPERATION_ON_ANY_NODE,
)

0 comments on commit 8b2665c

Please sign in to comment.