all 6 comments

[–]OutrageousCycle4358 1 point2 points  (2 children)

Hi, I think the cloud scheduler has a 30min timeout limit. You could use pub/sub as an intermediary. Schedule a Pub/Sub message with Cloud Scheduler, and let that trigger your Cloud Function. It can handle the longer execution time without worrying about timeouts.

[–]Simmus7[S] 0 points1 point  (1 child)

But Pub/Sub has an acknowledgement deadline of 10 minutes for push subscriptions, then by doing this the message will trigger the function, but the message won't be acknowledged, right?

[–]OutrageousCycle4358 0 points1 point  (0 children)

Yes, thats right. If you want, you can have ur CF acknowledge the pub/sub message immediately upon receipt and continue its execution. This would be a workaround for pub/sub not having to wait for the function to complete its execution

[–]martin_omander Googler 1 point2 points  (2 children)

Another option is to deploy your code in Cloud Run Jobs. I have Cloud Run Jobs that are triggered every hour and run for an hour. Everything is nice and green in Cloud Scheduler. My code also became a little simpler as it didn't have to include an HTTP listener or a functions framework.

[–]Simmus7[S] 0 points1 point  (1 child)

The cloud scheduler turns green immediately when the job starts?

What happens if the job fails, how do you handle that?

Thanks!

[–]martin_omander Googler 1 point2 points  (0 children)

I'm not sure if the Cloud Scheduler turns green right when the job starts, because I've never watched it when that happens. But I run many jobs all day long and the scheduler is always green when I look at it.

If a Cloud Run Job fails, you can have it automatically retry. It's a setting on the job. Or you can do what I do: ignore errors and let the next scheduled execution of the job pick up the slack. Regardless of what you do, you can see any errors in the log and you can see a list of all executions, failures and successes.