charms/node-app — pull request #1 by achiang (2014-06-19 22:27:23+00:00)
Title: hooks/stop: make idempotent

Both the mongodb-relation-departed hook and stop hook attempt to stop
the node-app service, but if the service is already stopped, this results
in an error.

This happens when issuing the sequence:

juju remove-relation mongodb node-app
juju remove-service node-app

Issuing juju status shows:

node-app:
charm: local:trusty/node-app-34
exposed: false
life: dying
units:
node-app/0:
agent-state: error
agent-state-info: 'hook failed: "stop"'
agent-version: 1.18.4
life: dying

Checking in /var/log/juju/unit-node-app-0.log reveals:

INFO mongodb-relation-departed openmotion stop/waiting
INFO stop openmotion stop/waiting
INFO stop stop: Unknown instance:

Solution is to rewrite the logic in the hooks so they don't care if the
service is already stopped or not.