Skip to content

Commit

Permalink
make run available
Browse files Browse the repository at this point in the history
Signed-off-by: Sylvain Hellegouarch <sh@defuze.org>
  • Loading branch information
Lawouach committed Apr 3, 2023
1 parent b3c9631 commit 3402e97
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

## [Unreleased][]

[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-addons/compare/0.8.4...HEAD
[Unreleased]: https://github.com/chaostoolkit/chaostoolkit-addons/compare/0.8.5...HEAD

## [0.8.5][]

[0.8.5]: https://github.com/chaostoolkit/chaostoolkit-addons/compare/0.8.4...0.8.5

### Changed

* Make safeguard probe that got triggered available to review

## [0.8.4][]

Expand Down
11 changes: 8 additions & 3 deletions chaosaddons/controls/safeguards.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
calls for too long.
"""
from concurrent.futures import Future, ThreadPoolExecutor
from copy import deepcopy
from datetime import datetime
from functools import partial
import sys
Expand Down Expand Up @@ -113,6 +114,8 @@ def __init__(self) -> None:
self._interrupted = False
self._setup = False
self.triggered_by = None
self.triggered_by_run = None
self.was_triggered = False

@property
def interrupted(self) -> bool:
Expand Down Expand Up @@ -192,9 +195,11 @@ def run(self, experiment: Experiment, probes: List[Probe],
# this allows the experiment to block until these are passed
self.now_all_done.wait()

def interrupt_now(self, triggered_by: str) -> None:
def interrupt_now(self, triggered_by: str, run: Run) -> None:
with self._lock:
self.triggered_by = triggered_by
self.triggered_by_run = deepcopy(run)
self.was_triggered = True

self.wait_for_interruption.set()

Expand All @@ -205,7 +210,7 @@ def _wait_interruption(self) -> None:
if experiment_finished.is_set():
return None

if not self.triggered_by:
if not self.was_triggered:
return None

with self._lock:
Expand Down Expand Up @@ -335,7 +340,7 @@ def interrupt_experiment_on_unhealthy_probe(guard: Guardian, probe: Probe,
tolerance, run["output"], configuration=configuration,
secrets=secrets)
if not checked:
guard.interrupt_now(probe["name"])
guard.interrupt_now(probe["name"], run)


def execute_activity(experiment: Experiment, probe: Probe,
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
setup(
use_scm_version=True,
name="chaostoolkit-addons",
version="0.8.4",
version="0.8.5",
)

0 comments on commit 3402e97

Please sign in to comment.