Bug 2048517

Summary: service stop tries to execute CheckTftpStorage
Product: Red Hat Satellite Reporter: Evgeni Golov <egolov>
Component: Satellite MaintainAssignee: Amit Upadhye <aupadhye>
Status: CLOSED ERRATA QA Contact: Gaurav Talreja <gtalreja>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.11.0CC: apatel, kgaikwad, pcreech
Target Milestone: 6.11.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: rubygem-foreman_maintain-1.0.3 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-07-05 14:32:43 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 Evgeni Golov 2022-01-31 12:32:12 UTC
Description of problem:
Ohai,

on a Satellite 7.0, when PostgreSQL is down (because it was taken down via `systemctl stop postgresql`, e.g.) and one tries to issue `foreman-maintain service stop` you get a "Broken Pipe" error and nothing works.


Version-Release number of selected component (if applicable):
7.0 Snap 7 on EL8 (but shouldn't be EL8 specific, I think)

How reproducible:
100

Steps to Reproduce:
1. systemctl stop postgresql
2. foreman-maintain service stop

Actual results:
[root@dhcp-3-233 ~]# foreman-maintain service stop
Broken pipe
[root@dhcp-3-233 ~]# echo $?
1


Expected results:
Services are stopped.

Additional info:
Looking at the log, you see:
D, [2022-01-31 07:18:10-0500 #61305] DEBUG -- : Running command PGPASSWORD='[FILTERED]' psql -h localhost  -p 5432 -U foreman -d foreman with stdin "SELECT 1 as ping"
D, [2022-01-31 07:18:10-0500 #61305] DEBUG -- : output of the command:
 psql: error: could not connect to server: Connection refused
	Is the server running on host "localhost" (::1) and accepting
	TCP/IP connections on port 5432?
could not connect to server: Connection refused
	Is the server running on host "localhost" (127.0.0.1) and accepting
	TCP/IP connections on port 5432?
E, [2022-01-31 07:18:10-0500 #61305] ERROR -- : Please check whether database service is up & running state. (ForemanMaintain::Error::Fail)
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/concerns/base_database.rb:203:in `raise_service_error'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/concerns/base_database.rb:51:in `psql'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/concerns/base_database.rb:42:in `query_csv'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/concerns/base_database.rb:38:in `query'
/usr/share/gems/gems/foreman_maintain-1.0.1/definitions/checks/foreman_proxy/check_tftp_storage.rb:46:in `lookup_token_duration'
/usr/share/gems/gems/foreman_maintain-1.0.1/definitions/checks/foreman_proxy/check_tftp_storage.rb:33:in `non_zero_token_duration?'
/usr/share/gems/gems/foreman_maintain-1.0.1/definitions/checks/foreman_proxy/check_tftp_storage.rb:9:in `block (2 levels) in <class:CheckTftpStorage>'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/concerns/metadata.rb:226:in `instance_exec'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/concerns/metadata.rb:226:in `block in evaluate_confines'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/concerns/metadata.rb:225:in `all?'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/concerns/metadata.rb:225:in `evaluate_confines'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/concerns/metadata.rb:200:in `present?'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/detector.rb:53:in `block in find_present_classes'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/detector.rb:52:in `each'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/detector.rb:52:in `reduce'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/detector.rb:52:in `find_present_classes'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/detector.rb:38:in `available_checks'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/concerns/finders.rb:17:in `find_checks'
/usr/share/gems/gems/foreman_maintain-1.0.1/definitions/scenarios/services.rb:36:in `compose'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/scenario.rb:86:in `initialize'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/cli/service_command.rb:24:in `new'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/cli/service_command.rb:24:in `execute'
/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
/usr/share/gems/gems/clamp-1.1.2/lib/clamp/subcommand/execution.rb:11:in `execute'
/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:63:in `run'
/usr/share/gems/gems/foreman_maintain-1.0.1/lib/foreman_maintain/cli.rb:46:in `run'
/usr/share/gems/gems/clamp-1.1.2/lib/clamp/command.rb:132:in `run'
/usr/share/gems/gems/foreman_maintain-1.0.1/bin/foreman-maintain:15:in `<top (required)>'
/usr/bin/foreman-maintain:23:in `load'
/usr/bin/foreman-maintain:23:in `<main>'
I, [2022-01-31 07:18:10-0500 #61305]  INFO -- : foreman-maintain command finished with 1

Comment 1 Evgeni Golov 2022-01-31 12:43:13 UTC
Alternative error, still not very helpful:

[root@sat70 ~]# foreman-maintain service stop
Please check whether database service is up & running state.

Oh, and obviously, Satellite needs to be deployed with TFTP feature on (foreman-installer --foreman-proxy-tftp true)

Comment 2 Brad Buckingham 2022-01-31 14:12:13 UTC
This bug was opened as a result of bug 2048470.

Comment 3 Bryan Kearney 2022-02-05 02:18:48 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34386 has been resolved.

Comment 4 Gaurav Talreja 2022-02-23 15:43:48 UTC
Verified.

Tested on Satellite 7.0 Snap 10.0 for EL7 and EL8 installations
Version: rubygem-foreman_maintain-1.0.3-1.el8sat.noarch

Steps:
1. systemctl stop postgresql
2. foreman-maintain service stop
3. echo $?

Observation:
foreman-maintain service stop works fine when tftp is enabled(--foreman-proxy-tftp true) with no broken pipe errors and able to start/restart stopped services.

Comment 8 errata-xmlrpc 2022-07-05 14:32:43 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 (Moderate: Satellite 6.11 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/RHSA-2022:5498