rails / mission_control-jobs

Dashboard and Active Job extensions to operate and troubleshoot background jobs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add more filters to the different job statuses

rosa opened this issue · comments

For example, filter scheduled jobs by scheduled_at time ranges, or finished jobs by finished_at time ranges, or blocked jobs by the block (Blocked by) key. The current filters by queue name and job class are generic and apply to all statuses, but we could have some filters that apply only to certain statuses. The Adapter#supported_filters already takes a JobsRelation as argument, so it can easily return different filters depending on jobs_relation.status.

I'd like to tackle this one!

hi @bruno-oliveira, are u still working on this?

hi @rosa, is it okay if give this a try?

@Xeitor sure thing!

One thing that would be awesome here would be if we could filter on a job argument. The basic scenario is that we do a lot of jobs on different accounts, and often we have questions of "what is still running for Account X". Right now we use sidekiq and do something kludgy to access this in the UI, and doing it properly with Mission Control would be really awesome.

@nhorton: sure, sounds useful, will take a look

hi @rosa, sorry for the delay, I've been getting myself familiar with the codebase

I was hoping you could help me out with a doubt, I am confused about what you said in the description about using Adapter#supported_filters (a method that seems to no longer exist) for returning filters based on the JobsRelation status, for what I can see, Adapters#supported_job_filters is used for returning filters suppoted natively by the adapter.

I just realized there already is some logic for raising errors if a filter is set for a non supported job status

example: raise ActiveJob::Errors::QueryError, "Filtering by worker id is not supported for status #{jobs_relation.status}" in lib/active_job/queue_adapters/solid_queue_ext.rb

I am guessing we could have one hand an error raised if a filter is used for the wrong status (like in the example above) and in the other a method like the one you mention (Adapter#supported_filters) for checking in the views if the filter should be used for the current status

Hey @Xeitor, sorry, my description was from over 2 months ago, and things have changed since then. Adapters#supported_job_filters takes a job_relation as argument and can use that to decide what filters are supported, just like this:

def supported_job_filters(jobs_relation)
if jobs_relation.pending? then [ :queue_name ]
else []
end
end

It takes into account what filters the adapter supports but also the jobs_relation.status.

hi, no problem, from what I can tell, Adapters#supported_job_filters will return the natively supported filters for the adapter (taking into account the jobs_relation status), for example:

def supported_job_filters(jobs_relation)
if jobs_relation.pending? then [ :queue_name ]
else []
end
end

in the resque adapter :queue_name filter can be performed natively if jobs_relation is pending and it will perform it in memory otherwise, :job_class_name will be performed in memory no matter the jobs_relation status

so I suppose we need another method that tells you if the filter is supported for the status, unless I am missing something

@Xeitor ah yes! Sorry, you're totally correct. Other filters could not be natively supported but are fine if performed in memory. I was getting confused with supported_job_statuses, which has nothing to do 😅

I'll continue the discussion in the PR, ultimately these are all implementation details that might not matter in the end.

@rosa no problem, thanks for your help :)