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

maestro restart doesn't handle service dependencies correctly #186

Open
petrkalina opened this issue Dec 13, 2016 · 11 comments
Open

maestro restart doesn't handle service dependencies correctly #186

petrkalina opened this issue Dec 13, 2016 · 11 comments
Assignees

Comments

@petrkalina
Copy link

containers are restarted in the order in which they are stopped

the correct behaviour is to wait starting the dependent services after their prerequsite services have been restarted

the easiest way how to achieve the behaviour is to decompose the execution internally performing maestro stop and maestro start sequentially

@mpetazzoni
Copy link
Contributor

Might be a silly question but are you using the -d flag?

Can you give more details about your services, containers and their dependencies, and the order you're seeing when doing maestro restart?

Thanks

@mpetazzoni mpetazzoni self-assigned this Dec 13, 2016
@petrkalina
Copy link
Author

petrkalina commented Dec 14, 2016 via email

@zsuzhengdu
Copy link
Contributor

I could also reproduce the same issue faced by @petrkalina

Is restating B first (stop B, start B), then restarting A (stop A, start A), an acceptable solution? or stop all basing on dependencies, and then start all stopped service basing on dependencies ('Stop' play and then 'Start' play)?

@mpetazzoni
Copy link
Contributor

mpetazzoni commented Apr 11, 2017

The current behavior is definitely not ideal, and most likely not what one would expect when restarting multiple services with some dependencies.

First, the important thing to understand is that the -d flag does not control in what order things are done, only what containers will be affected. By specifying -d, you explicitly ask Maestro to consider the dependencies (or the dependents) of the things you specified on the command line. In the case of stop and restart, specifying -d will make Maestro include all downstream dependencies. The logic behind this being that if B depends on A, maestro stop -d A should also consider B and stop it before A.

With regard to the order of a restart, the problem today is that Maestro does a per-container restart instead of a ascending stop + descending start of all identified containers. So if Maestro has identified the orchestration play will involves containers A1, A2, B1 and B2, from services A and B (with B depending on A), today the order will be:

  1. stop B1, start B1
  2. stop B2, start B2
  3. stop A1, start A1
  4. stop A2, start A2

Instead of:

  1. stop B1
  2. stop B2
  3. stop A1
  4. stop A2
  5. start A1
  6. start A2
  7. start B1
  8. start B2

It gets a little tricky to keep the --only-if-changed functionality, but I'll try to work on a fix.

@mpetazzoni
Copy link
Contributor

So, giving more thoughts to this, the main issue with the proposal above is that it's not a graceful restart at all. At step 4, the whole stack is down. With the current behavior of restarting one container at a time, the stack is always operational.

Thoughts?

@zsuzhengdu
Copy link
Contributor

zsuzhengdu commented Apr 11, 2017 via email

@mpetazzoni
Copy link
Contributor

It's hard to say what is correct here. I feel like their could be different answers based on what the nature of the dependency is.

@zsuzhengdu
Copy link
Contributor

zsuzhengdu commented Apr 12, 2017

Given a clear and universal acceptable definition to dependency is the key to make Play of restart right.

My understanding, in my use case, is if service A depends on service B; in another word, service A requires service B, service B is lower or closer to the root in the dependency tree. When restarting, service B should be restarted before its dependent, which is service A.

E.g. Kafka requires zookeeper. When restarting both with '-d', we better 're-start' zookeeper before kafka. Either stop kafka, stop zookeeper (stop play with '-d'), start zookeeper, start kafka (start play with '-d'); or stop zookeeper, start zookeeper (restart zookeeper); stop kafka, start kafka (restart kafka).

Or we could mimic docker-compose with links or depends_on.

@petrkalina
Copy link
Author

petrkalina commented Apr 12, 2017 via email

@petrkalina
Copy link
Author

petrkalina commented Apr 12, 2017 via email

@zsuzhengdu
Copy link
Contributor

zsuzhengdu commented Apr 19, 2017

Another potential fix demo @ https://www.youtube.com/watch?v=c0DzG4m5vSY

Meets your requirement @petrkalina ??

Stop wildfly, stop ldap, stop ldap-db, start ldap-db, start ldap and start wildfly.

@mpetazzoni May I have your opinion? Shall we restart service with dependencies by adopting PR or the captured demo, or provide an option for user basing on use case?

Noticed that the links and depends_on option in docker-compose, do randomly restart, not considering/following the service 'dependencies'.

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

3 participants