Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
Red Hat Satellite engineering is moving the tracking of its product development work on Satellite 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 "Satellite project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs will be migrated starting at the end of May. 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 "Satellite project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/SAT-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 1465628

Summary: A remote job runs multiple times on a single server that belongs to multiple Host Collections
Product: Red Hat Satellite Reporter: Brian Coca <brcoca>
Component: Remote ExecutionAssignee: Adam Ruzicka <aruzicka>
Status: CLOSED ERRATA QA Contact: jcallaha
Severity: high Docs Contact:
Priority: high    
Version: 6.2.10CC: adprice, ahumbe, arunas.vaznevicius, aruzicka, asahni, bkearney, ccvc-p-linux-cdc, cduryee, inecas, jcallaha, pghadge, swestrich, vivpatil, will_darton, wpinheir
Target Milestone: UnspecifiedKeywords: FieldEngineering, PrioBumpField
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-foreman_remote_execution-1.3.3,rubygem-foreman_remote_execution-0.3.0.19-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1480352 (view as bug list) Environment:
Last Closed: 2017-09-25 18:59:44 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:
Attachments:
Description Flags
verification screenshot
none
rhel7_hotfix
none
rhel6_hotfix none

Description Brian Coca 2017-06-27 19:26:13 UTC
Description of problem:

When you run a remote job on a single host collection and it contains a system that belongs to multiple host collections, the job will run multiple times on that system.


How reproducible:

100%

Steps to Reproduce:

[root@sat62 ~]# hammer job-invocation create --job-template "Run Command - SSH Default" --inputs command='date +"%H:%M:%S.%N" >> /tmp/lala.txt' --search-query "host_collection = hostcol01"  
Job invocation 13 created
[........................................................................................................................................] [100%]
8 task(s), 6 success, 2 fail


^^Note: 8 tasks created.



[root@sat62 ~]# hammer host-collection info --id 3
ID:          3
Name:        hostcol01
Limit:       None
Description: 
Total Hosts: 4

^^ Note: hostcol01 has 4 hosts only.


[root@member-of-hostcol01 ~]# cat /tmp/lala.txt
18:26:55.103882174
18:26:55.104630745
18:26:55.273895571


^^ This specific member of hostcol01 belongs to 3 host collections. It ran this job 3 times.


[root@member-of-hostcol01 ~]# journalctl -u sshd --since 18:20:55
-- Logs begin at Dom 2017-06-25 04:35:12 UTC, end at Ter 2017-06-27 18:45:30 UTC. --
Jun 27 18:26:54 member-of-hostcol01.example.com sshd[2269]: Accepted publickey for root from 172.18.0.1 port 45202 ssh2: RSA ee:a4:a8:67:65:b9:a3:
Jun 27 18:26:54 member-of-hostcol01.example.com sshd[2271]: Accepted publickey for root from 172.18.0.1 port 45204 ssh2: RSA ee:a4:a8:67:65:b9:a3:
Jun 27 18:26:54 member-of-hostcol01.example.com sshd[2270]: Accepted publickey for root from 172.18.0.1 port 45203 ssh2: RSA ee:a4:a8:67:65:b9:a3:


^^ All 3 visits to this host on the same second.



[root@other-member-of-hostcol01 ~]# cat /tmp/lala.txt
18:26:54.671381525

^^ Note, this host belongs to a single Host Collection. It ran the remote job only once.


Actual results:

It created 8 tasks

Expected results:

4 tasks and the job to run only once.

Comment 1 Brian Coca 2017-06-27 19:27:34 UTC
*** Bug 1465621 has been marked as a duplicate of this bug. ***

Comment 2 Adam Ruzicka 2017-07-10 12:51:20 UTC
Created redmine issue http://projects.theforeman.org/issues/20260 from this bug

Comment 7 Satellite Program 2017-07-11 08:12:35 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/20260 has been resolved.

Comment 11 Satellite Program 2017-08-03 22:15:23 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/20260 has been resolved.

Comment 12 Ivan Necas 2017-08-08 07:05:27 UTC
*** Bug 1479091 has been marked as a duplicate of this bug. ***

Comment 13 jcallaha 2017-08-10 18:20:10 UTC
Verified in Satellite 6.3 Snap 10.

Added an RE-enabled host to 3 host collections, then executed the following command.

-bash-4.2# hammer job-invocation create --job-template "Run Command - SSH Default" --inputs command='date +"%H:%M:%S.%N" >> /root/test.txt' --search-query "host_collection = collection2"
Job invocation 3 created
[......................................] [100%]
1 task(s), 1 success, 0 fail


--- on the host ---
-bash-4.2# cat test.txt 
20:09:45.333383189

Comment 16 jcallaha 2017-08-28 19:52:03 UTC
Verified in Satellite 6.2.12 Snap 1.

Added a single host to two host collections then ran the below command.

-bash-4.1# hammer job-invocation create --job-template "Run Command - SSH Default" --inputs command='date +"%H:%M:%S.%N" >> /root/test.txt' --search-query "host_collection = coll2"
[Foreman] Password for admin: 
Job invocation 1 created
[..............................................................] [100%]
1 task(s), 1 success, 0 fail

on the target host, it is clear that it only ran once.

[root@ibm-x3250m4-06 ~]# cat test.txt 
15:46:30.231378802

Finally, see attached screenshot for job page.

Comment 17 jcallaha 2017-08-28 19:52:33 UTC
Created attachment 1319206 [details]
verification screenshot

Comment 25 Adam Price 2017-09-11 15:38:11 UTC
Created attachment 1324496 [details]
rhel7_hotfix

Comment 26 Adam Price 2017-09-11 15:38:44 UTC
Created attachment 1324497 [details]
rhel6_hotfix

Comment 27 Adam Price 2017-09-11 15:42:45 UTC
=== HOTFIX INSTRUCTIONS FOR SATELLITE 6.2.11 ONLY ===

1. Download attached hotfix RPM depending on your Satellite host OS version
2. Stop Satellite
  katello-service stop
3. Extract the tarball and install the package
4. Start Satellite
  katello-service start

Comment 28 Adam Price 2017-09-11 15:45:40 UTC
Amendment to 6.2.11 hotfix instructions:

The hotfix RPMs are not archived, so there isn't a tarball to extract in step 3.

Comment 30 errata-xmlrpc 2017-09-25 18:59:44 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, 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-2017:2803