diff options
author | Fernando Royo <froyo@redhat.com> | 2022-10-25 11:33:37 +0200 |
---|---|---|
committer | Jake Hunsaker <jhunsake@redhat.com> | 2022-10-26 10:41:09 -0400 |
commit | 9b6de1e69bbb645f71cbc3006757b3e4c2c88970 (patch) | |
tree | 0c97d88edb2309c39bacfb9a87fe298eb211cd5d | |
parent | 80dd424ca90c4cc1871fefa2b17d453ea400ddfb (diff) | |
download | sos-9b6de1e69bbb645f71cbc3006757b3e4c2c88970.tar.gz |
[ovn_central] Add --no-leader-only to ovn-nbctl/ovn-sbctl commands
The option --no-leader-only will allow to run ovn-nbctl or
ovn-sbctl in all nodes, independently if we are in a clustered
or non-clustered enviroment.
The current check of executing commands only on nodes identified
as Leader, causes that in non-cluster environments (active/backup
mode) ovn-sbctl commands are not executed, not reporting the dump
of the tables.
By adding this parameter to the execution, which does not harm
non-clustered environments (active/backup), the command is executed
over the local database.
-rw-r--r-- | sos/report/plugins/ovn_central.py | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/sos/report/plugins/ovn_central.py b/sos/report/plugins/ovn_central.py index 16d7203c..8c37580c 100644 --- a/sos/report/plugins/ovn_central.py +++ b/sos/report/plugins/ovn_central.py @@ -13,7 +13,6 @@ from sos.report.plugins import ( RedHatPlugin, DebianPlugin, UbuntuPlugin, - SoSPredicate, ) import json import os @@ -98,41 +97,37 @@ class OVNCentral(Plugin): # Some user-friendly versions of DB output nbctl_cmds = [ - 'ovn-nbctl show', - 'ovn-nbctl get-ssl', - 'ovn-nbctl get-connection', - 'ovn-nbctl list loadbalancer', - 'ovn-nbctl list Load_Balancer', - 'ovn-nbctl list ACL', - 'ovn-nbctl list Logical_Switch_Port', + 'ovn-nbctl --no-leader-only show', + 'ovn-nbctl --no-leader-only get-ssl', + 'ovn-nbctl --no-leader-only get-connection', + 'ovn-nbctl --no-leader-only list loadbalancer', + 'ovn-nbctl --no-leader-only list Load_Balancer', + 'ovn-nbctl --no-leader-only list ACL', + 'ovn-nbctl --no-leader-only list Logical_Switch_Port', ] sbctl_cmds = [ - 'ovn-sbctl show', - 'ovn-sbctl lflow-list', - 'ovn-sbctl get-ssl', - 'ovn-sbctl get-connection', + 'ovn-sbctl --no-leader-only show', + 'ovn-sbctl --no-leader-only lflow-list', + 'ovn-sbctl --no-leader-only get-ssl', + 'ovn-sbctl --no-leader-only get-connection', ] # backward compatibility for path in ['/usr/share/openvswitch', '/usr/share/ovn']: nb_tables = self.get_tables_from_schema(self.path_join( path, 'ovn-nb.ovsschema')) - self.add_database_output(nb_tables, nbctl_cmds, 'ovn-nbctl') + self.add_database_output(nb_tables, nbctl_cmds, + 'ovn-nbctl --no-leader-only') cmds = nbctl_cmds - # Can only run sbdb commands if we are the leader - co = {'cmd': "ovs-appctl -t {} cluster/status OVN_Southbound". - format(self.ovn_sbdb_sock_path), - "output": "Leader: self"} - if self.test_predicate(self, pred=SoSPredicate(self, cmd_outputs=co)): - # backward compatibility - for path in ['/usr/share/openvswitch', '/usr/share/ovn']: - sb_tables = self.get_tables_from_schema(self.path_join( - path, 'ovn-sb.ovsschema'), ['Logical_Flow']) - self.add_database_output(sb_tables, sbctl_cmds, 'ovn-sbctl') - cmds += sbctl_cmds + for path in ['/usr/share/openvswitch', '/usr/share/ovn']: + sb_tables = self.get_tables_from_schema(self.path_join( + path, 'ovn-sb.ovsschema'), ['Logical_Flow']) + self.add_database_output(sb_tables, sbctl_cmds, + 'ovn-sbctl --no-leader-only') + cmds += sbctl_cmds # If OVN is containerized, we need to run the above commands inside # the container. |