Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 2004929

Summary: RFE request SOS collect sufficient information for offline analysis
Product: Red Hat Enterprise Linux 8 Reporter: Salvatore Daniele <sdaniele>
Component: sosAssignee: Pavel Moravec <pmoravec>
Status: CLOSED ERRATA QA Contact: Miroslav HradĂ­lek <mhradile>
Severity: medium Docs Contact:
Priority: medium    
Version: 8.5CC: agk, amorenoz, bmr, mhradile, plambri, pmoravec, sbradley, theute
Target Milestone: rcKeywords: FutureFeature, OtherQA, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: sos-4.2-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-05-10 15:16:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Salvatore Daniele 2021-09-16 13:09:45 UTC
Description of problem:
Currently the sos report lacks information that is needed to recreate ovs-vswitchd and ovs-db offline for debugging / analysis. 

This includes tlv map dumps for each bridge and group dumps which are being collected inconsistently.

Additionally the database is not currently collected in a format that can be used to restore the ovsdb-server.

With this information, offline proto/traces and various other tools could be run on offline replicas.

How reproducible:

Always

Steps to Reproduce:
1. Run sos report on an ovs-node

Actual results:
- db is not in a format that can be restored.
- tlv maps are missing
- group and -O flow dumps will only be available for bridges that specify protocols in ovs-vsctl get bridge <br> protocols

Expected results:

The sos report should contain all necessary information to recreate ovs-vswitchd and ovsdb-server offline without needing to request any additional information from the user.

Additional info:

Some of this information is already included in the sos report (i.e. flow and group dumps by bridge), however this is only collected if ovs-vsctl list bridge specifies protocols, which may not always be the case even when default protocols are in place.

The conf.db file is also needed, and is currently being gathered using ovsdb-client list dump. This is not a format that can be used to restore the db, and also requires interacting with the ovsdb-server which could potentially take it "down" for some time.

Comment 2 Salvatore Daniele 2021-09-16 13:16:56 UTC
I believe something like the following should achieve what I am proposing.

https://github.com/SalDaniele/sos/commit/7cfbaf3c1acaf4c5d1d32720108f916e0a25b69c
https://github.com/SalDaniele/sos/commit/50cf0322076031a3132a7be3abc6f9566613858b

Comment 3 Pavel Moravec 2021-09-16 14:20:59 UTC
In general, ACK (and thanks for such code snippets). Some minor comments:

1)
https://github.com/SalDaniele/sos/commit/7cfbaf3c1acaf4c5d1d32720108f916e0a25b69c#diff-5f39fe3a37e240e6dc0966f25ab1d0a6c18041ff11438e04a99a83a25d34a59eR256  :

br_protos == [''] or br_protos == [] ? I don't know the output being parsed there to decide, but the current [''] sounds like an oversight?


2)
https://github.com/SalDaniele/sos/commit/7cfbaf3c1acaf4c5d1d32720108f916e0a25b69c#diff-5f39fe3a37e240e6dc0966f25ab1d0a6c18041ff11438e04a99a83a25d34a59eR262  :

Isn't there redundant trailing space in "OpenFlow versions " ? Could you show us example output being parsed?


3)
https://github.com/SalDaniele/sos/commit/7cfbaf3c1acaf4c5d1d32720108f916e0a25b69c#diff-5f39fe3a37e240e6dc0966f25ab1d0a6c18041ff11438e04a99a83a25d34a59eR265

Isn't this for-cycle intended to be executed *inside* "for line in ofp_version_range:" cycle? As that cycle overwrites ver_range, no? (Or does the ofp_version_range outut contain *exactly* once "OpenFlow versions"? If so, we can add "break" to that cycle)


4)
Maybe some comment explaining what is being appended to br_protos will be meaningful - e.g. with an example output being parsed and what strings we need to fetch from it?


5) The "ovsdb-client -f list dump" being *removed* is intentional?


6) /etc/openvswitch/conf.db : can't it have some sensitive data (passwords, keys,..)? Can't the file be "too huge" to be collected? (I dont expect so as anything in few MBs is fully OK; default limit is 25MB we collect)


