Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Reschedule, Discard, Retry Job buttons to Dashboard #425

Merged
merged 1 commit into from
Oct 25, 2021
Merged

Conversation

bensheldon
Copy link
Owner

@bensheldon bensheldon commented Oct 18, 2021

Connects to #256.

The Retry action is only available upon Discarded Jobs. I'm considering having each job have all of the actions displayed but disabled if they are not relevant for the current state of the action. Once there are more actions, it should be clearer whether this is good or not.

Adds Schedule Now, Retry, and Discard buttons to Jobs. All of the buttons are present but are disabled if not relevant to the current job state.

Screen Shot 2021-10-20 at 9 45 45 PM

@bensheldon bensheldon temporarily deployed to goodjob-retry-jobs-ea8lyp814ni October 18, 2021 00:26 Inactive
@bensheldon bensheldon temporarily deployed to goodjob-retry-jobs-ea8lyp814ni October 18, 2021 00:32 Inactive
@@ -123,5 +133,30 @@ def running?
advisory_locked?
end
end

def retry_job
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if it wouldn't be easier to just change the schedule_at timestamp to current time, so it is handled in the regular way instead of doing it inline.
Wouldn't that work for some reason?

active_job = execution.active_job

raise AdapterNotGoodJobError unless active_job.class.queue_adapter.is_a? GoodJob::Adapter
raise ActionForStateMismatchError unless status == :discarded
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be useful to run the job even if it is not discarded yet. It could be called "Execute now" on UI or similar.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I'm imagining there being Reschedule Now, and also Discard (e.g. cancel it if it's already scheduled).

My intention is to try to perform the actions in the most ActiveJob manner (e.g. to have callbacks working), which requires some complexity. It may end up being more complexity than I can stomach though. I'm trying to keep the language symmetrical with ActiveJob (e.g. Retry, Discard, Re-Schedule).

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@morgoth I updated the PR to include 3 actions. I'd love your feedback.

I think potentially there is a 4th action too which is "create a new job with the same parameters" ("Duplicate job"?)

@bensheldon bensheldon added the enhancement New feature or request label Oct 19, 2021
@bensheldon bensheldon temporarily deployed to goodjob-retry-jobs-ea8lyp814ni October 21, 2021 00:00 Inactive
@bensheldon bensheldon temporarily deployed to goodjob-retry-jobs-ea8lyp814ni October 21, 2021 00:02 Inactive
@bensheldon bensheldon temporarily deployed to goodjob-retry-jobs-ea8lyp814ni October 21, 2021 04:36 Inactive
@bensheldon bensheldon changed the title Add "Retry job" button to Dashboard for Discarded jobs Add Reschedule, Discard, Retry buttons to Dashboard Oct 21, 2021
@bensheldon bensheldon temporarily deployed to goodjob-retry-jobs-ea8lyp814ni October 21, 2021 04:59 Inactive
end
end

def reschedule_job(scheduled_at = Time.current)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need reschedule and retry? I find it a bit confusing on the UI. I guess having single "Schedule now" or "Execute now" would be simpler.

Also what about https://github.com/bensheldon/good_job/pull/425/files#r730604390
Wouldn't work to update scheduled_at and remove finished_at for that case to have it run in the regular way?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I misunderstood your first comments. And it isn't helped by me not having added docs to any of this. I'll try to answer the conceptual stuff here, and then add the code documentation.

  • I would like to match the verbs of ActiveJob (e.g. retry, discard), which I'm hoping helps with cognitive load (both as a GoodJob maintainer and end-developer/operator)
  • I admit there is messy conceptual overlap in the implementation between Job and Execution. A Job has many Executions, but the Job itself is not modeled in the database (In the DB, the Job is a group-by of Executions). I'd like to keep Executions immutable as much as possible. e.g. if the execution has errored, running the job again creates a new execution, rather than un-executing the previous execution. My perspective may be overly weighted towards the ideas expressed in Better Defaults and Run-time expectations #271. My adherence to this idea is what makes it complicated.

But I get the point that, from the developer/operator perspective, you want a button that is "do it!".

Your leading-edge feedback is super valuable. I was imagining this going a few different ways:

  • It being too fiddly a set of controls (which I think is where you're coming from).
  • Liking the fiddly controls, but being hampered by the state-based filtering making them difficult to use efficiently (e.g. people are reading the state of a job by seeing which controls are available)
  • Finding this inefficient and wanting mass-actions of "do all these jobs!"
  • Getting some left-field stuff like "We have a compliance regime that means we can't have any operator discretion. Please make optional"
  • Not getting any feedback at all

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the next steps I'm thinking:

  • Put documentation into this PR to explain the class/methods and why it's complicated
  • Release this with the fiddly buttons
  • Make a GH Discussion topic for getting freeform "Dashboard Improvement Suggestions" to link to in the release notes, and I'll see if I can pin it.
  • At this point, it's fairly simple to have a "do it!" method that calls the underlying implementations based on state, so we can quickly adjust to that too.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, that's a good plan. Better to have something on which we all can iterate and provide/receive feedback

<% end %>

<% job_discardable = job.status.in? [:scheduled, :retried, :queued] %>
<%= button_to discard_job_path(job.id), method: :put, class: "btn btn-sm #{job_discardable ? 'btn-outline-primary' : 'btn-outline-secondary'}", form_class: "d-inline-block", disabled: !job_discardable, aria: { label: "Discard job" }, title: "Discard job" do %>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this might be handy but also a bit confusing on how it differs from "delete" (BTW are you planning to have a delete here?)
Maybe having a title "Stop job from executing but leave in the database" would be more clear?

@bensheldon bensheldon changed the title Add Reschedule, Discard, Retry buttons to Dashboard Add Reschedule, Discard, Retry Job buttons to Dashboard Oct 21, 2021
@ssendev
Copy link

ssendev commented Oct 21, 2021

Schedule Now should also be an option on cron jobs

@ssendev ssendev mentioned this pull request Oct 21, 2021
3 tasks
@bensheldon bensheldon temporarily deployed to goodjob-retry-jobs-ea8lyp814ni October 22, 2021 15:21 Inactive
@bensheldon
Copy link
Owner Author

@ssendev I'll do those cron dashboard improvements in another PR 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants