Skip to content

Commit

Permalink
Merge pull request #16 from chuckbutler/minimum-juju-version
Browse files Browse the repository at this point in the history
is_leader requires juju 1.22.0 or better
  • Loading branch information
Matt Bruzek committed Aug 10, 2015
2 parents 489ddb7 + e9efc9b commit 7eb5166
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -51,10 +51,17 @@ Health of the cluster can be checked by verified via juju actions
juju action fetch <uuid>


## Usage Caveats

This charm requires Leader Election, which is a feature of Juju >= 1.23.2. The
charm will panic and refuse to continue if the leader_election binary is not
found. Please take care when deploying this charm on older versions of Juju.

## Credits

The etcd charm was originally written by Kapil Thangavelu ([@kapilt](https://github.com/kapilt)).


#### Mantainers:

The kubernetes team maintains this charm:
Expand Down
9 changes: 8 additions & 1 deletion hooks/hooks.py
Expand Up @@ -16,11 +16,18 @@
hook_data = unitdata.HookData()
db = unitdata.kv()

leader_status = check_output(['is-leader']).rstrip() != "False"
private_address = hookenv.unit_get('private-address')
public_address = hookenv.unit_get('private-address')
unit_name = environ['JUJU_UNIT_NAME'].replace('/', '')

try:
leader_status = hookenv.is_leader()
except NotImplementedError:
hookenv.log('This charm requires Leader Election. Juju >= 1.23.2.'
' Leader election binary not found, Panic and exit!',
'CRITICAL')
sys.exit(1)


@hooks.hook('config-changed')
def config_changed():
Expand Down

0 comments on commit 7eb5166

Please sign in to comment.