Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

exit with 1 when Exception catched and raise exception when HTTP error code is client error #511

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/scylla_configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def run_post_configuration_script(self):
except Exception as e:
scylla_excepthook(*sys.exc_info())
LOGGER.error("Post configuration script failed: %s", e)
sys.exit(1)

def start_scylla_on_first_boot(self):
default_start_scylla_on_first_boot = self.CONF_DEFAULTS["start_scylla_on_first_boot"]
Expand All @@ -141,6 +142,7 @@ def create_devices(self):
except Exception as e:
scylla_excepthook(*sys.exc_info())
LOGGER.error("Failed to create devices: %s", e)
sys.exit(1)

def configure(self):
self.configure_scylla_yaml()
Expand Down
1 change: 1 addition & 0 deletions common/scylla_create_devices
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,4 @@ if __name__ == "__main__":
create_raid(disk_devices, args.raid_level)
except (DiskIsNotEmptyError, NoDiskFoundError) as e:
print(e)
sys.exit(1)
1 change: 1 addition & 0 deletions common/scylla_post_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def run_post_start_script(self):
except Exception as e:
scylla_excepthook(*sys.exc_info())
LOGGER.error(f"Post start script failed: {e}")
sys.exit(1)


if __name__ == "__main__":
Expand Down
10 changes: 8 additions & 2 deletions lib/scylla_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ def curl(url, headers=None, method=None, byte=False, timeout=3, max_retries=5, r
while True:
try:
return _curl_one(url, headers, method, byte, timeout)
except (urllib.error.URLError, socket.timeout):
except (urllib.error.URLError, socket.timeout) as e:
# if HTTP error code is client error (400-499), skip retrying
if isinstance(e, urllib.error.HTTPError) and e.code in range(400,500):
raise
time.sleep(retry_interval)
retries += 1
if retries >= max_retries:
Expand All @@ -85,7 +88,10 @@ async def aiocurl(url, headers=None, method=None, byte=False, timeout=3, max_ret
while True:
try:
return _curl_one(url, headers, method, byte, timeout)
except (urllib.error.URLError, socket.timeout):
except (urllib.error.URLError, socket.timeout) as e:
# if HTTP error code is client error (400-499), skip retrying
if isinstance(e, urllib.error.HTTPError) and e.code in range(400,500):
raise
await asyncio.sleep(retry_interval)
retries += 1
if retries >= max_retries:
Expand Down
Loading