-
Notifications
You must be signed in to change notification settings - Fork 35
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
Support dynamically setting multiple failpoints #38
Support dynamically setting multiple failpoints #38
Conversation
cc @ptabor as well |
Related to #38 |
It isn't safe to lock each failpoint. The server might panic before sending response back to client. For example, when a user set a terms for failpoint A, but the server might be panicking due to failpoint B. So it isn't safe to lock each single failpoint once a time. Instead, we should lock the global mutex. When each failpoint is triggered, it just needs to acquire the read lock. But when a client set terms for failpoints, they need to acquire the write lock, and release the lock after the server(runtime) sends response back to the client. Signed-off-by: Benjamin Wang <[email protected]>
When the server(runtime) processes a http request, it acquires the global write lock. This prevents all failpoints from being triggered. It ensures the server(runtime) doesn't panic due to any failpoints during processing the HTTP request. It may be inefficient, but correctness is more important than efficiency. Usually users will not enable too many failpoints at a time, so it (the efficiency) isn't a problem. Example: endpoint: /failpoints body: failpoint1=return("hello");failpoint2=sleep(10) Signed-off-by: Benjamin Wang <[email protected]>
Signed-off-by: Benjamin Wang <[email protected]>
b475efa
to
1337baf
Compare
Signed-off-by: Benjamin Wang <[email protected]>
Thanks @serathius . Resolved all your comments. PTAL. |
if len(fps) == 0 { | ||
return fpMap, nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note: Don't think this is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we remove this, When users pass an empty string, then it will return error "bad failpoint xxx".
If we don't check the fps, then users are supposed to always pass a non-empty string. It seems like not a big deal, so let's keep it as it's for now.
Signed-off-by: Benjamin Wang <[email protected]>
1998403
to
d16d16d
Compare
Users can dynamically setting multiple failpoints using endpoint
/failpoints
, see example below,Please review this PR commit by commit.
@spzala @serathius @ramil600