Skip to content

[FR] add wait timer to batch mode #1038

Closed

Description

@halberom

Feature Request.

There are times when an application can restart almost immediately, but doesn't necessarily start responding for x seconds. In these cases, I'd like the ability to add a wait timer in the batch call.

e.g.
salt -G 'role:webserver' -b 2 --batch-wait 30 cmd.run 'service tomcat restart'

Where it would iterate through all servers matching the grain, performing 2 at a time, with a 30 second wait between each.

Many thanks

Activity

  1. thatch45 commented on Apr 3, 2012

    @thatch45
    Contributor

    I will put this on post 1.0.0, I think it is a good idea

  2. halberom commented on Aug 6, 2012

    @halberom
    Author

    I know this has been marked for post 1.0, is there any chance of squeezing it in sooner? If not, we'll look at creating a quick wrapper - I wouldn't have a clue where to even start for coding it into the main app.

  3. thatch45 commented on Aug 6, 2012

    @thatch45
    Contributor

    I am happy to bump it up, the problem I have right now is that I am beating down bugs and have a lot of back logged features. The batch system also does not work in large groups, but makes sure that n number of minions are working at a time.
    But the place to put the code would be here:
    https://github.com/saltstack/salt/blob/develop/salt/cli/batch.py

  4. halberom commented on Aug 7, 2012

    @halberom
    Author

    Thanks for your response thatch45, fully understand your time commitments, we'll have a look at either adding to batch.py or writing a quick wrapper. Our problem is that for things like tomcat, the init script returns almost immediately, however the daemon can take up to 30sec to fully start before it'll start responding to requests - cases like that, we need an extra buffer to ensure there's no drops in service.

  5. thatch45 commented on Aug 8, 2012

    @thatch45
    Contributor

    That in and of itself is something to consider, if we should have some provision to wait for daemons to "really" start up. This is something that a lot of daemons do.

  6. SEJeff commented on Nov 1, 2012

    @SEJeff
    Contributor

    I believe this is also how some of the new init replacements like systemd and upstart function too. They will return as soon as they have spawned the various bits that then spawn the services and return immediately. It might be worth bumping up for that alone. Just my 2 cents.

  7. ghost assigned on Nov 8, 2012
  8. wichert commented on Apr 15, 2013

    @wichert
    Contributor

    I have applications that have a similar problem: after a restart they may take a few minutes to preload caches. Since that preload (and other tasks) happen in an uWSGI worker process salt will not wait for that to finish. A delay would be a simple system to use here, but perhaps this is better handled witg a verify-state method that can check if 1) a restart is still running, or 2) it failed in some way, for example a daemon started but aborted after backgrounding.

  9. thatch45 commented on Apr 22, 2013

    @thatch45
    Contributor

    I have been doing more work in this area recently and will try to revisit this for 0.16.0

  10. nikosg commented on Aug 16, 2013

    @nikosg

    I was wondering if there is any update-progress on the wait timer for batch.
    Thank you.

  11. minaguib commented on Aug 20, 2013

    @minaguib

    +1

    For now I'm coping with adding an explicit sleep to the command to run. cmd.run "restart foo; sleep 30" - this naturally works for parts like cmd.run but not state.sls

  12. basepi commented on Aug 21, 2013

    @basepi
    Contributor

    Issues get forgotten from time to time. I'll put this on the current milestone so we see it more often.

  13. nikosg commented on Aug 27, 2013

    @nikosg

    Thank you for your reply. Really much appreciated.
    Will keep a close eye on this thread.

  14. modified the milestones: Helium, Hydrogen Release on Feb 4, 2014
  15. 19 remaining items

  16. basepi commented on Nov 11, 2015

    @basepi
    Contributor

    No news, but thanks for the bump, I've put some eyes on it.

  17. modified the milestones: B 7, Approved on Nov 25, 2015
  18. matthayes commented on Dec 11, 2015

    @matthayes

    Related to this, I think it would be useful if there is was a way to ping a web server before moving on. Sometimes one may implement a /ping path that returns 200 if the server is up and ready to serve requests. This could be more reliable and quicker than a fixed sleep. For example, what if there is a bug? It'd be nice to catch it immediately before rolling it out to all instances. Maybe the service.running state could have a test option of some sort?

  19. lpgauth commented on Dec 11, 2015

    @lpgauth
  20. basepi commented on Dec 11, 2015

    @basepi
    Contributor

    @matthayes I'm not convinced that this belongs in batch. I think it's doable without batch mode, and it's hard to generalize inside of batch mode in a useful way.

    1. You could use state.orchestrate, target a subset of the minions to roll out changes, and then have a separate piece of the orchestration, probably using a custom module, to check if the changes were successful
    2. You could also just use a normal state run. Have the minion check for its own web service. Again, if you need custom checks or a loop with a custom timeout to check the service, a custom module is probably the way to go here.

    Here are some resources on custom modules:

    https://docs.saltstack.com/en/latest/ref/modules/
    https://youtu.be/7CxJGglQhxQ

    Does that make sense?

    Also, the original issue is now implemented, so I'm going to close this issue.

  21. added
    fixed-pls-verify
    on Dec 11, 2015
  22. matthayes commented on Dec 11, 2015

    @matthayes

    Thanks @basepi , that makes sense. For point 2, how can the minion check its own web service in a state run? Would there need to be a state that checks the web service is responding when it is evaluated? Does such a state exist that can be used? If I were to write a custom module I would need to use something like state.orchestrate as in point 1 right?

  23. matthayes commented on Dec 11, 2015

    @matthayes

    I just noticed you can call modules from states. Is this how you'd suggest doing it if I pursued point 2? It seems like I could write a custom module that makes an HTTP call and fails if the response is not 200. Then it seems I could do a normal state run with a wait between each node and it would work great.

  24. basepi commented on Dec 11, 2015

    @basepi
    Contributor

    You could also easily write a custom state module. It's not covered in as much detail in that youtube video, but it's just as easy. But yes, you have the idea spot on.

  25. shinshenjs commented on Mar 17, 2016

    @shinshenjs

    Saw this issue when searching for the feature. As it was not released yet I figured out an easy hack for this case. simply run a sleep afterwards.

    salt -G 'app:whatever' -b 1 cmd.run "echo test; sleep 300

    For highstate, I just put a cmd.run state at the end of top file with the same idea.

    Leave it here as it could be helpful before this feature is released.

  26. rothgar commented on Mar 17, 2016

    @rothgar

    That's a decent hack if you want to arbitrarily wait (assuming you don't know how long echo test will take to run). My use case was to run a command everywhere twice per hour. It would be nice to have salt figure out the batch size to make sure the command is triggered (doesn't have to finish) the correct amount of times in a given timespan.

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

Metadata

Metadata

Labels

CoreFeatureZRELEASED - Boronfixed-pls-verify

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions