Bug 1468388

Summary: [RFE] Tasks: allow for searching of tasks by 'user'
Product: Red Hat Satellite Reporter: Chris Duryee <cduryee>
Component: Tasks PluginAssignee: Ivan Necas <inecas>
Status: CLOSED ERRATA QA Contact: Peter Ondrejka <pondrejk>
Severity: medium Docs Contact:
Priority: medium    
Version: 6.2.10CC: aruzicka, bkearney, egolov, inecas, jcallaha, mmccune, nshaik
Target Milestone: 6.7.0Keywords: FieldEngineering, FutureFeature, Reopened, UserExperience
Target Release: Unused   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: tfm-rubygem-foreman-tasks-0.17.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-14 13:22:16 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: 1631812    
Bug Blocks:    
Attachments:
Description Flags
Search by admin User none

Description Chris Duryee 2017-07-06 23:03:20 UTC
Description of problem:

It is not currently possible to search for tasks using the search bar via the 'user' field. If you attempt this, an error is raised.

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


How reproducible: every time


Steps to Reproduce:
1. go to /foreman_tasks/tasks page
2. put 'user' in the search box, nothing auto-fills
3. type 'user = admin'

Actual results: error page saying that 'user' is not a valid search term


Expected results: successful search 


Additional info: it's useful to search tasks by users to find syncs that were kicked off by a user at a particular time.

Comment 7 Adam Ruzicka 2017-08-28 11:29:53 UTC
Created redmine issue http://projects.theforeman.org/issues/20755 from this bug

Comment 8 Nagoor Shaik 2017-09-15 12:31:45 UTC
I believe we can do this currently with following search 

 owner.login = admin

Comment 9 Ivan Necas 2017-09-15 16:08:52 UTC
That's right. Thanks @nagoor for pointing out this

Comment 10 Chris Duryee 2017-09-15 20:26:53 UTC
can 'user' be added as a synonym for owner.login? it's difficult to figure out from the web ui to use owner.login, since the column is named 'user'.

Comment 11 Ivan Necas 2017-09-19 08:09:32 UTC
I'm ok with this: opened a PR upstream for it https://github.com/theforeman/foreman-tasks/pull/283

Comment 12 Satellite Program 2017-09-19 10:03:36 UTC
Upstream bug assigned to inecas

Comment 13 Satellite Program 2017-09-19 10:03:40 UTC
Upstream bug assigned to inecas

Comment 14 Satellite Program 2017-09-19 16:03:49 UTC
Moving this bug to POST for triage into Satellite 6 since the upstream issue http://projects.theforeman.org/issues/20755 has been resolved.

Comment 15 Chris Brown 2018-07-30 20:49:23 UTC
Created attachment 1471642 [details]
Search by admin User

Verified in Satellite 6.4

Comment 20 Satellite Program 2018-09-06 10:04:47 UTC
Upstream bug assigned to aruzicka

Comment 21 Satellite Program 2018-09-06 10:04:51 UTC
Upstream bug assigned to aruzicka

Comment 30 Bryan Kearney 2019-06-04 22:03:56 UTC
Upstream bug assigned to inecas

Comment 31 Bryan Kearney 2019-09-30 12:03:51 UTC
Upstream bug assigned to aruzicka

Comment 32 Bryan Kearney 2019-11-10 01:03:44 UTC
Upstream bug assigned to inecas

Comment 36 Perry Gagne 2019-12-02 20:59:26 UTC
FailedQA, tested in sat 6.7 snap 4

Search tasks with query "user = admin" got "Could Not Receive Data: Request Failed With Status Code 500"

searching with "owner.login = admin" seem to work ok though. 

attached foreman-debug

Not sure if it helps, but here is dynflow-executor.log:
SIGTERM
["/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:55:in `sleep'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:55:in `block in watch'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:42:in `loop'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:42:in `watch'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:66:in `block in start_with_pidfile'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:61:in `fork'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:61:in `start_with_pidfile'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/monitor.rb:92:in `start'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/application_group.rb:141:in `create_monitor'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/application.rb:283:in `start'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/controller.rb:56:in `run'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons.rb:193:in `block in run_proc'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons/cmdline.rb:88:in `catch_exceptions'", "/opt/theforeman/tfm/root/usr/share/gems/gems/daemons-1.2.3/lib/daemons.rb:192:in `run_proc'", "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.1/lib/dynflow/rails/daemon.rb:73:in `block in run_background'", "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.1/lib/dynflow/rails/daemon.rb:72:in `times'", "/opt/theforeman/tfm/root/usr/share/gems/gems/dynflow-1.4.1/lib/dynflow/rails/daemon.rb:72:in `run_background'", "/usr/sbin/dynflowd:71:in `block in <main>'", "/usr/sbin/dynflowd:67:in `chdir'", "/usr/sbin/dynflowd:67:in `<main>'"]

