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
555 stars 274 forks source link

scheduler-cli is super frustrating #246

Closed sandwormusmc closed 1 year ago

sandwormusmc commented 3 years ago

Some thoughts on scheduler-cli after installing it (had to run sudo, setup.py said to use -d but that option as well as --install-dir didn't work).

  1. --profile-name is not documented in --help, so using it when having multiple account credentials isn't intuitive
  2. I'm not sure if the arguments are positional (e.g. --stack should be first)
  3. If I use =, the command seems to work, sort of... if I use a space (e.g. --stack stackname), I get an error. The help doesn't mention how to pass arguments
  4. If I use "argumentname argumentvalue" the wrong argumentvalue is picked for argumentname. E.g. one of the attempts below I tried "scheduler-cli --profile-name=someprofile -s instance-scheduler describe-periods", and the script attempted to use instance-scheduler as the command
  5. I finally got this to work, after a dozen and a half commands, due to insufficient help and difficult usage guidance from the command
  6. coming from a Linux and AWS CLI background, having this CLI require the action be at the front of the command was a difficult mental block for me, as I'm used to putting "--" arguments that change the behavior in the front of a command, and items like filters after the "action" (e.g. aws --profile=something ec2 describe-instances --query 'Something[].' --filter 'SomethingElse.[]')
  7. The -h (or --help) seem to indicate that the arguments can go in front of the action (e.g. -h and --version). Why can these go in front but others can't?

mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --profile-name someprofile describe-periods usage: scheduler-cli [-h] [--version] {create-period,create-schedule,delete-period,delete-schedule,describe-periods,describe-schedule-usage,describe-schedules,update-period,update-schedule} ... scheduler-cli: error: invalid choice: 'someprofile' (choose from 'create-period', 'create-schedule', 'delete-period', 'delete-schedule', 'describe-periods', 'describe-schedule-usage', 'describe-schedules', 'update-period', 'update-schedule') mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --profile-name=someprofile describe-periods usage: scheduler-cli describe-periods [-h] [--name NAME] [--query QUERY] [--region REGION] --stack STACK [--profile-name PROFILE_NAME] scheduler-cli describe-periods: error: the following arguments are required: --stack/-s  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --profile-name=someprofile -s instance-scheduler describe-periods usage: scheduler-cli [-h] [--version] {create-period,create-schedule,delete-period,delete-schedule,describe-periods,describe-schedule-usage,describe-schedules,update-period,update-schedule} ... scheduler-cli: error: invalid choice: 'instance-scheduler' (choose from 'create-period', 'create-schedule', 'delete-period', 'delete-schedule', 'describe-periods', 'describe-schedule-usage', 'describe-schedules', 'update-period', 'update-schedule')  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --profile-name=someprofile -s=instance-scheduler describe-periods usage: scheduler-cli describe-periods [-h] [--name NAME] [--query QUERY] [--region REGION] --stack STACK [--profile-name PROFILE_NAME] scheduler-cli describe-periods: error: the following arguments are required: --stack/-s  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --profile-name=someprofile --stacks=instance-scheduler describe-periods usage: scheduler-cli describe-periods [-h] [--name NAME] [--query QUERY] [--region REGION] --stack STACK [--profile-name PROFILE_NAME] scheduler-cli describe-periods: error: the following arguments are required: --stack/-s  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --profile-name=someprofile --stacks instance-scheduler describe-periods usage: scheduler-cli [-h] [--version] {create-period,create-schedule,delete-period,delete-schedule,describe-periods,describe-schedule-usage,describe-schedules,update-period,update-schedule} ... scheduler-cli: error: invalid choice: 'instance-scheduler' (choose from 'create-period', 'create-schedule', 'delete-period', 'delete-schedule', 'describe-periods', 'describe-schedule-usage', 'describe-schedules', 'update-period', 'update-schedule')  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --profile-name someprofile --stacks instance-scheduler describe-periods usage: scheduler-cli [-h] [--version] {create-period,create-schedule,delete-period,delete-schedule,describe-periods,describe-schedule-usage,describe-schedules,update-period,update-schedule} ... scheduler-cli: error: invalid choice: 'someprofile' (choose from 'create-period', 'create-schedule', 'delete-period', 'delete-schedule', 'describe-periods', 'describe-schedule-usage', 'describe-schedules', 'update-period', 'update-schedule')  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --profile-name someprofile --stacks instance-scheduler describe-periods usage: scheduler-cli [-h] [--version] {create-period,create-schedule,delete-period,delete-schedule,describe-periods,describe-schedule-usage,describe-schedules,update-period,update-schedule} ... scheduler-cli: error: invalid choice: 'someprofile' (choose from 'create-period', 'create-schedule', 'delete-period', 'delete-schedule', 'describe-periods', 'describe-schedule-usage', 'describe-schedules', 'update-period', 'update-schedule')  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --profile-name=someprofile --stacks instance-scheduler describe-periods usage: scheduler-cli [-h] [--version] {create-period,create-schedule,delete-period,delete-schedule,describe-periods,describe-schedule-usage,describe-schedules,update-period,update-schedule} ... scheduler-cli: error: invalid choice: 'instance-scheduler' (choose from 'create-period', 'create-schedule', 'delete-period', 'delete-schedule', 'describe-periods', 'describe-schedule-usage', 'describe-schedules', 'update-period', 'update-schedule')  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --profile-name=someprofile --stacks=instance-scheduler describe-periods usage: scheduler-cli describe-periods [-h] [--name NAME] [--query QUERY] [--region REGION] --stack STACK [--profile-name PROFILE_NAME] scheduler-cli describe-periods: error: the following arguments are required: --stack/-s  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --profile-name=someprofile --stack=instance-scheduler describe-periods usage: scheduler-cli describe-periods [-h] [--name NAME] [--query QUERY] [--region REGION] --stack STACK [--profile-name PROFILE_NAME] scheduler-cli describe-periods: error: the following arguments are required: --stack/-s  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --profile-name=someprofile -s=instance-scheduler describe-periods usage: scheduler-cli describe-periods [-h] [--name NAME] [--query QUERY] [--region REGION] --stack STACK [--profile-name PROFILE_NAME] scheduler-cli describe-periods: error: the following arguments are required: --stack/-s  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli -s=instance-scheduler --profile-name=someprofile describe-periods usage: scheduler-cli describe-periods [-h] [--name NAME] [--query QUERY] [--region REGION] --stack STACK [--profile-name PROFILE_NAME] scheduler-cli describe-periods: error: the following arguments are required: --stack/-s  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --stack=instance-scheduler --profile-name=someprofile describe-periods usage: scheduler-cli describe-periods [-h] [--name NAME] [--query QUERY] [--region REGION] --stack STACK [--profile-name PROFILE_NAME] scheduler-cli describe-periods: error: the following arguments are required: --stack/-s  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --stack instance-scheduler --profile-name someprofile describe-periods usage: scheduler-cli [-h] [--version] {create-period,create-schedule,delete-period,delete-schedule,describe-periods,describe-schedule-usage,describe-schedules,update-period,update-schedule} ... scheduler-cli: error: invalid choice: 'instance-scheduler' (choose from 'create-period', 'create-schedule', 'delete-period', 'delete-schedule', 'describe-periods', 'describe-schedule-usage', 'describe-schedules', 'update-period', 'update-schedule')  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --stack instance-scheduler --profile-name=someprofile describe-periods usage: scheduler-cli [-h] [--version] {create-period,create-schedule,delete-period,delete-schedule,describe-periods,describe-schedule-usage,describe-schedules,update-period,update-schedule} ... scheduler-cli: error: invalid choice: 'instance-scheduler' (choose from 'create-period', 'create-schedule', 'delete-period', 'delete-schedule', 'describe-periods', 'describe-schedule-usage', 'describe-schedules', 'update-period', 'update-schedule')  mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli --stack=instance-scheduler --profile-name=someprofile describe-periods usage: scheduler-cli describe-periods [-h] [--name NAME] [--query QUERY] [--region REGION] --stack STACK [--profile-name PROFILE_NAME] scheduler-cli describe-periods: error: the following arguments are required: --stack/-s

FINAL WORKING COMMAND (seems arguments are positional, after all)

 mmoldvan  ~  projects  someprofile  keypairs  scheduler-cli describe-periods -s instance-scheduler --profile-name=someprofile { "Periods": [ { "Begintime": "00:00", "Description": "development systems schedule", "Endtime": "12:00", "Weekdays": "mon-fri", "Name": "dev", "Type": "period" }, { "Begintime": "21:00", "Description": "production systems schedule", "Endtime": "22:30", "Weekdays": "mon-fri", "Name": "prod", "Type": "period" } ] }

gockle commented 3 years ago

Hi @sandwormusmc Reviewing your entire comment, looks like you were able to create the periods. Scheduler-cli instructions are provided in the documenation here, let me know if these instructions are not helpful or are missing some details which would have been helpful. We will review the documentation and update it.

sandwormusmc commented 3 years ago

Yes, the help area in the command itself is lacking and it's unclear if the arguments are positional. I think other users of the CLI would find it helpful if the help and documentation were consistent, so rather than opening a browser and searching for the documentation, then the part that is relevant to what they are doing, it could be in the output of -h. Hope I explained that well.

gockle commented 3 years ago

@sandwormusmc Thanks for the feedback, will review the command line help option and update the documentation.

Peter-Darton-i2 commented 1 year ago

I'm not convinced this is completed. I've just started using this command and I've found it to be one of the least friendly CLIs I've encountered in the last few decades. e.g. the command scheduler-cli describe-periods –-stack cicd-pre-prod-ci-instance-scheduler-stack --profile-name=dev gave the response

usage: scheduler-cli describe-periods [-h] [--name NAME] [--query QUERY] [--region REGION] --stack STACK
                                      [--profile-name PROFILE_NAME]
scheduler-cli describe-periods: error: the following arguments are required: --stack/-s

i.e. it's complaining it doesn't have the argument it's got. I'm sure you can understand why this is frustrating to an end user.

After much fiddling about, I eventually found that the key was to ignore the error message it was emitting (because that was a pack of lies) and in fact the command scheduler-cli describe-periods --stack cicd-pre-prod-ci-instance-scheduler-stack --profile=dev finally yielded results.

i.e. when it says --profile-name NAME what it actually means is --profile=NAME. SMH.

Having to resort to trial and error and/or guesswork is super frustrating. I'm not sure which is worse - finding out that you can't configure the instance scheduler properly via CloudFormation (so you can't do configuration-as-code and have to use this cli tool instead), finding out that the cli tool needs a version of python newer that the latest you have available for your OS, finding out that the CLI you have to use is frustratingly unhelpful, or finding out that the bug report about this issue has been closed despite it still being "super frustrating". It's certainly not a user-experience that's consistent with user-expectations for a world-leading cloud provider.

Y'all need to remove data-duplication / copy-paste in your source code so that all these bits of text are built up from the argument(s) that the command really expects. If you do that, you won't be able to tell the user misleading lies because you'll only have correct argument names available, and when someone changes the code to change the arguments, the generated help/errors will change too. (this is a lesson I've had to teach younger coders a gazillion times; copy/paste code may save you a few seconds today but it will cost you hours tomorrow)

CrypticCabub commented 1 year ago

@Peter-Darton-i2 Thanks for the feedback!

We completely hear you on the difficulties with the CLI and the complexity of the source code. Our team is hard at work on resolving many of these issues.

You mentioned that you couldn't configure schedules properly via cloud-formation. Do you have any specific issues that you ran into that were preventing you from creating schedules via CloudFormation? We have a custom-resource that allows schedules to be managed via cloud-formation templates as documented in our implementation guide. You can find several example templates on how to do this here

Thanks again for the feedback. I'm reopening this ticket to help with our internal tracking.

Peter-Darton-i2 commented 1 year ago

I did (eventually) find examples of configuring schedules via cloud-formation, on the page you linked to ... but unfortunately that's got a broken link so we can't see what the actual expected format is:

The following CloudFormation template will create the above schedule using the schedule custom resource.

...but https://docs.aws.amazon.com/solutions/latest/instance-scheduler-on-aws/appendix-resource is "not a functioning page on our site" image

The next issue was that when I tried adding custom resources to my template, deployment then failed because it exceeded a 51200 byte limit. (I'm old enough to remember home computing in the 1980s when 50k was considered to be a lot of memory, but I wasn't expecting to hit that limit four decades later when taking to a multinational cloud service that doesn't/shouldn't have any 8bit systems or limits) ...so I deleted all the "metadata" to bring the file size down and eventually got things working.

...but not until after I found that the scheduler logic doesn't understand that morning follows night (See #456); I wanted an overnight job and it doesn't seem to understand that jobs can start at 9pm and finish 6 hours later at 3am. So I had to set my jobs to start a minute after midnight instead because that way the CLI's belief that 3am can't be later than 9pm doesn't break things.

IMO it would really help if the CFN template included a (commented-out?) example of using CFN to configure it ... although I guess then it'd blow the 50k limit there too :-/

FYI there's also inconsistent links in https://repost.aws/knowledge-center/stop-start-instance-scheduler. One points to a "latest instance-scheduler" which turns out to be version 1.3.3 whereas the other "latest instance-scheduler" is version 1.5.0. Unfortunately I used the first link, not the second, so that cost me a day's rework, at which point the frustration-factor was starting to exceed medically-safe levels...

...and, lastly, my AWS admin tells me that having all the IAM resources bundled up within the same template is frustrating; they're of the opinion that IAM resources should be kept separate from everything else so that the admin can deploy the IAM stuff and then "mere users" (like myself) can "get on with everything else" ... but by that point I'd pretty much lost the will to live and could barely muster a "Meh" in reply.

TL;DR: Lots of frustration and wails of "it shouldn't be this hard!" but got there in the end.

CrypticCabub commented 1 year ago

Thanks for the info! I'll see what I can do to get those documentation links corrected.

For the 50k limit, this is a general quota limitation of CloudFormation when embedding templates directly in the html request body as described in the documentation here. The fix for this would be to spread the schedules you want to create across multiple stacks or to upload and deploy the template from S3 (which has much higher limitations)

rakshb commented 1 year ago

We have added this to the backlog and it will be prioritized for a future release.