7) There is nothing common with https://bugzilla.redhat.com/show_bug.cgi?id=1975414 , right?

Comment 5 Salvatore Daniele 2021-09-16 16:39:13 UTC
(In reply to Pavel Moravec from comment #3)
> In general, ACK (and thanks for such code snippets). Some minor comments:
> 
> 1)
> https://github.com/SalDaniele/sos/commit/
> 7cfbaf3c1acaf4c5d1d32720108f916e0a25b69c#diff-
> 5f39fe3a37e240e6dc0966f25ab1d0a6c18041ff11438e04a99a83a25d34a59eR256  :
> 
> br_protos == [''] or br_protos == [] ? I don't know the output being parsed
> there to decide, but the current [''] sounds like an oversight?
> 
> 

'protocols           : []' is an example of line in 252 [1], which sets br_protos_ln to an empty string in the following lines. empty_string.split(", ") returns [''].

I agree it looks weird at a glace, I attached an example running this code on my KIND set up with various ovs-vsctl -t 5 list bridge to demonstrate the code will fall through to the default when "protocols : []"

[1] https://github.com/SalDaniele/sos/commit/7cfbaf3c1acaf4c5d1d32720108f916e0a25b69c#diff-5f39fe3a37e240e6dc0966f25ab1d0a6c18041ff11438e04a99a83a25d34a59eR252

> 2)
> https://github.com/SalDaniele/sos/commit/
> 7cfbaf3c1acaf4c5d1d32720108f916e0a25b69c#diff-
> 5f39fe3a37e240e6dc0966f25ab1d0a6c18041ff11438e04a99a83a25d34a59eR262  :
> 
> Isn't there redundant trailing space in "OpenFlow versions " ? Could you
> show us example output being parsed?
> 

Certainly!

Example output:
sh-5.0# ovs-ofctl -t 5 --version
ovs-ofctl (Open vSwitch) 2.15.0
OpenFlow versions 0x1:0x6

Example parsing:
for line in ofp_version_range:
    if "OpenFlow versions" in line:
        print("line:", line)
        versions = line.split("OpenFlow versions ")[1].split(":")
        print("versions:", versions)
        ver_range = range(int(versions[0], 16), int(versions[1], 16)+1)
        print("ver_range:", ver_range)

ouput:
line: OpenFlow versions 0x1:0x6
versions: ['0x1', '0x6']
ver_range: range(1, 7)

> 
> 3)
> https://github.com/SalDaniele/sos/commit/
> 7cfbaf3c1acaf4c5d1d32720108f916e0a25b69c#diff-
> 5f39fe3a37e240e6dc0966f25ab1d0a6c18041ff11438e04a99a83a25d34a59eR265
> 
> Isn't this for-cycle intended to be executed *inside* "for line in
> ofp_version_range:" cycle? As that cycle overwrites ver_range, no? (Or does
> the ofp_version_range outut contain *exactly* once "OpenFlow versions"? If
> so, we can add "break" to that cycle)
> 

"for line in ofp_version_range:" accesses the line "OpenFlow versions 0x1:0x6"
if it exists, and parses out the hex range (which correspond to the default OFP
hex values[1]).

It then appends each protocol in that range. So in this example above:

br_protos = ['OpenFlow10', 'OpenFlow11', 'OpenFlow12', 'OpenFlow13', 'OpenFlow14', 'OpenFlow15']
as they should all be supported by default [2]

Does that answer the question? Perhaps I missed something.

[1] https://opennetworking.org/wp-content/uploads/2014/10/openflow-switch-v1.5.1.pdf
[2] https://docs.openvswitch.org/en/latest/faq/openflow/

> 
> 4)
> Maybe some comment explaining what is being appended to br_protos will be
> meaningful - e.g. with an example output being parsed and what strings we
> need to fetch from it?
> 

Great, I can add that!

> 
> 5) The "ovsdb-client -f list dump" being *removed* is intentional?
> 

