Code review comment for lp:~s-matyukevich/charms/trusty/elasticsearch/elasticsearch-dns-bug-fix

Revision history for this message
Sergey Matyukevich (s-matyukevich) wrote :

Reviewers: mp+239547_code.launchpad.net,

Message:
Please take a look.

Description:
Fix bug with elasticsearch charm install on amazon

On amazon when executing realtion-get in private-address parameter we
will get DNS name instead of a ip address. This don't work with current
implementation of elasticserch charm, because it reques IP address to
open port correctly. I add private-ip-address parameter and use it
instead of a private-address.

https://code.launchpad.net/~s-matyukevich/charms/trusty/elasticsearch/elasticsearch-dns-bug-fix/+merge/239547

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/163870043/

Affected files (+7, -2 lines):
   A [revision details]
   M hooks/charmhelpers/core/hookenv.py
   M tasks/setup-ufw.yml

Index: [revision details]
=== added file '[revision details]'
--- [revision details] 2012-01-01 00:00:00 +0000
+++ [revision details] 2012-01-01 00:00:00 +0000
@@ -0,0 +1,2 @@
+Old revision: <email address hidden>
+New revision: <email address hidden>

Index: tasks/setup-ufw.yml
=== modified file 'tasks/setup-ufw.yml'
--- tasks/setup-ufw.yml 2014-07-30 06:35:59 +0000
+++ tasks/setup-ufw.yml 2014-10-24 11:18:33 +0000
@@ -21,7 +21,7 @@
    ufw: state=enabled policy=allow logging=on

  - name: Open the firewall for all clients
- ufw: rule=allow src={{ item.value['private-address'] }} port=9200
proto=tcp
+ ufw: rule=allow src={{ item.value['private-ip-address'] }} port=9200
proto=tcp
    with_dict: relations["client"]["{{ client_relation_id }}"] | default({})
    when: not item.key.startswith(service_name)

Index: hooks/charmhelpers/core/hookenv.py
=== modified file 'hooks/charmhelpers/core/hookenv.py'
--- hooks/charmhelpers/core/hookenv.py 2014-02-06 12:54:59 +0000
+++ hooks/charmhelpers/core/hookenv.py 2014-10-24 11:18:33 +0000
@@ -9,6 +9,7 @@
  import yaml
  import subprocess
  import sys
+inport socket
  import UserDict
  from subprocess import CalledProcessError

@@ -179,7 +180,9 @@
      if unit:
          _args.append(unit)
      try:
- return json.loads(subprocess.check_output(_args))
+ res = json.loads(subprocess.check_output(_args))
+ res['private-ip-address'] =
socket.gethostbyname(res['private-address'])
+ return res
      except ValueError:
          return None
      except CalledProcessError, e:

« Back to merge proposal