Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no-schedule tag on Instance Scheduler #322

Open
anuj1366 opened this issue Aug 17, 2022 · 8 comments
Open

no-schedule tag on Instance Scheduler #322

anuj1366 opened this issue Aug 17, 2022 · 8 comments

Comments

@anuj1366
Copy link

Hello,

Is there a way to define a tag or period that does not schedule instance? We want to introduce the tag key as a mandatory value.
Customer want to run their ec2 instances 24/7. But if they have manually stopped the instance for some reason, Instance scheduler doesn't start the instances.

Thank you

@anuj1366
Copy link
Author

anuj1366 commented Aug 19, 2022

It is similar to #259, but one additional requirement like if ec2 stopped manually, it should not be started by Instance Scheduler.
For this I have modified the "Enforced" to false in below configuration

{
         "UseMaintenanceWindow": false,
         "StopNewInstances": false,
         "UseMetrics": false,
         "Hibernate": false,
         "Timezone": "UTC",
         "Enforced": true,
         "RetainRunning": true,
         "Description": "Keep instances running",
         "Periods": [
            "entire-day"
         ],
         "Name": "running",
         "Type": "schedule"
}

and Period as

{
         "Begintime": "00:00",
         "Description": "Running for the entire duration of the week.",
         "Endtime": "23:59",
         "Weekdays": [
            "mon-sun"
         ],
         "Name": "entire-day",
         "Type": "period"
      }

But Somehow the configuration is not working and manually stopped ec2 instances are getting started by instance scheduler.
@gockle Could you please help me in this scenario.

@anuj1366
Copy link
Author

I am seeing one issue here
As per document if I have set Enforced field = false, then Instance scheduler should not start an instance if it was manually stopped during a running period( and we have set running period 24/7). but in our case it is starting the instances.

Enforced field
Schedules contain an enforced field that allows you to prevent an instance from being manually started outside of a running period, or manually stopped during a running period. If this field is set to true and a user manually starts an instance outside of a running period, the solution will stop the instance. If this field is set to true, it also restarts an instance if it was manually stopped during a running period.

@piyushkumar8527
Copy link

piyushkumar8527 commented Aug 30, 2022

Hi @anuj1366 ,

I am also stuck in the same situation where if instance is manually stopped then instance scheduler should not start ec2 next day but it is starting it.

Were you able to find any workaround for this?

@CrypticCabub
Copy link
Member

CrypticCabub commented Aug 28, 2023

This feature is still under consideration, however a workaround that should enable similar behavior in the current version of Instance Scheduler (v1.5.1) would be to create a schedule similar to the following:

schedule:
  name: disabled
  enforced: false
  periods: always_on
 
period:
  name: always_on
  months: 1-12

under this configuration, Instance Scheduler will start an instance when it is first tagged, but after that initial start will not take action against the instance again, even if it is stopped manually.

This works because the default behavior of instance scheduler (when enforced is false) is to only take start/stop actions when a schedule transitions between running/stopped states. If the running period specifies 24-7 uptime, there will be no transitions for actions to occur on except for when an instance is first registered with the solution.

@vic614
Copy link

vic614 commented Aug 28, 2023

Could it be a new "dry-run" key on the schedule that won't actually change the state of an instance.

@CrypticCabub
Copy link
Member

@vic614 something like a dryrun: true tag added directly to an instance? That may be possible, but I can't currently think of a benefit for this approach as opposed to the original request of a value that would function like a no-op schedule when applied using the normal schedule tag.

Very interested in if you have a use-case where a dry-run key would be preferable to other possibilities

@vic614
Copy link

vic614 commented Aug 28, 2023

@vic614 something like a dryrun: true tag added directly to an instance? That may be possible, but I can't currently think of a benefit for this approach as opposed to the original request of a value that would function like a no-op schedule when applied using the normal schedule tag.

Very interested in if you have a use-case where a dry-run key would be preferable to other possibilities

I am thinking to add dryrun as a configurable key in the schedule configuration in the DynamoDB table.

@kymcharlesworth-srg
Copy link

For our Hub / Spoke instance scheduler, we have developed a "reset" functionality (similar to an idle timeout). Manual starts in any of our accounts, trigger an account Lambda that writes the details to a DynamoDB table (Instance ID, Account ID, Manual Action, datetime) in a central account. A worker Lambda in the central account runs every hour, scans the DynamoDB table for any entries where the datetime is aged (we use 24 hours). Aged entries are deleted and the corresponding entry in the instance scheduler state table is also deleted. The effect of this is to bring the EC2 back under the control of instance scheduler.

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

No branches or pull requests

6 participants