/srv/irclogs.ubuntu.com/2014/03/01/#juju.txt

cory_fuIf I'm making a charm for an (http) application that has a setup step that needs to run once mongo is available but before it can be started, I assume that relation-mongodb-relation-joined is the appropriate place to do that?00:12
arosalescory_fu: I think that would be appropriate. You would need to ensure it is idempotent though00:15
arosalesie,00:16
cory_fuNot sure if I missed your reply after "ie,"00:22
=== arosales_ is now known as arosales
arosalescory_fu, python-django may have some good example of a relation-joined for mongo00:24
hazmatcory_fu, yes.. that's the place... joined is a bit early if you depend on getting any settings from mongodb00:32
cory_fuHow do you mean?00:33
arosalescory_fu, I was going to ref in python-django but I realize that is a "sym-link" charm00:39
arosales"sym-link" == all the hook files point to a central file00:39
cory_fuYeah, I figured that out.  mongodb_relation_joined_changed was still helpful.  :-)00:40
* arosales was just looking to see if https://bazaar.launchpad.net/~charmers/charms/precise/python-django/trunk/view/head:/hooks/hooks.py#L65900:42
arosaleswas helpful00:42
arosalescory_fu, I think what hazmat is saying you can expect mongoDB on relation-joined _start_ getting the DB hooked up. So if you need an action to happen before mongo is set up then this would be a good place00:43
arosalesAs long as you don't need mongo up and running at that time.00:43
arosalescory_fu, helpful?00:43
cory_fuBut it would have the host and port settings, at least, right?00:43
cory_fuWhat hook should I use if I need mongo up and running?00:43
arosalespending how much it needs to be up and running you may be able to insert toward the end of relation-joined, if not you could leverage relation-changed00:46
* arosales looking at node.js as an example00:47
cory_fuAlso, Allura needs four mongo databases: task, activity, pyforge, and project-data.  Is it ok to use those hard-coded names?  The databases will need to be shared across allura instances, so I assume hard-coding them is ok, though they could conflict with other charms (especially task)00:47
arosaleshttp://bazaar.launchpad.net/~charmers/charms/precise/node-app/trunk/view/head:/hooks/mongodb-relation-changed00:47
arosalesya, I don't see immediately why a user would need to name those DBs differently00:48
cory_fuSo, if relation-get private-address works, then mongo should be up and ready?00:50
cory_fuAlso, I notice that python-django uses host while the node-app one uses private-address; but I don't see either of those in the mongodb hook's relation_set00:52
arosalescory_fu, should be00:55
arosalesre mongo being up00:55
* arosales looking at those code bases00:55
cory_fuI was looking at this: http://bazaar.launchpad.net/~charmers/charms/precise/mongodb/trunk/view/head:/hooks/hooks.py#L105700:57
arosalescory_fu, I am looking around http://bazaar.launchpad.net/~charmers/charms/precise/mongodb/trunk/view/head:/hooks/hooks.py#L136  and django and node both seem to be getting the host01:05
cory_fuHrm.  If my charm depends on mongodb, can it be assumed that the mongo command-line client is available?  I'm guessing not, and I'd be better off using python01:12
cory_fuAlternatively, is it reasonable to create some sort of flag in the installed location to track whether a needed-once setup step has been done?01:17
arosalescory_fu, you can specify in the install hook which packages you want to ensure are specifically available01:18
cory_fuAh, yeah, of course01:19
arosalescory_fu, sorry I didn't parse your last question01:19
cory_fu:-)  Instead of connecting to mongo and checking for the database's existence to know if the setup-app step has been run, I could do something like touch /var/local/allura/setup-done, but that seems hinky01:21
arosalescory_fu, fyi python-django uses https://bazaar.launchpad.net/~charmers/charms/precise/python-django/trunk/view/head:/hooks/hooks.py#L660 for the  install01:28
arosalescory_fu, you could call the mongodb-relation-changed if you want to take some action on the mongodb post a certain setup call01:30
arosalescory_fu, hooks should be able to be called more than once.  this is what the node-app does01:31
arosalescory_fu, I am not sure if that information is helpful though01:31
arosaleshttps://bazaar.launchpad.net/~charmers/charms/precise/node-app/trunk/view/head:/hooks/mongodb-relation-changed#L801:32
hazmatcory_fu, sorry went afk.. but i was referencing .. relations being bi-directional, if mongo needs to send something like an ssl cert.. joined is early to see any settings from the remote side.. lots of charms just do changed hooks for relations, and check to see if the values they need are present.01:33
cory_fuMakes sense01:33
arosalescory_fu, does allura always need this setup-app to be done before other services are connected?01:34
cory_fuYes.  The setup-app creates the databases, collections, and indexes that the app needs01:35
cory_fuSo it needs to be done once before the app is started, when mongo is available01:35
arosalesah, once mongo is available01:36
arosalescory_fu, seems you would need to do that in the mongodb-relation-joined hook and check to make to see if setup-app has run and if not  . .  .01:37
arosalesthis would put a dep on the charm to mongodb. Specifically the charm is not usable until the mongodb relation is created01:38
arosalesthat would need to be documented in the readme01:38
arosaleshazmat, sound reasonable? ^01:39
cory_fuIf you're interested in seeing what I have so far, I just put it up here: https://sourceforge.net/u/masterbunnyfu/allura-charm/ci/master/tree/01:39
arosalesseems the install hook is too early as mongo may not be available01:39
hazmatarosales, sounds good01:39
* hazmat peaks01:40
hazmatcory_fu, allura is python afaicr.. i'd probably go with an upstart job for the wsgi api.. and s/paster/gunicorn01:41
hazmatoh.. allura made it to an apache project.. cool01:42
cory_fuIncubating, but we're hoping to get it graduated soon01:42
hazmatcory_fu, re install i'd probably do pip ---use-mirrors01:44
arosaleslooks like your following the node example and skipping the mongodb-relation-joined and checking for the db in the mongodb-relation-changed01:46
cory_fuYeah01:46
cory_fuhazmat: I've not tried to run Allura under gunicorn.  Is it more or less drop-in?01:47
hazmatcory_fu, some charms capture there deps locally.. probably overkill but with pip you can do offline installs if you $ pip install -d  dist -r requirements.txt  to download all the eggs and then install  in the charm with $ pip install --no-index --find-links=file://tools/dist -r requirements.txt01:47
hazmatcory_fu, yeah.. more or less.. there's a gunicorn_paster command that behaves like a paster analogue for serve  http://gunicorn-docs.readthedocs.org/en/latest/run.html01:48
hazmater.. http://gunicorn-docs.readthedocs.org/en/latest/run.html#gunicorn-paster01:48
hazmatcory_fu, i'd go ahead and get it running with whatever your comfortable with first.. there's always room for optimization later01:49
cory_fuYeah01:49
arosalescory_fu, if you have issues with waiting the the db in mongodb-relation-changed you may want to specifically move the setup-app into the -joined hook01:50
* arosales still looking to see what mims is doing to skip the -joined and block to the -changed hook is fired01:51
cory_fuNow I'm confused.  Is -changed before or after -joined?01:51
arosalescory_fu, sorry for the confusion01:52
arosales-joined is before -changed01:52
hazmatjoined is always called before the first changed, and always accompanied by a changed.01:52
arosales<name>-relation-joined is run once only, when that remote unit is first observed by the unit.01:53
arosalesref = https://juju.ubuntu.com/docs/authors-charm-hooks.html01:53
hazmatonce for each unit of the remote service01:53
hazmatso if you have a replica set.. you'll get joined multiple times.01:54
hazmatand each of those joins will be immediately followed by a changed hook firing for the same unit.01:54
arosaleshazmat, is -joined to early to call setup-app here?01:55
arosalesor just the right place01:55
arosalescory_fu, needs setup-app to be called once only after mongodb is ready01:56
arosalesready = mongodb can start creating tables01:56
hazmatarosales, joined feels a bit early for db initialization..  ie. a mongodb client connections might need a replicaset name that's sets on the connection, and port is a config option for mongo which is conveyed along relations (although defaults to std 27017)... neither would be set in -joined02:00
arosalescory_fu, if all you need in setup-app is the private address and the DB names which you know before hand -joined should be ok, but you can also check if it is a first run -changed02:00
arosaleshazmat, good point on the replica set02:00
arosaleshazmat, thanks for the info02:00
arosalescory_fu, hopefully that info is helpful.02:01
arosalescory_fu, I am going to grab some dinner but feel free to leave a ping here if you run into any other questions02:01
cory_futhanks.  I'm probably going to call it a night soon (on east coast time), but I'll be on tomorrow working on this.02:02
hazmatcory_fu, np.. folks will be around02:03
cory_fuThanks02:03
* hazmat included02:04
=== ev_ is now known as ev
=== freeflying is now known as freeflying_away
=== freeflying_away is now known as freeflying
=== freeflying is now known as freeflying_away
hazmatcory_fu, so you've got local provider in vagrant you want to access from cli on osx host19:13
hazmat?19:13
cory_fuWell, I followed this setup: https://juju.ubuntu.com/docs/config-vagrant.html19:13
hazmathmm.. so there are two ports you would need forwarded from host to container19:14
hazmatnot sure if the vagrant box does that19:14
cory_fuSo, yeah, wondering how to use that from the cli now.  (Or how to add and debug my charm to it)19:14
hazmatcory_fu, you can use the cli from within the vagrant box19:15
cory_fuAh19:15
hazmatcory_fu, vagrant ssh19:15
cory_fuI did do the sshuttle step, so it would be nice to take advantage of that19:16
hazmatcory_fu, that will be helpful for access services you deploy in the local provider (lxc contianers in the vagrant box)19:17
cory_fuAh, so it doesn't really help with using the cli locally against the vagrant box?19:18
hazmatto use the cli on osx, you'd need to copy ~/.juju/environments/$env_name.jenv within the box to the host in the same place.. you'll also need to forward some additional ports..19:18
hazmatcory_fu, yeah.. it doesn't seem like it does..19:19
hazmatcory_fu, you can not sure which version of the gui its using, but you can drag and drop local charm folders to the gui in the latest version to deploy them19:19
hazmatbut not helpful for debugging19:19
cory_fuOh, nice19:19
=== timrc is now known as timrc-afk
hazmatcory_fu, i'd recommend just doing cli from within the vagrant box19:20
cory_fuJust the local folder into the GUI?19:20
cory_fuOk19:20
cory_fuvagrant@vagrant-ubuntu-precise-64:~/allura-charm$ juju debug-log19:22
cory_fuPermission denied (publickey,password).19:22
cory_fuThe authorized-keys in ~/.juju/environments/local.jenv matches the id_rsa.pub.  o_O19:29
hazmatmarcoceppi, you know anything about that vagrant box setup? ^19:30
* hazmat notes he's not here19:31
hazmatcory_fu, switch to the ubuntu user19:31
cory_fuAh19:32
hazmatcory_fu, i'm guessing.. i haven't used that vagrant box before19:32
cory_fuCan't seem to su; none of the mentioned passwords work19:33
cory_fuOk, su -> su ubuntu worked19:33
* hazmat installs virtualbox19:34
cory_fuNope.  No .juju directory for that user19:34
hazmatcory_fu, and no private keys in ~/.ssh?19:34
cory_fuIt does seem like it's set up to use the vagrant user.19:34
hazmatfor vagrant user19:34
hazmatyeah19:34
hazmatit does19:34
cory_fuNot for ubuntu, no19:34
hazmatbut it should have a private key as well is the odd part19:34
cory_fuThe vagrant user does have one, and it matches what's in the local.jenv file19:35
cory_fuBut I still get the error19:35
hazmatsounds like a different issue then19:40
hazmatcory_fu, i'm in process of downloading the jujubox img.19:40
hazmatcory_fu, works out of the box for me19:55
hazmatcory_fu, interesting i take that back19:55
hazmatcory_fu, aha19:55
hazmatjuju debug-log doesn't.. juju ssh unit_does19:55
hazmatcory_fu, you can juju ssh allura/0   and view log at /var/log/juju/unit-allura-0.log19:56
hazmatcory_fu, debug-log doesn't work for local provider in 1.16.6 version of juju19:56
cory_fuAh20:00
cory_fuThis is after doing juju deploy allura from within the vagrant image?20:01
cory_fuvagrant@vagrant-ubuntu-precise-64:~$ juju ssh allura/020:04
cory_fuERROR unit "allura/0" has no public address20:04
hazmatcory_fu, juju status allura20:05
cory_fuAh, I see.  It wasn't up yet20:06
cory_fuI don't see a juju destroy command; how do I re-deploy if it failed?20:24
cory_fuOh, nevermind.  juju help commands20:25
cory_fu:-p20:25
cory_fuHow long should I expect destroy-service to take?20:30
cory_fuHrm, yeah.  The status says it's in "life: dying" but it doesn't seem to be doing anything20:43
hazmatcory_fu, shouldn't take that long20:43
cory_fuIs there another log besides the unit-allura-0.log?20:44
cory_futhat I should check?20:44
hazmatcory_fu, for local provider on the vagrant box there should be some logs in ~/.juju20:44
hazmatthe interesting one is the host machine-0.log20:45
cory_fuYeah, it doesn't seem to do anything when I issue a destroy-service allura20:46
cory_fuCan I more forcibly remove it with destroy-machine?20:47
hazmatcory_fu, yes.. juju terminate-machine --force machine_id_with_allura20:48
cory_fuOk, that worked20:50
cory_fuWonder why it didn't work with destroy-service20:50
hazmatnot sure, i've been using the dev version 1.17 series and hitting it pretty hard.. haven't seen that20:54
cory_fuBlargh.  It didn't use my update to the install script20:55
cory_fu*hook20:55
cory_fuI assume that once I referenced it once with --repository=/path and local:precise/allura, it's somehow cached and I need to do something to clear that?20:57
hazmatcory_fu, you have to deploy with -u21:11
cory_fuAh21:11
hazmatcory_fu, you can also juju upgrade-charm --force to update in place21:11
hazmat--force is needed to upgrade if its currently in an error state21:11
cory_fuOk21:11
hazmatcory_fu, if you hit a hook error, you can juju resolved --retry to have it re-execute21:11
hazmatjuju debug-hooks drops you in a tmux session where you can interactively explore the state of the hook (the hooks pop up in new tmux windows) can be used in combination with resolved --retry..21:12
hazmatcaveat there is debug-hooks always returns success for the hook being executed21:12
cory_fuThough I can't retry the hook, since I need the copy of the hook to be updated.  I assume it won't re-pull the hook from the source I gave to the original deploy command?21:18
hazmatcory_fu, you can juju upgrade-charm --force to put the new source in place21:25
hazmatcory_fu, or deploy -u  which will increment the revision file automatically in the charm21:25

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!