The thinking was that everything in the client list dump is included in conf.db. You
could recreate the list dump using conf.db.

However, the human readable list dump does not allow one to restore ovsdb-server.

Copying both therefore seemed redundant, and could nearly double the size of the report
in large clusters. ovsdb-client also requires interaction with the ovsdb-server, which
should be avoided if possible (as you point out, this is discussed in [7]).

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1975414

> 
> 6) /etc/openvswitch/conf.db : can't it have some sensitive data (passwords,
> keys,..)? Can't the file be "too huge" to be collected? (I dont expect so as
> anything in few MBs is fully OK; default limit is 25MB we collect)
> 
Yes, I know the issue of size was discussed in [1]. I am not sure at scale
how large this could potentially be. I was partially following the
precedent in [2] where this file would be collected in the event "check_6wind"
is true. 

WRT sensitive data, I don't believe this is the case, though I will look further
into this to confirm. It should just contain the configurations for Openv Switch
daemon.

If there are logistical issues that prevent collecting conf.db, using "ovsdb-client
backup" instead of "-f list dump" would allow for restoring ovsdb offline.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1975414
[2] https://github.com/sosreport/sos/blob/main/sos/report/plugins/openvswitch.py#L46

> 
> 7) There is nothing common with
> https://bugzilla.redhat.com/show_bug.cgi?id=1975414 , right?


The same logic here is what lead me to suggesting cp conf.db rather than using something
like ovsdb-client backup (Adrian M is my mentor at RH / on this offline visibility work).


One question I did have is redundant copying of files in the event self.add_copy_spec
is told to add the same file twice. Is this possible?

Comment 6 Pavel Moravec 2021-09-20 06:31:15 UTC
(In reply to Salvatore Daniele from comment #5)
> (In reply to Pavel Moravec from comment #3)
> > In general, ACK (and thanks for such code snippets). Some minor comments:
> > 
> > 1)
> > https://github.com/SalDaniele/sos/commit/
> > 7cfbaf3c1acaf4c5d1d32720108f916e0a25b69c#diff-
> > 5f39fe3a37e240e6dc0966f25ab1d0a6c18041ff11438e04a99a83a25d34a59eR256  :
> > 
> > br_protos == [''] or br_protos == [] ? I don't know the output being parsed
> > there to decide, but the current [''] sounds like an oversight?
> > 
> > 
> 
> 'protocols           : []' is an example of line in 252 [1], which sets
> br_protos_ln to an empty string in the following lines.
> empty_string.split(", ") returns [''].

Ah right, it is evident from the context (that split method with arguments returns a list of strings, not an empty list).


> 
> I agree it looks weird at a glace, I attached an example running this code
> on my KIND set up with various ovs-vsctl -t 5 list bridge to demonstrate the
> code will fall through to the default when "protocols : []"
> 
> [1]
> https://github.com/SalDaniele/sos/commit/
> 7cfbaf3c1acaf4c5d1d32720108f916e0a25b69c#diff-
> 5f39fe3a37e240e6dc0966f25ab1d0a6c18041ff11438e04a99a83a25d34a59eR252
> 
> > 2)
> > https://github.com/SalDaniele/sos/commit/
> > 7cfbaf3c1acaf4c5d1d32720108f916e0a25b69c#diff-
> > 5f39fe3a37e240e6dc0966f25ab1d0a6c18041ff11438e04a99a83a25d34a59eR262  :
> > 
> > Isn't there redundant trailing space in "OpenFlow versions " ? Could you
> > show us example output being parsed?
> > 
> 
> Certainly!
> 
> Example output:
> sh-5.0# ovs-ofctl -t 5 --version
> ovs-ofctl (Open vSwitch) 2.15.0
> OpenFlow versions 0x1:0x6
> 
> Example parsing:
> for line in ofp_version_range:
>     if "OpenFlow versions" in line:
>         print("line:", line)
>         versions = line.split("OpenFlow versions ")[1].split(":")
>         print("versions:", versions)
>         ver_range = range(int(versions[0], 16), int(versions[1], 16)+1)
>         print("ver_range:", ver_range)
> 
> ouput:
> line: OpenFlow versions 0x1:0x6
> versions: ['0x1', '0x6']
> ver_range: range(1, 7)

