0
votes

I have a website with code that I want to make run periodically (sending e-mails).

My web.xml is as follows:

<servlet-mapping>
    <servlet-name>sendEmailsController</servlet-name>
    <url-pattern>/cron/sendEmails</url-pattern>
</servlet-mapping>
<servlet>
    <servlet-name>sendEmailsController</servlet-name>
    <servlet-class>sendEmailsController</servlet-class>
</servlet>

I am trying to schedule the code to run through Google Cloud Scheduler, but when I'm editing the 'Service Account' field to insert my [email protected], I get a black pop-up saying: Updating job "myJob" failed: Unknown error

I've tried saving the job with the Service Account field left blank and it shows Success, but it doesn't run my code (does not send e-mails), neither prints the logs I left in the code. Also, I've tried adding the Cloud Scheduler Admin, Cloud Scheduler Job Runner and Cloud Scheduler Service Agent roles to the service account in case it was a problem with the permissions, but it didn't work either.

For Frequency, i'm using * * * * * (every minute), target is HTTP, HTTP Method is GET, and URL is https://myDomain/cron/sendEmails

1
from the service account, you mentioned above is a Cloud Scheduler service account. Since you will use this service account to run the Schedule service and started the 'Send Email ' service. This service account should grant the necessary role that can call the Send Email method too. Can you pointed out where the Send Email method be deployed?Shawn Di Wu

1 Answers

2
votes

You might probably used account from "IAM & Admin" in "IAM" tab, but for some it might be working, for some other not. Hard to find, on my testing account I have more than 20 and only 5 where working.

This is error is not showing up when you use account listed in is "Service Accounts" tab (which was just a few instead of many in "IAM&Admin/ IAM").

I have tested it quickly. Trying to add any service account from IAM tab, that is not listed in Service Accounts was giving error.

Than I have added new account like:

scheduler@<my-test-project>.iam.gserviceaccount.com.

Without any permissions I was able to use it in Cloud Scheduler without the error. I suggest to do it the same way.