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

Add support of JSON API via network socket #121

Open
ligurio opened this issue Jan 22, 2023 · 0 comments
Open

Add support of JSON API via network socket #121

ligurio opened this issue Jan 22, 2023 · 0 comments

Comments

@ligurio
Copy link
Owner

ligurio commented Jan 22, 2023

Currently, unreliablefs supports a single interface of setting fault injections - plain text file with INI-style configuration options. It would be quite convenient to have yet another interface with access via network socket and JSON API.

New command-line option

Add a new option socket that allows to specify a path to a control UNIX socket.
Mount with socket:

$ unreliablefs /tmp/fs -base_dir=/tmp -seed=1618680646 -socket=/tmp/unreliablefs.socket

JSON API:

JSON API has the same keywords as used in a configuration file.

# Show current fault-injections:
$ cat /tmp/unreliablefs.socket
{ "err-injections":[] }
...
# Set an error injection with `noop`:
$ echo '{ "err-injections": [ {"name": "errinj_noop", "path_regexp": "", "op_regexp": "", "probability": 5 } ] }' >  /tmp/unreliablefs.socket
...
# Set two error injections: `errinj_kill_caller` and `errinj_errno`:
$ echo '{ "err-injections":[ { "name": "errinj_kill_caller", "path_regexp": "" }, { "name": "errinj_errno", "path_regexp": "" } ] }' >  /tmp/unreliablefs.socket
...
# Cleanup all fault-injections:
$ echo '{ "err-injections": [] }' >  /tmp/unreliablefs.socket

Setting options using jo(1):

$ jo err_injections[]=$(jo name=errinj_errno) err_injections[]=$(jo name=errinj_noop)
{"err_injections":[{"name":"errinj_errno"},{"name":"errinj_noop"}]}
$ jo err_injections[]=$(jo name=errinj_errno) err_injections[]=$(jo name=errinj_noop) > /tmp/unreliablefs.socket

References

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