Skip to content

Commit 890b7f7

Browse files
committed
Always sleep while restarting
The /services/server/control/restart endpoint does not stop the API immediately. As a result, a login() call may still succeed just before the restart takes effect. This change introduces an additional sleep to prevent a burst of requests from reaching the server while it is in the process of restarting.
1 parent 27af330 commit 890b7f7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

splunklib/client.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,15 @@ def restart(self, timeout=None):
618618
while datetime.now() - start < diff:
619619
try:
620620
self.login()
621-
if not self.restart_required:
621+
if self.restart_required:
622+
# Prevent a burst of requests from bombarding Splunk.
623+
# Splunk does not stop the API immediately when /services/server/control/restart
624+
# responds, thus the login call (above) will still succeed until the server
625+
# is actually stopped. Based on the presence of restart_required required message,
626+
# that we have added before calling restart, we know that the server did not stop yet.
627+
sleep(1)
628+
continue
629+
else:
622630
return result
623631
except Exception as e:
624632
sleep(1)

0 commit comments

Comments
 (0)