-
Notifications
You must be signed in to change notification settings - Fork 74
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
[Test] Validate the status of hosts in cluster post upgrade #4257
Open
sayaleeraut
wants to merge
1
commit into
red-hat-storage:master
Choose a base branch
from
sayaleeraut:ceph_orch_marks_host_offline
base: master
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.
Open
Changes from all commits
Commits
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,84 @@ | ||
from json import loads | ||
|
||
from ceph.waiter import WaitUntil | ||
from cli.cephadm.cephadm import CephAdm | ||
from cli.exceptions import OperationFailedError, UnexpectedStateError | ||
from cli.utilities.utils import bring_node_offline | ||
from utility.log import Log | ||
|
||
log = Log(__name__) | ||
|
||
|
||
def check_host_status(node, hostname, status=None): | ||
""" | ||
Checks the status of host(offline or online) using | ||
ceph orch host ls and return boolean | ||
Args: | ||
node (ceph): Node in which the cmd is executed | ||
hostname: hostname of host to be checked | ||
status: custom status check for the host | ||
""" | ||
conf = {"host_pattern": hostname, "format": "json-pretty"} | ||
out = loads((CephAdm(node).ceph.orch.host.ls(**conf))[node[0].hostname][0]) | ||
host_status = out[0]["status"].lower().strip() | ||
if status is None: | ||
if host_status is None: | ||
log.info("Status of the host is online") | ||
return True | ||
else: | ||
if status.lower() == host_status: | ||
log.info(f"Status of the host is {host_status}") | ||
return True | ||
return False | ||
|
||
|
||
def run(ceph_cluster, **kw): | ||
"""Verify upgrade, host should not go offline | ||
Args: | ||
**kw: Key/value pairs of configuration information to be used in the test. | ||
""" | ||
config = kw["config"] | ||
nodes = [node for node in ceph_cluster.get_nodes() if node.role not in ["client"]] | ||
installer = ceph_cluster.get_nodes("installer") | ||
mon_node = ceph_cluster.get_nodes("mon")[1] | ||
ssh_keepalive_interval = config.get("ssh_keepalive_interval") | ||
ssh_keepalive_count_max = config.get("ssh_keepalive_count_max") | ||
|
||
# Check the status of all hosts in cluster | ||
for _node in nodes: | ||
out = check_host_status(installer, _node.hostname) | ||
if out: | ||
raise UnexpectedStateError("All hosts of cluster are not online") | ||
|
||
# Set the value of ssh_keepalive_interval as 30 | ||
CephAdm(installer).ceph.config.set( | ||
key="mgr/cephadm/ssh_keepalive_interval", | ||
value=ssh_keepalive_interval, | ||
daemon="mgr", | ||
) | ||
log.info("cephadm ssh_keepalive_interval is set to 30") | ||
|
||
# Set the value of ssh_keepalive_count_max as 7 | ||
CephAdm(installer).ceph.config.set( | ||
key="mgr/cephadm/ssh_keepalive_count_max", | ||
value=ssh_keepalive_count_max, | ||
daemon="mgr", | ||
) | ||
log.info("cephadm ssh_keepalive_count_max is set to 7") | ||
|
||
# Bring the mon_node down | ||
out = bring_node_offline(mon_node, timeout=120) | ||
if not out: | ||
raise OperationFailedError(f"Failed to bring {mon_node.hostname} offline") | ||
|
||
# Check the status of the host that is down is shown offline | ||
timeout, interval = 120, 5 | ||
for w in WaitUntil(timeout=timeout, interval=interval): | ||
out = check_host_status(installer, mon_node.hostname, "offline") | ||
if out: | ||
log.info("Host status is offline as expected") | ||
break | ||
if w.expired: | ||
raise OperationFailedError("Host status is not offline as expected") | ||
|
||
return 0 |
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.
HI @sayaleeraut
You can create method here for "check_host_status" as per your requirment
Thanks,
Mohit Bisht
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.
Done, added a local method to the test file itself.