cloudtasker icon indicating copy to clipboard operation
cloudtasker copied to clipboard

Cloudtasker::Cron::Schedule crash application load when schedule tasks due date is 720 hours in the future

Open wagnerpereira opened this issue 3 years ago • 2 comments

We need that cloudtasker don't brake in this casa.

CloudTasker::Cron load breaking application starts when worker tasks ETA is more then 720h in the future.

2021-10-01T15:26:04.698271Z/usr/local/bundle/gems/google-gax-1.8.2/lib/google/gax/api_callable.rb:264:in rescue in block in create_api_call': GaxError RPC failed, caused by 3:The Task.scheduleTime, 2021-11-01T03:00:00-07:00, is too far in the future. Schedule time must be no more than 720h in the future.. debug_error_string:{"created":"@1633101964.695316382","description":"Error received from peer ipv4:142.250.148.95:443","file":"src/core/lib/surface/call.cc","file_line":1069,"grpc_message":"The Task.scheduleTime, 2021-11-01T03:00:00-07:00, is too far in the future. Schedule time must be no more than 720h in the future.","grpc_status":3} (Google::Gax::InvalidArgumentError) ` Screen Shot 2021-10-01 at 12 44 22

wagnerpereira avatar Oct 01 '21 15:10 wagnerpereira

@wagnerpereira Thanks for raising this issue. GCP Cloud Tasks does not allow tasks to be scheduled more than 30 days in the future unfortunately. This limits Cron schedules to cron tasks every 30 days at most...

I believe the best approach here would be to propose another Cloudtasker cron extension leveraging GCP Cloud Scheduler (on top of the native Cloud Tasks implementation). See https://github.com/keypup-io/cloudtasker/issues/20

In the meantime you can work around this limitation by configuring your job to run every day then add the following logic inside your job:

class MyMonthlyWorker
  include Cloudtasker::Worker

  def perform(*args)
    # Abort unless we're the first of the month
    return unless Time.current.day == 1

    # ... job logic
  end
end

It's not pretty but it's the best I can propose just now. I'll check if I can implement a workaround on the current task-based implementation. If I can't come up with something then I will prioritize the implementation of scheduler-based cron jobs as this issue is clearly a major one.

I have added a limitations section in the cron documentation to reflect that issue.

alachaum avatar Oct 04 '21 09:10 alachaum

Thanks @alachaum , it was exactly what we did to bypass until we find an elegant way to solve this google tasks limitation using cloud scheduler.

I would offer help to update the documentation but I saw you already did. Thanks again.

🙌

wagnerpereira avatar Oct 04 '21 11:10 wagnerpereira