awslabs / fargatecli

CLI for AWS Fargate
Apache License 2.0
893 stars 114 forks source link

Proposal - wait command - wait for a task to finish #65

Closed michael-paddle closed 5 years ago

michael-paddle commented 5 years ago

I would like to see the ability to run a one shot task and then ensure that it should finish. This PR is a proof of concept for a wait command that waits for a task to have completed.

This is a PR with some code that I wrote that enables me to do that. Since it's my first attempt at programming in go you might want to treat it more as a proposal than a PR, however if you like the design but have comments then I'm more than willing to work to clean up the code. Alternatively, if there's a way to do this that I missed please do tell.

There are two situations I think would be good to have

  # run task and wait for it complete - not yet supported
  fargate task run -w uploadtask
  # now run something that depends on the task completing.
  s3_verify_upload 

and

  #run task then do something else - this is what I have provided
  fargate task run uploadtask
  ec2_fix_permissions_to_allow_web_access
  #check that the task has actually finished
  fargate  task wait 
  s3_verify_upload 

Bugs

osterman commented 5 years ago

I think this is a great proposal, but suggest altering the implementation. Instead, it would be nice if there were a --wait flag for each command that would make it synchronous. This is how the helm tool works for kubernetes. For example, what drew me to this page was I wanted to do fargate certificate validate $DOMAIN --wait, so that when that completes I create the service.

michael-paddle commented 5 years ago

@osterman I totally agree that would be better. For now the current way of doing it suits what I'm working on but if I get a message from @jpignata that he would accept the patches I will code the feature as you described.

PaulMaddox commented 5 years ago

I'm closing this as it's been open and stale for a long time. Sync waits do seem like a useful feature, however I do not think that this is the optimal implementation.