Search code examples
google-app-enginegoogle-cloud-platformcrongoogle-cloud-scheduler

Cloud Scheduler showing Uknown Error when adding Service Account


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


Solution

  • 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.