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 1371279

Summary: [RFE] Running jobs that resolve to 0 hosts result as 'succeeded'
Product: Red Hat Satellite Reporter: Craig Donnelly <cdonnell>
Component: Remote ExecutionAssignee: satellite6-bugs <satellite6-bugs>
Status: CLOSED WONTFIX QA Contact:
Severity: low Docs Contact:
Priority: low    
Version: 6.2.0CC: aruzicka, bkearney, cdonnell, jcallaha
Target Milestone: UnspecifiedKeywords: FutureFeature
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: 2018-09-04 19:11:56 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 Craig Donnelly 2016-08-29 18:57:21 UTC
Description of problem:
If we run a remote execution job that has a 'search query' which resolves to 0 hosts, the job will still run but show a mis-leading success.

Version-Release number of selected component (if applicable):
Satellite 6.2.1:
rubygem-smart_proxy_remote_execution_ssh-0.1.2-2.el7sat.noarch
tfm-rubygem-smart_proxy_remote_execution_ssh_core-0.1.2-1.el7sat.noarch

How reproducible:
100%

Steps to Reproduce:
1. Goto Monitor -> Jobs
2. Click Run Job
3. Create a search query that resolves to 0 hosts, for example:
last_report < "30 minutes ago" and status.enabled = false
4. Submit job.

Actual results:
Shows evaluated against 0 hosts, but shows succeeded on right side (where we normally see percentage complete for job run).
Hosts tab is empty.
Monitor -> Jobs shows a job with 0 total hosts, and 0 actions, with status 'succeeded'.

Expected results:
Should not allow job to run if it resolves to 0 hosts on job submission.

Comment 2 Adam Ruzicka 2016-10-18 13:41:19 UTC
REX can handle resolving the search query two ways, static and dynamic. Static is evaluated when the user submits the form, dynamic is evaluated 

REX has two ways of resolving the search query. Citing the explanation from the new job invocation form:

"Type has impact on when is the query evaulated to hosts.
Static evaluates just after you submit this form.
Dynamic evaluates just before the execution is started, so if it's planed in future, targeted hosts set may change before it."

This means we can implement a check and display some kind of validation error in case there are no hosts, but this can be done only when using the static query. 

When using the dynamic query we could show some kind of warning like "right now, this search query would resolve to no hosts", but we can't stop the execution, because the query will be resolved later and the number of hosts matching it might change.

Would this work for you?

Comment 3 Adam Ruzicka 2016-10-18 13:41:56 UTC
Created redmine issue http://projects.theforeman.org/issues/16993 from this bug

Comment 4 Craig Donnelly 2016-10-31 16:31:31 UTC
This sounds fine to me.
I really was not aware of the other type of query.

Comment 5 Bryan Kearney 2018-09-04 18:59:53 UTC
Thank you for your interest in Satellite 6. We have evaluated this request, and we do not expect this to be implemented in the product in the foreseeable future. We are therefore closing this out as WONTFIX. If you have any concerns about this, please feel free to contact Rich Jerrido or Bryan Kearney. Thank you.

Comment 6 Bryan Kearney 2018-09-04 19:11:56 UTC
Thank you for your interest in Satellite 6. We have evaluated this request, and we do not expect this to be implemented in the product in the foreseeable future. We are therefore closing this out as WONTFIX. If you have any concerns about this, please feel free to contact Rich Jerrido or Bryan Kearney. Thank you.