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

Skip to content

Commit fd7f815

Browse files
robyoungmattbostock
authored andcommitted
elasticsearch safe_reboot no longer just runs_once
With a more robust `wait_for_status` and given that `safe_reboot` waits for the cluster to be green, we can now run `safe_reboot` over an elasticsearch cluster with something like: `fab staging puppet_class:govuk::node::s_api_elasticsearch elasticsearch.safe_reboot`
1 parent b38cdbd commit fd7f815

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

elasticsearch.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ def wait_for_status(*allowed):
9595

9696
@task
9797
@serial
98-
@runs_once
9998
def safe_reboot():
10099
"""Reboot only if the cluster is currently green"""
101100
import vm
@@ -112,12 +111,16 @@ def safe_reboot():
112111
# Give the reboot time to start, before we check for the status again.
113112
sleep(10)
114113

115-
# Status won't usually go back to green while reallocation is turned off,
116-
# but should go to yellow.
114+
# Status won't usually go back to green while reallocation is turned
115+
# off, but should go to yellow.
117116
wait_for_status("green", "yellow")
118117
enable_reallocation()
119118
except:
120-
print "Failed to re-enable allocation - you will need to enable it again using the 'elasticsearch.enable_reallocation' fabric command"
119+
print(
120+
"Failed to re-enable allocation - "
121+
"you will need to enable it again using the "
122+
"'elasticsearch.enable_reallocation' fabric command"
123+
)
121124
raise
122125

123126

0 commit comments

Comments
 (0)