Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Cannot Specify Day of the Week in Cron Expression #3

Open
jfix opened this issue Mar 30, 2018 · 7 comments
Open

Cannot Specify Day of the Week in Cron Expression #3

jfix opened this issue Mar 30, 2018 · 7 comments

Comments

@jfix
Copy link

jfix commented Mar 30, 2018

Hello, I've just installed your sls plugin, great find, thanks for the work! I have the following expression:

      - schedule:
          rate: cron(0 7 ? * MON-FRI *)
          timezone: Europe/Paris

When deploying from scratch via sls deploy I see the following lines, the first one being of your plugin:

$ sls deploy
Serverless: Converting local crontabs to UTC crontabs...
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
.....
Serverless: Stack create finished...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (3 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
.....................
Serverless: Operation failed!
 
  Serverless Error ---------------------------------------
 
  An error occurred: NudgerEventsRuleSchedule2 - send-export-feedback-nudge already exists in stack arn:aws:cloudformation:eu-central-1:[obfuscated]:stack/export-nudger-dev/[obfuscated].

Would you have an idea whether there is an attempt to create a schedule twice?

I had a look at the cloudformation-template-update-stack.json file in the unzipped deployment package and I cannot find anything problematic. I can provide this file if required for analysis.

@jfix
Copy link
Author

jfix commented Mar 30, 2018

I commented out the plugin and the corresponding timezone line in the serverless.yml file for the time being and deployment runs without fault ... mmh. ;-)

@dschep
Copy link
Contributor

dschep commented Apr 2, 2018

Hm.. not entirely sure about the specific error, but I have noticed that AWS is very picky about day-of-week & day-of-month. Namely, it seems one of them must be ?. However this conflicts with using this plugin & specifying day of week. This is because to support the split months (March & November in the US), the plugin has to specify a day of month (EG: November 1-3 this year), so you cannot specify a DOW other than ? unfortunately. I'm gonna leave this open since I need to document this limitation. For my own purposes, I accepted that It'll run every day (instead of weekdays, similar to your expression) and the code checks the DOW at start and exits if it is a weekend.

@dschep
Copy link
Contributor

dschep commented Apr 2, 2018

Idea from @dwolfand, make the plugin warn about this limitation in addition to documenting it in the readme.

@jfix
Copy link
Author

jfix commented Apr 3, 2018

OK, I understand the limitation (and yes, would be good to document and warn). I may move the check from the cron expression to my code too. Thanks for pointing that out.

@XinfinityoO
Copy link

i wish this issue could be fixed. also facing similar issue. cant get DST to work properly

@dwolfand dwolfand changed the title Question regarding supported cron expressions Cannot Specify Day of the Week in Cron Expression Jul 2, 2018
@dwolfand
Copy link
Contributor

dwolfand commented Jul 2, 2018

I've updated the title of this issue and added a note about this to the readme as a first step. I am going to leave this open so we can eventually add a build-time error message when this happens.

@simondutertre
Copy link

Would love this to be fixed too.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants