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

Error When an Invalid Recurring Task is Configured #427

Merged
merged 3 commits into from
Dec 10, 2024

Conversation

jherdman
Copy link
Contributor

I took a first crack at resolving #414. I think it's a little bit of a blunt solution.

Resolves #414

@rosa
Copy link
Member

rosa commented Dec 2, 2024

Thanks a lot @jherdman! I was thinking that perhaps this should be part of a more generic configuration validation that runs and raises before starting the supervisor 🤔

@jherdman
Copy link
Contributor Author

jherdman commented Dec 2, 2024

Perhaps we need both things? Since the recurring jobs are just DB backed, and have validations, we probably need to report on those validation errors should they occur.

@rosa
Copy link
Member

rosa commented Dec 2, 2024

we probably need to report on those validation errors should they occur.

Right, I mean doing this as part of that configuration validation that runs before the supervisor starts, instead of waiting until we try to schedule them.

@jherdman
Copy link
Contributor Author

jherdman commented Dec 2, 2024

I can take a crack at your suggestion unless you have something very specific in mind.

@rosa
Copy link
Member

rosa commented Dec 2, 2024

@jherdman thank you! I was just thinking of having the current check here expanded to also check if the configuration is valid (configuration.valid?), and if not, abort printing the existing errors. I think not having any configured processes could be part of the configuration.valid? check.

@jherdman jherdman force-pushed the error-when-invalid-recurring-task branch from 2657a3c to 20169c7 Compare December 3, 2024 02:44
Copy link
Contributor Author

@jherdman jherdman left a comment

Choose a reason for hiding this comment

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

@rosa take two! I think this is more in line with what you noted above.

@@ -36,6 +36,14 @@ def configured_processes
end
end

def valid?
skip_recurring_tasks? || recurring_tasks.none? || recurring_tasks.all?(&:valid?)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel like this is probably not exhaustive enough, but I'm unsure of other cases to expand upon. This is probably sufficient for the scope of this PR though.

Copy link
Member

Choose a reason for hiding this comment

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

Could we include perhaps the case of no configured processes? So we could unify that call in the Supervisor, instead of having two separate checks?

Besides that, I think you can skip recurring_tasks.none? because if recurring_tasks is empty, recurring_tasks.all?(&:valid?) will return true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ugh... seems so obvious after you pointed it out 😅

I hope you don't mind, but I've kept the two distinct error messages. It feels like the verbose invalid task error message would be helpful.

test/unit/supervisor_test.rb Show resolved Hide resolved
Asserting on the abort message ensures we're not aborting for some other
reason.
@jherdman jherdman force-pushed the error-when-invalid-recurring-task branch 2 times, most recently from e25ebd8 to a743f27 Compare December 6, 2024 12:01
@jherdman jherdman force-pushed the error-when-invalid-recurring-task branch from a743f27 to b0534f0 Compare December 6, 2024 12:04
Copy link
Member

@rosa rosa left a comment

Choose a reason for hiding this comment

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

Wonderful! Thank you so much, @jherdman! 🙏 🙇‍♀️

@rosa rosa merged commit e3f422c into rails:main Dec 10, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invalid Recurring Jobs: No Feedback
2 participants