instance-scheduler-on-aws: Stop only schedule (with manual start) not working

Hi, I’m trying to implement a “stop only” schedule for my instances. The goal is to stop all instances at 10pm every day and leave them in stopped state until someone starts them manually (and stop them again automatically at 10pm). I naively created a single period and schedule for that:

scheduler-cli create-period --stack scheduler-stack --name stop-22 --endtime 22:00
scheduler-cli create-schedule --stack scheduler-stack --name stop-22  --periods stop-22

The first time the scheduler runs, it stops the instances at 22h00 as expected. So far, so good. The problem is: if I restart the instance manually, it never gets stopped again by the scheduler. After investigation, this is because the scheduler saves the “stopped” state in DynamoDB state table.

Thus, if I start the instance and remove the key in DynamoDB, then the scheduler stops the instance. But I don’t want to have to explicitely remove the DynamoDB key each time I restart my instance…

Thus the question is: can the current implemention of the scheduler allow doing this: stop only and without touching the DynamoDB ?

I guess that if I ask the scheduler to start the instance just before stopping it, this will work but ideally I would want to avoid to start the instances just for the stop to be working.

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 8
  • Comments: 17 (1 by maintainers)

Most upvoted comments

@madhavvishnubhatta i faced the same problem, schedule with option enforced solves it, you can update this option with true value manually in DynamoDB item, or create schedule with this option like this scheduler-cli create-schedule --stack InstanceScheduler --name QuickSchedule --periods QuickPeriod --enforced you can read about this option in docs in section Schedule definitions.

Unlike #77, I don’t want to use the override-status. This would stop all tagged instances at next interval check. I just want (if possible) to have a schedule that makes sure tagged instances are stopped at a given time. The override-status cannot help for that.

@michaelbertino It’s difficult to say without seeing your config parameters. Below is a detailed example with instructions for partial automation. I recommend reviewing the implementation guide as well. There are some specific details related to stopping instances, which could be the source of the problem.

Example: Start instances every Tuesday at 9 AM and run continuously until it stopped manually.

Create two periods: Period 1 will start the instance on Tuesday at 9 AM: scheduler-cli create-period --stack <stackname> --name tue-start-9am --weekdays tue --begintime 9:00

Period 2 will ensure the instances run continuously throughout the week: scheduler-cli create-period --stack <stackname> --name wed-mon-full-day --weekdays wed-sun,mon

Schedule: scheduler-cli create-schedule --stack <stackname> --name tue-9am --periods tue-start-9am,wed-mon-full-day --timezone UTC

Issue #77 is same as this one.