RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1895316 - collector _get_nodes not called when --cluster-type specified
Summary: collector _get_nodes not called when --cluster-type specified
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: sos
Version: 8.4
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: rc
: 8.4
Assignee: Pavel Moravec
QA Contact: Miroslav Hradílek
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-11-06 10:27 UTC by Miroslav Hradílek
Modified: 2021-05-19 08:38 UTC (History)
5 users (show)

Fixed In Version: sos-4.0-3.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2021-05-18 14:48:58 UTC
Type: Bug
Target Upstream Version:
Embargoed:
pm-rhel: mirror+


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github sosreport sos pull 2331 0 None closed [collector] allow overriding plain --cluster-type 2021-01-22 12:48:26 UTC

Description Miroslav Hradílek 2020-11-06 10:27:11 UTC
Description of problem:
It looks like master node is not queried for nodes when '--cluster-type' option is specified.

Version-Release number of selected component (if applicable):
# Unreleased package
# rpm -q sos sos-collector
sos-4.0-2.el8.noarch
package sos-collector is not installed

How reproducible:
100%

Steps to Reproduce:
# Setup
# ssh-keygen -t rsa -f $HOME/.ssh/id_rsa -N ''
# cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
# chmod og-wx ~/.ssh/authorized_keys
# cat >/usr/share/ovirt-engine/dbscripts/engine-psql.sh <<'EOF'
#!/bin/bash
# /usr/share/ovirt-engine/dbscripts/engine-psql.sh -c "select host_name from vds_static..."

echo "$@" >> /root/engine-psql.debug
EOF
# chmod +x /usr/share/ovirt-engine/dbscripts/engine-psql.sh
# cat /root/engine-psql.debug
cat: /root/engine-psql.debug: No such file or directory

# Repoduce
# echo -e "\n"| sos-collector -vvv --case-id=666 --no-local --cluster-type ovirt --master "127.0.0.1" -c "ovirt.cluster=whatever"
. . .
[ovirt] Query command for ovirt DB set to: SELECT host_name from vds where cluster_id in (select cluster_id FROM cluster WHERE name like 'whatever' and storage_pool_id in (SELECT id FROM storage_pool WHERE name like '%'))
[sos_collector:reduce_node_list] Node list reduced to []
. . .
# cat /root/engine-psql.debug
cat: /root/engine-psql.debug: No such file or directory

Actual results:
engine-psql.sh is not called to query database for nodes. (called through _get_nodes())

Expected results:
engine-psql.sh is not called to query database for nodes. (called through _get_nodes())

This is from sos-collector-1.8-2.el8.noarch for comparison
# Repoduce
# echo -e "\n"| sos-collector -vvv --case-id=666 --no-local --cluster-type ovirt --master "127.0.0.1" -c "ovirt.cluster=whatever"
. . .
[['ovirt']] Query command for ovirt DB set to: SELECT host_name from vds where cluster_id in (select cluster_id FROM cluster WHERE name like 'whatever' and storage_pool_id in (SELECT id FROM storage_pool WHERE name like '%'))
[sweetpig-16.4a2m.lab.eng.bos.redhat.com:run_command] Running command /usr/share/ovirt-engine/dbscripts/engine-psql.sh -c 'SELECT host_name from vds where cluster_id in (select cluster_id FROM cluster WHERE name like '"'"'whatever'"'"' and storage_pool_id in (SELECT id FROM storage_pool WHERE name like '"'"'%'"'"'))'
. . .
# cat engine-psql.debug 
-c SELECT host_name from vds where cluster_id in (select cluster_id FROM cluster WHERE name like 'whatever' and storage_pool_id in (SELECT id FROM storage_pool WHERE name like '%'))


Additional info:
I managed to trace it to the following method:
    def get_nodes_from_cluster(self):
        """Collects the list of nodes from the determined cluster cluster"""
        if self.cluster_type:
            nodes = self.cluster._get_nodes()
            self.log_debug('Node list: %s' % nodes)
            return nodes
        return []


When I change following code:
        if self.opts.cluster_type:
            if self.opts.cluster_type == 'none':
                self.cluster = self.clusters['jbon']
            else:
                self.cluster = self.clusters[self.opts.cluster_type]
            self.cluster.master = self.master

to
        if self.opts.cluster_type:
            if self.opts.cluster_type == 'none':
                self.cluster = self.clusters['jbon']
            else:
                self.cluster = self.clusters[self.opts.cluster_type]
                self.cluster_type = self.opts.cluster_type
            self.cluster.master = self.master

it works as expected. I'm not suggesting that as a patch. The issue might be that the self.cluster_type is no longer set by parsing options implicitly?

Comment 2 Jake Hunsaker 2020-11-06 14:45:29 UTC
So, this is currently intentional. The thought being if we can't reliably determine the cluster type, then we won't be able to reliably determine the node list. oVirt/RHV is probably the only potential exception to this, since node determination is done via DB query that is separated from the "normal" processes that make a system a RHV manager. For pacemaker for example, if we can't determine that a system is part of a pacemaker cluster then we have no way to assume that the `pcs` command is present or functional on the system.

The assumption here is that when specifying --cluster-type, users will also specify --nodes. That very well may be a wrong assumption to make, so let's tackle that first before deciding on a code change for this.

Comment 3 Pavel Moravec 2020-11-06 15:46:33 UTC
(In reply to Jake Hunsaker from comment #2)
> The assumption here is that when specifying --cluster-type, users will also
> specify --nodes. That very well may be a wrong assumption to make, so let's
> tackle that first before deciding on a code change for this.

Shouldn't we enforce that assumption in code, then? I.e. raise an error when --cluster-type is provided but --nodes not?

(I dont have much preference to either option of the quoted assumption)

Comment 4 Jake Hunsaker 2020-11-06 15:51:00 UTC
Definitely a solid point, that. Also, thinking on this more I'm convincing myself that the original thinking is wrong. We should be more in line with the idea of "since the user is explicitly saying this is the cluster type, then they know the mechanism to determine nodes is present". Whether or not that mechanism is _functional_ is not really a determination for us to make.

+1 to running get_nodes() when --cluster-type is manually specified.

Comment 5 Miroslav Hradílek 2020-11-06 16:01:48 UTC
I will drop you an email as the point I will try to make is not UX related but rather testing related.

From the UX point of view it makes sense to me that you specify also nodes and that it should fail if you do not. Not sure how users are expecting it to work.

Comment 6 Pavel Moravec 2020-11-10 07:57:16 UTC
(In reply to Jake Hunsaker from comment #4)
> Definitely a solid point, that. Also, thinking on this more I'm convincing
> myself that the original thinking is wrong. We should be more in line with
> the idea of "since the user is explicitly saying this is the cluster type,
> then they know the mechanism to determine nodes is present". Whether or not
> that mechanism is _functional_ is not really a determination for us to make.
> 
> +1 to running get_nodes() when --cluster-type is manually specified.

Jake, will you file upstream PR for this or shall I? (directly the patch that Mirek proposed, right?)

Comment 13 errata-xmlrpc 2021-05-18 14:48:58 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (sos bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2021:1604


Note You need to log in before you can comment on or make changes to this bug.