Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d95376d

Browse files
committed
Fix Elasticsearch settings on newer versions
Newer versions of Elasticsearch do not return a key of "ok" in the response body when changing a setting, which means this task fails on our newest machines. Amend the conditional so that we only check for "acknowledged", unless we're on an old version of Elasticsearch in which case also check for "ok". We can remove the 2nd conditional once all of the old Elasticsearch is gone.
1 parent acb52ee commit d95376d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

elasticsearch.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from distutils.version import StrictVersion
12
from fabric.api import *
23
from time import sleep
34
import json
@@ -41,8 +42,11 @@ def put_setting(setting, value):
4142
"transient": {"%s": "%s"}
4243
}'""" % (setting, value))
4344
parsed_result = json.loads(result)
44-
if not parsed_result.get("ok") or not parsed_result.get("acknowledged"):
45-
raise RuntimeError("Failed to put setting: %s" % (result, ))
45+
if not parsed_result.get("acknowledged"):
46+
raise RuntimeError("Failed to put setting: %s".format(result))
47+
if StrictVersion(version()) < StrictVersion('1.0'):
48+
if not parsed_result.get("ok"):
49+
raise RuntimeError("Failed to put setting: %s".format(result))
4650

4751

4852
@task

0 commit comments

Comments
 (0)