Fleet: How to make a unit depend on any of an instance unit

55 views
Skip to first unread message

Thomas Krahn

unread,
Apr 15, 2015, 3:53:17 AM4/15/15
to coreo...@googlegroups.com
Hi All,

i hope to get the right forum for my question.

I have an application which needs Cassandra up and running before it can start. Therefore i start 3 instances of Cassandra building a Cluster, pushing the IP:PORT config
to Etcd and use this as Environment Variable for my App Container.
Can someone tell me what i need to define inside the unit file of my app so that at least one of the Cassandra Containers must be up and running before the Application
unit can start? I'm looking for something like: 

RequiresAnyOf=cassandra@*.service

Environment Information:
3 node cluster CoreOS 607.

Thanks for your help

Ryan Brodkin

unread,
Apr 21, 2015, 3:04:42 PM4/21/15
to coreo...@googlegroups.com
Since Requires is part of systemd, not fleet, it only knows that is happening on the same machine. The only way to achieve what you're looking for that I know of is to register each Cassandra unit in etcd and then write an ExecStartPre task that runs in a loop checking if there is at least one instance registered in the etcd cassandra tree.

Thomas Krahn

unread,
Apr 22, 2015, 11:36:27 AM4/22/15
to coreo...@googlegroups.com
Hi Ryan

i was thinking about something similar. I will try your idea and let you know. Pretty sure that i'm not the only one having such type of dependency.

Brandon Philips

unread,
Apr 27, 2015, 6:57:49 PM4/27/15
to Thomas Krahn, coreos-user
On Wed, Apr 22, 2015 at 8:36 AM, Thomas Krahn <thomas....@gmail.com> wrote:
> i was thinking about something similar. I will try your idea and let you
> know. Pretty sure that i'm not the only one having such type of dependency.

Providing this sort of guarantee is very difficult in a system like
fleet. For example fleet might say that the process is up but your
application might be unable to reach it due to network partition or
perhaps cassandra is still starting up or cassandra crashes the moment
after you see if it is up. In these cases your application should
implement a retry loop anyways.

Having a dependency chart is great on a single host but in a
distributed system making these sorts of guarantees can be tricky and
provide very little utility.

In any case I hope you got a solution figured out; do you have a blog
or something describing what you are building?

Thanks!

Brandon
Reply all
Reply to author
Forward
0 new messages