aws-solutions / instance-scheduler-on-aws

A cross-account and cross-region solution that allows customers to automatically start and stop EC2 and RDS Instances
https://aws.amazon.com/solutions/implementations/instance-scheduler-on-aws/
Apache License 2.0
542 stars 264 forks source link

override_status - replacement #535

Closed whoDoneItAgain closed 4 months ago

whoDoneItAgain commented 4 months ago

Describe the bug

not a bug per se. With the deprecation of override_status, what is the recommended replacement?

Our use case for override_status:

When an EC2 that is typically off is needed, the dev team manually turns on the server. If the server is not turned off by the dev team, the override_status=stopped will turn the server off according to the schedule but not turn it back on. Effectively its used to turn servers off at a set time and keep them off until they are manually started again.

To Reproduce

n/a

Expected behavior

n/a

Please complete the following information about the solution:

To get the version of the solution, you can look at the description of the created CloudFormation stack. For example, "(SO0030) instance-scheduler-on-aws v1.5.1". You can also find the version from releases

Screenshots If applicable, add screenshots to help explain your problem (please DO NOT include sensitive information).

Additional context Add any other context about the problem here.

CrypticCabub commented 4 months ago

Does that schedule actually work as you describe? The reason we deprecated the override_status flag is because though this was the described behavior, our testing indicated that it didn't actually work this way.

Instead what we found it would do is cause the schedule to always set desired_state = stopped, which would have the knock-on effect of preventing the scheduler from ever stopping the instance again after the first stop action was taken. (Instance Scheduler looks for state transitions in the schedule to take action, but the override flag prevented there from ever being a transition)

the schedule you describe sounds to me like a 1-sided stop schedule. If you create a schedule with a single period containing an endtime of say 20:00, and no begintime or other periods, Instance Scheduler will issue a stop action to all tagged instances at 8pm every day but will otherwise not start the instances (note -- this type of schedule needs to stop at least 1 scheduling interval before midnight to work correctly. As such, I typically recommend setting the stop to 11PM for reliability)

whoDoneItAgain commented 4 months ago

hmmm, i'll have to reach back out to the team for clarification. regardless, i'll test the 1-sided stop schedule you mentioned. sounds like that's what i should be using for this use case.

whoDoneItAgain commented 4 months ago

we converted to the method described and is working as it should. we are not going to bother investigating the override_status behavior since its deprecated.

CrypticCabub commented 4 months ago

sounds good, glad the schedule is working for you!