Skip to content

RFC 5545 recur schedule support#931

Closed
grepsr wants to merge 506 commits intoHubSpot:masterfrom
grepsr:rfc5545_recur_schedule
Closed

RFC 5545 recur schedule support#931
grepsr wants to merge 506 commits intoHubSpot:masterfrom
grepsr:rfc5545_recur_schedule

Conversation

@grepsr
Copy link
Copy Markdown

@grepsr grepsr commented Mar 2, 2016

To get over cron/quartzCron limitations for my own projects, I tried to add RFC5545 support.
https://tools.ietf.org/html/rfc5545#section-3.3.10

I've been running this on my testing server with great success.

The scheduling is much more easy to configure and dynamic with RFC5545 (things like start date, end date, odd schedules like every 37 hours or every 93 days works with this)

Have not had the time to work on the UI to make the new ScheduleType appear; but once this is reviewed, adding that would be trivial.

import com.hubspot.singularity.WebExceptions;
import com.hubspot.singularity.config.SingularityConfiguration;
import com.hubspot.singularity.data.history.DeployHistoryHelper;
import org.dmfs.rfc5545.recur.RecurrenceRule;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

can you sort these imports? if you're using Eclipse or IntelliJ, we have a formatter config here: https://github.com/HubSpot/Singularity/blob/master/eclipse/singularity_eclipse_formatter.xml

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Code re-formatted.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Wow that re-formatted everything, perhaps I should just re-format the sections I added?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeah, just your sections sounds good. Thanks!

@grepsr
Copy link
Copy Markdown
Author

grepsr commented Mar 3, 2016

Not sure why the travis check keeps failing, it compiles file on my machine. Any idea how to go from here?

@tpetr
Copy link
Copy Markdown
Contributor

tpetr commented Mar 3, 2016

@grepsr the Travis output makes it look like there's a findbugs issue. How are you building it locally? Try running mvn clean verify to compile, test, package, and analyzes the code for possible bugs or style issues.

@grepsr
Copy link
Copy Markdown
Author

grepsr commented Mar 3, 2016

Thanks, I'm using mvn clean package

I'll try that.

LOG.warn(msg);
exceptionNotifier.notify(msg, ImmutableMap.of("taskId", taskId.toString()));
return Optional.absent();
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

could we refactor all this RFC5545 logic (lines 128-166) into its own class? it'd be nice to expose an interface similar to CronExpression.getNextValidTimeAfter() below

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I actually thought about doing that too. I'll take care of it and commit

I'm not a Java guy, can you tell me where I should place the new RFC5545Schedule.java file into the folder structure? Should I put it inside com.hubspot.singularity folder inside the SingularityService module?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No worries -- I'd suggest putting it under com.hubspot.singularity.helpers

@grepsr
Copy link
Copy Markdown
Author

grepsr commented Mar 4, 2016

I just refactored the code and moved everything into a helper class, much cleaner now.

@grepsr
Copy link
Copy Markdown
Author

grepsr commented Mar 5, 2016

This finally worked on JDK8 on Travis, but still fails on JDK7 - not sure I understand why, any thoughts? Thanks

@grepsr
Copy link
Copy Markdown
Author

grepsr commented Mar 9, 2016

Just wanted to check back on this and see if I could get any help getting this to work on JDK7?
JDK8 compiles great - really want to help move this feature into production branch.

@grepsr
Copy link
Copy Markdown
Author

grepsr commented Mar 10, 2016

I just re-comitted the code without any change and it builds in both JDK7 and JDK8! I guess it was a Travis issue.

Where do we go from here?

@tpetr
Copy link
Copy Markdown
Contributor

tpetr commented Mar 10, 2016

Awesome! Taking another look at this today. We'll need to add some unit tests since this change affects the operation of the scheduler.

@grepsr
Copy link
Copy Markdown
Author

grepsr commented Mar 11, 2016

Great, please let me know if you need any help.

Also, I'm using this on production for the past 10 days and this is working great! I have about 200+ tasks scheduled and it schedules everything right on time.

@ssalinas ssalinas modified the milestone: 0.4.12 Mar 18, 2016
@grepsr
Copy link
Copy Markdown
Author

grepsr commented Mar 24, 2016

A note about this feature. Lately I've realised that the tasks are usually overdue by 5 minutes before running. I have a feeling its because of some default setting that triggers the check

Is there some global setting that can help here? Perhaps checkNewTasksEverySeconds?

@ssalinas
Copy link
Copy Markdown
Contributor

So there are two things to check here (second one is most likely the issue since you mentioned things are overdue):

  • Are the tasks being put in the pending queue with the correct time? You can check the tasks page in the ui and filter for scheduled. These should have the time they were expected to run at. If those times are not what you expect, that would indicate an error in the scheduler (i.e. choosing the wrong time based on the changes in this PR).
  • Are you getting offers with enough resources? While the tasks are put in the pending queue with an expected time to run, Singularity can only start those tasks that are due to run when an offer comes in that has the appropriate resources. So, if you have a scheduled job that is due, but you aren't getting offers, or you are getting offers that don't have enough resources, that would cause the tasks to be overdue until an appropriate offer came in. If this is the case, you may need more resources in your cluster, or another running framework in the cluster may be hogging all the offers
  • Only other thing I can think of is if you have maxTasksPerOffer set too low. This will limit the number of tasks Singularity can schedule from a single offer, meaning you then have to wait for more offers to schedule the next tasks. By default, there is no limit, so if you don't have it set in your config this isn't the issue

Hope that helps

@ssalinas ssalinas modified the milestones: 0.5.0, 0.6.0 Apr 5, 2016
@grepsr
Copy link
Copy Markdown
Author

grepsr commented May 20, 2016

Hi there, we've fixed the merge conflicts for this, and pushed to latest branch.

@ssalinas
Copy link
Copy Markdown
Contributor

ssalinas commented Jun 8, 2016

closing in favor of #1071

@ssalinas ssalinas closed this Jun 8, 2016
@ssalinas ssalinas modified the milestone: 0.8.0 Jun 14, 2016
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.

7 participants