On 21 May 2014 21:53, Tudor Rogoz <[email protected]> wrote: > > My service (i will call it application service) "strongly" depends on the > mongodb service [0].This means that the application service cannot be > installed and started without a mongo previously configured for storing the > application data.The problem is that when I'm deploying the service, > automatically the install, config-service and start hooks will be triggered, > but at this point my service cannot know about mongo service because a > relation between the 2 services is not established yet.So, it's impossible > for me to perform the product installation in the install hook.An ugly > workaround would be to perform the installation in the > relation-joined/relation-cahnged hook, but this would be my last option.Even > in this case the service unit will appear as "started" after the start hook > ends, but nothing will actually run there.
Doing the installation in the relation-joined hook seems the best solution to me. It isn't ugly at all to perform bits of installation in the other hooks. For example, a config-changed hook will install new packages if required by changed config settings, or a db-relation-joined hook install the drivers needed to talk to whatever sort of database the user actually related. > I would like for the charm to support the following scenario. > > 1/I deploy the application service > > 2/ the service unit remains in a pending state before the installation hook > will run because the service unit has no access to a mongo service > > 3/ deploy the mongo service which successfully starts > > 4/ add a relation between mongo and application service. The app service will > get the mongo connection information > > 5/ application service installation starts (the install hook is unblocked), > and successfully starts In your proposal, you deploy the service, deploy the mongo service, add a relation, and, once all the hooks have run, the service becomes usable. If you do the actual software installation in the relation-joined hook, you will deploy the service, deploy the mongo service, add a relation, and, once all the hooks have run, the service becomes usable. Exactly the same workflow when you look at it from outside, but without needing to redesign or fight with juju ;) > Another problem that i have is the following: > > For example, one of my application units is getting the connection details > from a specific mongodb unit while running the relation hook, were i can > store the specific information for using it in another hook? Is there > anything implemented in juju for this, or I should write the information in a > file and store it on disk and read from there when is need it? You can persist information to disk as you suggest or store it on one of your relations. In this case though, you don't need to. Your hooks can just inspect the mongo relation. relation-get allows all of your hooks to retrieve data from any of the units in any of your relations (similarly, relation-set allows you to set your unit's data in any of your relations). -- Stuart Bishop <[email protected]> -- Juju mailing list [email protected] Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/juju
