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

Counterintuitive behaviour while using WatchedCustomServices #451

Open
eshaanganesh2 opened this issue Mar 14, 2024 · 1 comment
Open

Counterintuitive behaviour while using WatchedCustomServices #451

eshaanganesh2 opened this issue Mar 14, 2024 · 1 comment

Comments

@eshaanganesh2
Copy link

eshaanganesh2 commented Mar 14, 2024

Whenever we encounter any method, class, or package listed in WatchedCustomServices and it satsifies the level criteria, an assault is launched.

However, it's important to note that the level count increases each time we encounter a watched method, class, or package, regardless of whether it's present in the WatchedCustomServices list or not.

To simplify this, I propose that we only increase the level count while encountering any watched method (or class or package) listed in WatchedCustomServices. This adjustment would make the behavior more intuitive and ensure that the level count reflects the actual monitoring of the specified elements within the WatchedCustomServices list.

This can be better illustrated through an example.

Current Behavior

Consider the below code which consists of a service layer implementation invoking 3 functions (which are defined in another class annotated with @Component )

class serviceImpl(){ 

    @Autowired
    DemoApplicationComponent x;

    x.func1();
    x.func2();
    x.func3();
}

Let us assume the below configuration property has been set for WatchedCustomServices
chaos.monkey.assaults.watchedCustomServices=com.example.demo.component.DemoApplicationComponent.func2

and the watcher property for Component has been set to true
chaos.monkey.watcher.component=true

Let us also assume that a level count of 4 was set for this example
chaos.monkey.assaults.level=4
chaos.monkey.assaults.deterministic=true

When the request arrives at the serviceImpl class, the level count increases as follows:

x.func1(); // level = 1 (Not present in WatchedCustomServices)
x.func2(); // level = 2 (Present in WatchedCustomServices) ; 2%4!=0, therefore no assault is launched
x.func3(); // level = 3 (Not present in WatchedCustomServices)

Upon making a 2nd request to the serviceImpl class, the values change as follows:

x.func1(); // level = 4 (Not present in WatchedCustomServices)
x.func2(); // level = 5 (Present in WatchedCustomServices) ; 5%4!=0, therefore no assault is launched
x.func3(); // level = 6 (Not present in WatchedCustomServices)

Upon making a 3rd request to the serviceImpl class, the values change as follows:

x.func1(); // level = 7 (Not present in WatchedCustomServices)
x.func2(); // level = 8 (Present in WatchedCustomServices) ; 8%4==0, therefore assault is launched!
x.func3(); // level = 9 (Not present in WatchedCustomServices)

So, what we notice is that the assault occurs while handling the 3rd request, which is unexpected.

Expected Behavior

The expected behavior would be for the assault to happen during the handling of the 4th request. We'd anticipate the level count to increase by 1 each time func2() is encountered, hence triggering the assault in the 4th request.

An additional note (if required) may be included in the documentation explaining that the level count will only increase if the method specified in the WatchedCustomServices list is encountered. In case an incorrect value is assigned to the WatchedCustomServices property, no level count increment would be observed and hence, no assault would be initiated. Therefore, it is imperative to exercise caution when setting values within the WatchedCustomServices list.

@eshaanganesh2
Copy link
Author

A PR with the proposed changes has been raised at #452

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant