Bug 2048547

Summary: When using async_ssh true and for some reason the script retrieve.sh fails to, the task remain stuck
Product: Red Hat Satellite Reporter: Joniel Pasqualetto <jpasqual>
Component: Remote ExecutionAssignee: Adam Ruzicka <aruzicka>
Status: CLOSED ERRATA QA Contact: Peter Ondrejka <pondrejk>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 6.10.1CC: aruzicka, lstejska
Target Milestone: 6.12.0Keywords: Triaged
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-11-16 13:33:25 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:
Bug Depends On: 2124850, 2128209    
Bug Blocks:    

Description Joniel Pasqualetto 2022-01-31 13:45:01 UTC
Description of problem:

- Have option async_ssh set to true
- Have /var/tmp mounted with option noexec on clients
- Try to run any remote execution job will result in the job stuck on "running" forever. 
- Looking at the target server logs, we can see repeatedly connections calling the retrieve.sh:

~~~
Jan 31 08:09:50 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:10:50 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:11:51 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:12:51 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:13:52 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:14:52 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:15:52 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:16:53 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:17:53 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:18:54 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:19:54 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:20:55 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:21:55 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:22:55 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:23:56 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:24:56 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:25:57 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:26:57 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
Jan 31 08:27:58 nodename sudo:     rex : TTY=unknown ; PWD=/home/rex ; USER=root ; COMMAND=/var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
~~~

- Running the script manually, we can see that it never runs due to noexec:

~~~
# /var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh
-bash: /var/tmp/foreman-ssh-cmd-c5227fef-dd73-4ee9-b6cf-6be9226e0191/retrieve.sh: Permission denied
~~~


Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Configure foreman-proxy to use async_ssh
~~~
# grep async /etc/foreman-proxy/settings.d/remote_execution_ssh.yml 
# Whether to run remote execution jobs asynchronously
:async_ssh: true
~~~

2. Have a client configured with its remote_working_dir (/var/tmp by default) in a mountpoint with "noexec"

~~~
# mount |grep /var/tmp
tmpfs on /var/tmp type tmpfs (rw,noexec,relatime,seclabel,size=524288k)
~~~

3. Launch any command to be executed with remote execution. 

Actual results:

Job is initiated, but never ends. Doesn't return any errors either.

Expected results:
It should return an error, because the script is not being executed at all.

Additional info:
When using async_false, the jobs fails and returns the permission denied returned by the script execution.

Comment 2 Joniel Pasqualetto 2022-01-31 13:56:43 UTC
Agreed, but that's not the problem I'm reporting.

The problem is that if someone does that, the rex execution don't fail. It should fail, like it does when the async_ssh is false.

Comment 3 Bryan Kearney 2022-03-17 00:05:15 UTC
Moving this bug to POST for triage into Satellite since the upstream issue https://projects.theforeman.org/issues/34363 has been resolved.

Comment 6 Peter Ondrejka 2022-10-03 14:34:28 UTC
Verified on Satellite 6.12 sn 13, the rex job now fails with: "Error initializing command: RuntimeError - Failed to execute script on remote machine, exit code: 126" in described circumstances (async-ssh). The same goes for ssh provider, pull-mqtt still hangs but that is expected and tracked in https://bugzilla.redhat.com/show_bug.cgi?id=2118651

Comment 10 errata-xmlrpc 2022-11-16 13:33:25 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 (Important: Satellite 6.12 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:8506