Skip to content

Commit

Permalink
scripts: exit with 1 when Exception catched
Browse files Browse the repository at this point in the history
On #498, status of scylla-image-post-start.service is NOT "failed" even
the script causing error, because scylla_post_start.py catches all
exceptions and just logging it, so the script finishes without error.

To getting notify users the script failed operation during running, we
should sys.exit(1) when the exception catched.

fixes #505
  • Loading branch information
syuu1228 authored and yaronkaikov committed May 29, 2024
1 parent dc18f00 commit 2c1786c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
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

0 comments on commit 2c1786c

Please sign in to comment.