My service recipe: DB Server <-> App Server <-> Web Reverse Proxy.
My relation requirements are:
- 1 unit of DB Server related 1 (specific) unit of App Server
- 1 unit of Web Reverse Proxy related to all App Servers
Given below is a sequence of Juju commands, that will happen in my case
Expected Steps are (correct me if I am wrong):
Phase - Install
- Deploy Db
- Deploy App Server
- Deploy Web Reverse Proxy
- Add relation App Server to Db
- Add relation Web Reverse Proxy to App Server
Phase - Scaling
- Add unit Db
- Add unit App Server (Problem step): Oh no! I don't need the automatic behavior based on Provides/Required setting in charm metadata. I want to specify the App server to Db relation at a unit level here.
Ideally, I want the relation-xxx hooks to fire only on the new unit of Db. May be an add-unit parameter passing mechanism similar to one proposed for deploy ?
My thoughts for a work around given the current features are as following:
- One way is to conditional execute in callbacks. Check if already related to a remote unit and ignore the incoming relation-added/Changed call back. Would be messy. When restarting services may be buggy cause of sequence of start for each db app unit pair has to be carefully managed or wrong app service will talk to wrong db service. I am already using Juju as a back-end service with a python script managing the juju cli.
Another way is that I have a specific code which is common to the app server / db pair. Much like the set command for post deploy phase, can I use it to set values to specific service instances post add-unit?
Another option is a subordinate service with a container scope - but I want Db as a separate machine instance not on the app server machine instance..
As for the web proxy, I expect the hooks to be fired, so proxy can add the new app server as a back-end. Current Juju behavior is ideal.
I am looking forwards to a optimal way to go about this. Thanks in advance..