I see, thanks for the example.


> 
> > 
> > 3)
> > https://github.com/SalDaniele/sos/commit/
> > 7cfbaf3c1acaf4c5d1d32720108f916e0a25b69c#diff-
> > 5f39fe3a37e240e6dc0966f25ab1d0a6c18041ff11438e04a99a83a25d34a59eR265
> > 
> > Isn't this for-cycle intended to be executed *inside* "for line in
> > ofp_version_range:" cycle? As that cycle overwrites ver_range, no? (Or does
> > the ofp_version_range outut contain *exactly* once "OpenFlow versions"? If
> > so, we can add "break" to that cycle)
> > 
> 
> "for line in ofp_version_range:" accesses the line "OpenFlow versions
> 0x1:0x6"
> if it exists, and parses out the hex range (which correspond to the default
> OFP
> hex values[1]).
> 
> It then appends each protocol in that range. So in this example above:
> 
> br_protos = ['OpenFlow10', 'OpenFlow11', 'OpenFlow12', 'OpenFlow13',
> 'OpenFlow14', 'OpenFlow15']
> as they should all be supported by default [2]
> 
> Does that answer the question? Perhaps I missed something.

Yes, now I got it. I didnt know the output being traversed.


> 
> [1]
> https://opennetworking.org/wp-content/uploads/2014/10/openflow-switch-v1.5.1.
> pdf
> [2] https://docs.openvswitch.org/en/latest/faq/openflow/
> 
> > 
> > 4)
> > Maybe some comment explaining what is being appended to br_protos will be
> > meaningful - e.g. with an example output being parsed and what strings we
> > need to fetch from it?
> > 
> 
> Great, I can add that!

That would be great, such an example let me explain all my questions, I think :)


> One question I did have is redundant copying of files in the event
> self.add_copy_spec
> is told to add the same file twice. Is this possible?


If you include a file in two self.add_copy_spec within the *same* plugin, then it does not matter - since we keep the copy_paths as a set:

https://github.com/sosreport/sos/blob/05be120ef94fecac2aacb44f44bb0d2f29998cf6/sos/report/plugins/__init__.py#L574

If you include a file in two self.add_copy_spec in *different* plugins, then we dont recommend it. Although *usually* nothing happens here (hence just a recommendation) - the file is just redundantly overwritten. But as plugins work independently, they dont expect situations like:
- 1st plugin collects a logfile (still within a sizelimit, hence whole file)
- some new log records appear in the file, such that its size exceeds sizelimit
- 2nd plugin attempts to collect the logfile, due to sizelimit it collects just tail of it. That is stored as a symlink from path/to/logfile to sos_strings dir. Creating the symlink fails if the path/to/file is a regular file created by the 1st plugin.



The commits sounds very good. Let me know if you can prepare an upstream PR from them, or if I shall do it by myself.

Comment 7 Salvatore Daniele 2021-09-20 12:45:51 UTC
Great, thank you for your feedback! I can send it upstream, no worries.

Comment 8 Salvatore Daniele 2021-09-27 14:52:06 UTC
(In reply to Pavel Moravec from comment #6)
> (In reply to Salvatore Daniele from comment #5)
> > (In reply to Pavel Moravec from comment #3)

> The commits sounds very good. Let me know if you can prepare an upstream PR
> from them, or if I shall do it by myself.

I changed the version on the bz to 8.4, as upon further testing we've determined this would need to be applied to sos 4.0, since this will be what OpenStack customers will be running.

Would this be possible? If so, I can move forward with the PR.

Comment 13 Pavel Moravec 2021-10-11 20:24:25 UTC
Adding OtherQA, thanks for the codechanges and QA offer. Trying to get qa_ack as the last (harder :) ) step.

Comment 21 errata-xmlrpc 2022-05-10 15:16:32 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-2022:1998