Comment 38 Bryan Kearney 2019-12-02 21:03:53 UTC
Upstream bug assigned to inecas

Comment 39 Adam Ruzicka 2019-12-03 09:25:12 UTC
2019-12-03T10:21:14 [D|app|aec885e2] Backtrace for 'Action failed' error (ActiveRecord::StatementInvalid): PG::AmbiguousColumn: ERROR:  ORDER BY "started_at" is ambiguous                                                                  
 | LINE 1: ...,4)) WHERE (("users"."login" = 'admin')) ORDER BY started_at...                                                                                                                                                               
 |                                                              ^                                                                                                                                                                           
 | : SELECT  DISTINCT foreman_tasks_tasks.*, *, coalesce(ended_at, current_timestamp) - coalesce(coalesce(started_at, ended_at), current_timestamp) as duration, "foreman_tasks_tasks"."id" AS t0_r0, "foreman_tasks_tasks"."type" AS t0_r1,
 "foreman_tasks_tasks"."label" AS t0_r2, "foreman_tasks_tasks"."started_at" AS t0_r3, "foreman_tasks_tasks"."ended_at" AS t0_r4, "foreman_tasks_tasks"."state" AS t0_r5, "foreman_tasks_tasks"."result" AS t0_r6, "foreman_tasks_tasks"."ext
ernal_id" AS t0_r7, "foreman_tasks_tasks"."parent_task_id" AS t0_r8, "foreman_tasks_tasks"."start_at" AS t0_r9, "foreman_tasks_tasks"."start_before" AS t0_r10, "foreman_tasks_tasks"."action" AS t0_r11, "foreman_tasks_tasks"."user_id" AS
 t0_r12, "foreman_tasks_tasks"."state_updated_at" AS t0_r13, "users"."id" AS t1_r0, "users"."login" AS t1_r1, "users"."firstname" AS t1_r2, "users"."lastname" AS t1_r3, "users"."mail" AS t1_r4, "users"."admin" AS t1_r5, "users"."last_l$
gin_on" AS t1_r6, "users"."auth_source_id" AS t1_r7, "users"."created_at" AS t1_r8, "users"."updated_at" AS t1_r9, "users"."password_hash" AS t1_r10, "users"."password_salt" AS t1_r11, "users"."locale" AS t1_r12, "users"."avatar_hash" $
S t1_r13, "users"."default_organization_id" AS t1_r14, "users"."default_location_id" AS t1_r15, "users"."lower_login" AS t1_r16, "users"."mail_enabled" AS t1_r17, "users"."timezone" AS t1_r18, "users"."description" AS t1_r19 FROM "fore$
an_tasks_tasks" LEFT OUTER JOIN "users" ON "users"."id" = "foreman_tasks_tasks"."user_id" AND (users.id IN (1,2,3,4,2,4,1,3,4)) WHERE (("users"."login" = 'admin')) ORDER BY started_at DESC LIMIT $1 OFFSET $2
-----B<-----SNIP-----B<-----
 | /home/aruzicka/projects/foreman/foreman-tasks/app/controllers/foreman_tasks/api/tasks_controller.rb:299:in `map'                                                                                                                         
 | /home/aruzicka/projects/foreman/foreman-tasks/app/controllers/foreman_tasks/api/tasks_controller.rb:299:in `tasks_list'
-----B<-----SNIP-----B<-----

If you sort by duration, the search for "user = admin" should work. It seems that the default ordering is somehow interfering with the search.

Comment 40 Adam Ruzicka 2019-12-04 13:04:13 UTC
The failure is being addressed in https://bugzilla.redhat.com/show_bug.cgi?id=1779653

Comment 42 Peter Ondrejka 2020-01-15 10:45:34 UTC
Verified on Sat 6.7 snap 8, using all supported search symbols

Comment 45 errata-xmlrpc 2020-04-14 13:22:16 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/RHSA-2020:1454