Skip to content
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

Fix: ui_node: prevent traceback on node standby #1299

Merged
merged 2 commits into from
Mar 4, 2024

Conversation

freishutz
Copy link
Contributor

Crm throws traceback on crm node standby if cluster (corosync/pacemaker) stopped.

[root@es-3-virt1 ~]# rpm -qa | grep crmsh
crmsh-4.5.1-1.el8.noarch
crmsh-scripts-4.5.1-1.el8.noarch
crmsh-test-4.5.1-1.el8.noarch

[root@es-3-virt1 ~]# crm cluster stop
WARNING: crmsh configuration is inconsistent in cluster.
INFO: The cluster stack already stopped on es-3-virt1

[root@es-3-virt1 ~]# crm node standby
WARNING: crmsh configuration is inconsistent in cluster.
ERROR: running cibadmin -Ql: Could not connect to the CIB: Transport endpoint is not connected
Init failed, could not perform requested operations

Traceback (most recent call last):
  File "/usr/sbin/crm", line 53, in <module>
    rc = main.run()
  File "/usr/lib/python3.6/site-packages/crmsh/main.py", line 369, in run
    return main_input_loop(context, user_args)
  File "/usr/lib/python3.6/site-packages/crmsh/main.py", line 247, in main_input_loop
    rc = handle_noninteractive_use(context, user_args)
  File "/usr/lib/python3.6/site-packages/crmsh/main.py", line 204, in handle_noninteractive_use
    if context.run(' '.join(l)):
  File "/usr/lib/python3.6/site-packages/crmsh/ui_context.py", line 86, in run
    rv = self.execute_command() is not False
  File "/usr/lib/python3.6/site-packages/crmsh/ui_context.py", line 271, in execute_command
    rv = self.command_info.function(*arglist)
  File "/usr/lib/python3.6/site-packages/crmsh/ui_node.py", line 397, in do_standby
    xml_item_list = cib.xpath(xml_path)
AttributeError: 'NoneType' object has no attribute 'xpath'

[root@es-3-virt1 ~]# echo $?
1

[root@es-3-virt1 ~]# cp /usr/lib/python3.6/site-packages/crmsh/ui_node.py{,.orig}
[root@es-3-virt1 ~]# vim /usr/lib/python3.6/site-packages/crmsh/ui_node.py
[root@es-3-virt1 ~]# diff -Naru /usr/lib/python3.6/site-packages/crmsh/ui_node.py.orig /usr/lib/python3.6/site-packages/crmsh/ui_node.py
--- /usr/lib/python3.6/site-packages/crmsh/ui_node.py.orig      2024-01-08 14:43:49.166728433 +0000
+++ /usr/lib/python3.6/site-packages/crmsh/ui_node.py   2024-01-08 14:44:50.942622070 +0000
@@ -376,6 +376,8 @@
             xml_query_path_oppsite = constants.XML_NODE_QUERY_STANDBY_PATH

         cib = xmlutil.cibdump2elem()
+        if cib is None:
+            return False
         # IMPORTANT:
         # Do NOT call cibdump2elem twice, or you risk a race where the
         # resulting diff will contain more changes than the values for

[root@es-3-virt1 ~]# crm node standby ; echo $?
WARNING: crmsh configuration is inconsistent in cluster.
ERROR: running cibadmin -Ql: Could not connect to the CIB: Transport endpoint is not connected
Init failed, could not perform requested operations

1

```
[root@es-3-virt1 ~]# rpm -qa | grep crmsh
crmsh-4.5.1-1.el8.noarch
crmsh-scripts-4.5.1-1.el8.noarch
crmsh-test-4.5.1-1.el8.noarch

[root@es-3-virt1 ~]# crm cluster stop
WARNING: crmsh configuration is inconsistent in cluster.
INFO: The cluster stack already stopped on es-3-virt1

[root@es-3-virt1 ~]# crm node standby
WARNING: crmsh configuration is inconsistent in cluster.
ERROR: running cibadmin -Ql: Could not connect to the CIB: Transport endpoint is not connected
Init failed, could not perform requested operations

Traceback (most recent call last):
  File "/usr/sbin/crm", line 53, in <module>
    rc = main.run()
  File "/usr/lib/python3.6/site-packages/crmsh/main.py", line 369, in run
    return main_input_loop(context, user_args)
  File "/usr/lib/python3.6/site-packages/crmsh/main.py", line 247, in main_input_loop
    rc = handle_noninteractive_use(context, user_args)
  File "/usr/lib/python3.6/site-packages/crmsh/main.py", line 204, in handle_noninteractive_use
    if context.run(' '.join(l)):
  File "/usr/lib/python3.6/site-packages/crmsh/ui_context.py", line 86, in run
    rv = self.execute_command() is not False
  File "/usr/lib/python3.6/site-packages/crmsh/ui_context.py", line 271, in execute_command
    rv = self.command_info.function(*arglist)
  File "/usr/lib/python3.6/site-packages/crmsh/ui_node.py", line 397, in do_standby
    xml_item_list = cib.xpath(xml_path)
AttributeError: 'NoneType' object has no attribute 'xpath'

[root@es-3-virt1 ~]# echo $?
1

[root@es-3-virt1 ~]# cp /usr/lib/python3.6/site-packages/crmsh/ui_node.py{,.orig}
[root@es-3-virt1 ~]# vim /usr/lib/python3.6/site-packages/crmsh/ui_node.py
[root@es-3-virt1 ~]# diff -Naru /usr/lib/python3.6/site-packages/crmsh/ui_node.py.orig /usr/lib/python3.6/site-packages/crmsh/ui_node.py
--- /usr/lib/python3.6/site-packages/crmsh/ui_node.py.orig      2024-01-08 14:43:49.166728433 +0000
+++ /usr/lib/python3.6/site-packages/crmsh/ui_node.py   2024-01-08 14:44:50.942622070 +0000
@@ -376,6 +376,8 @@
             xml_query_path_oppsite = constants.XML_NODE_QUERY_STANDBY_PATH

         cib = xmlutil.cibdump2elem()
+        if cib is None:
+            return False
         # IMPORTANT:
         # Do NOT call cibdump2elem twice, or you risk a race where the
         # resulting diff will contain more changes than the values for

[root@es-3-virt1 ~]# crm node standby ; echo $?
WARNING: crmsh configuration is inconsistent in cluster.
ERROR: running cibadmin -Ql: Could not connect to the CIB: Transport endpoint is not connected
Init failed, could not perform requested operations

1
```
@liangxin1300
Copy link
Collaborator

@freishutz Good catch!

Could you please fix the same issue on crm node online?

Thanks!

Copy link

codecov bot commented Jan 9, 2024

Codecov Report

Attention: 2 lines in your changes are missing coverage. Please review.

Comparison is base (d797e04) 52.95% compared to head (72f6851) 52.95%.

Files Patch % Lines
crmsh/ui_node.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1299      +/-   ##
==========================================
- Coverage   52.95%   52.95%   -0.01%     
==========================================
  Files          79       79              
  Lines       25055    25059       +4     
==========================================
+ Hits        13268    13270       +2     
- Misses      11787    11789       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@freishutz
Copy link
Contributor Author

@freishutz Good catch!

Could you please fix the same issue on crm node online?

Thanks!

Done.

@liangxin1300 liangxin1300 merged commit 94b4c39 into ClusterLabs:master Mar 4, 2024
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants