Bug 1650167 - foreman-maintain should not use spinner when stdout is not terminal
Summary: foreman-maintain should not use spinner when stdout is not terminal
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Satellite Maintain
Version: 6.5.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: 6.8.0
Assignee: Lukas Zapletal
QA Contact: Jameer Pathan
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-11-15 13:37 UTC by Ales Dujicek
Modified: 2023-12-15 16:13 UTC (History)
9 users (show)

Fixed In Version: rubygem-foreman_maintain-0.6.4
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-10-27 12:38:20 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Foreman Issue Tracker 28281 0 Normal Closed Spinner makes non-interactive terminal unusable 2020-08-16 15:38:58 UTC
Red Hat Product Errata RHBA-2020:4365 0 None None None 2020-10-27 12:38:41 UTC

Description Ales Dujicek 2018-11-15 13:37:18 UTC
Description of problem:

foreman-maintain creates loong redundant output when it is redirected to a file

# foreman-maintain service stop > fm.log
# cat fm.log | tr '\r' '\n' 
Running Stop Services
================================================================================
Check if command is run as root user:                                 [OK]
--------------------------------------------------------------------------------
Stop applicable services: 
Stopping the following service(s):

rh-mongodb34-mongod, postgresql, qdrouterd, qpidd, squid, pulp_celerybeat, pulp_resource_manager, pulp_streamer, pulp_workers, smart_proxy_dynflow_core, tomcat, dynflowd, httpd, puppetserver, foreman-proxy

                                                                                
| 
                                                                                
/ 
                                                                                
/ 
                                                                                
- stopping foreman-proxy
                                                                                
- stopping foreman-proxy
                                                                                
\ stopping puppetserver
                                                                                
\ stopping puppetserver
                                                                                
| stopping httpd
                                                                                
| stopping httpd
                                                                                
/ stopping httpd
                                                                                
- stopping httpd
                                                                                
\ stopping httpd
                                                                                
| stopping httpd
                                                                                
/ stopping httpd

...

\ stopping postgresql
                                                                                
| stopping postgresql
                                                                                
/ stopping postgresql
                                                                                
- stopping postgresql
                                                                                
\ stopping postgresql
                                                                                
| stopping postgresql
                                                                                
/ stopping postgresql
                                                                                
- stopping rh-mongodb34-mongod
                                                                                
- All services stopped                                                [OK]
--------------------------------------------------------------------------------



It could be simply:

Running Stop Services
================================================================================
Check if command is run as root user:                                 [OK]
--------------------------------------------------------------------------------
Stop applicable services: 
Stopping the following service(s):
rh-mongodb34-mongod, postgresql, qdrouterd, qpidd, squid, pulp_celerybeat, pulp_resource_manager, pulp_streamer, pulp_workers, smart_proxy_dynflow_core, tomcat, dynflowd, httpd, puppetserver, foreman-proxy
- stopping foreman-proxy
- stopping puppetserver
- stopping httpd
- stopping dynflowd
- stopping tomcat
- stopping smart_proxy_dynflow_core
- stopping pulp_workers
- stopping pulp_streamer
- stopping pulp_resource_manager
- stopping pulp_celerybeat
- stopping squid
- stopping qpidd
- stopping qdrouterd
- stopping postgresql
- stopping rh-mongodb34-mongod
- All services stopped                                                [OK]
--------------------------------------------------------------------------------


Version-Release number of selected component (if applicable):
rubygem-foreman_maintain-0.2.11-1.el7sat.noarch

Comment 2 Matt 2019-05-26 13:04:11 UTC
This would be really, really great to get fixed, including for *ALL* foremain-maintain subcommands.

The same issue (albeit on a much larger scale) shows up when running a Satellite backup in a Cron job via foremain-maintain, the output of which by default is sent via e-mail to the root user on the system. The e-mail sent by Cron is completely unreadable (see below for examples) and is so long that the e-mail actually gets truncated (most of the output is completely lost), making it useless. I've since made the decision to redirect the backup command to /dev/null so it's output doesn't get captured by cron and sent over e-mail, but it'd be really nice if the output could be sent over e-mail again in a readable state (without the spinner causing issues).

It would also probably be good to not use any formatting that only works correctly in a terminal (like colors), unless a terminal is being used for stdout, so you don't get strange characters and formatting in the files/e-mails/etc.

There were never any issues with this prior to the backup commands being absorbed into foremain-maintain (with the added spinner actions and formatting).



Example:


...
 --------------------------------------------------------------------------------
 Generate metadata:


| Checking connection to the Mongo DB

/ Collecting metadata

/ Collecting system release info

/ Collecting system release info

- Collecting list of plugins

- Collecting list of plugins

\ Collecting list of plugins

| Collecting list of plugins

...
...
#### (repeats 50+ times) ####
...
...

| Collecting list of plugins

/ Collecting list of plugins

- Collectin!
 g list of!
  proxy features

- Collecting list of proxy features

\ Collecting list of proxy features

| Collecting installed RPMs

| Collecting installed RPMs

/ Collecting installed RPMs

...
...

\ Collecting installed RPMs

| Collecting installed RPMs

/ Collecting installed RPMs

- Saving metadata to metadata.yml                                     [!
 32m[1m[O!
 K][0m
--------------------------------------------------------------------------------
Backup config files:


- Saving metadata to metadata.yml

\ Collecting config files to backup

\ Collecting config files to backup

| Collecting config files to backup

...
...
#### (repeats 100's of times) ####
...
...

| Collecting config files to backup

/ Collecting config files to backup

- Collecting config files to backup

\ Collecting config files to backup

| Collecting config files to backup

/ Collecting config files to backup

- Collecting config files to backup

\ Collecting config files to backup

#### -> e-mail ends (truncated)

Comment 3 Bryan Kearney 2019-11-18 13:00:28 UTC
Upstream bug assigned to lzap

Comment 4 Bryan Kearney 2019-11-18 13:00:31 UTC
Upstream bug assigned to lzap

Comment 5 Bryan Kearney 2020-05-11 15:30:17 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue https://projects.theforeman.org/issues/28281 has been resolved.

Comment 8 Jameer Pathan 2020-07-28 13:35:13 UTC
Verified

Verified with:
- Satellite 6.8.0 snap 10
- rubygem-foreman_maintain-0.6.8-1.el7sat.noarch

Test steps:
- "foreman-maintain service status > /tmp/test.log" executed from cron.

Observation:
- Readable output, and spinner is not visible.

Comment 12 errata-xmlrpc 2020-10-27 12:38:20 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 (Satellite 6.8 Satellite Maintenance Release), 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/RHBA-2020:4365


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