-
Notifications
You must be signed in to change notification settings - Fork 71
daemonized-mode: add interactive shell support #167
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
daemonized-mode: add interactive shell support #167
Conversation
12415bc
to
5a1db10
Compare
This is confusing for the user. The shell, batch mode, and single commands should behave the same regardless of whether or not the daemon is being used. I propose one of the following:
|
I understand I didn't keep interactive mode as default mainly because our gluster-block tool uses daemonized batch mode already, and I fear making interactive default will break gluster-block for sure. Now that you raised the voice, I'II will work on fixing gluster-block later. Now, let me make interactive shell as default as to make it look alike cli mode. I will also provide a global option something like 'use_batch_mode' which should help switch between interactive and batch modes. |
5a1db10
to
9654476
Compare
@gonzoleeman @iammattcoleman @maurizio-lombardi @lxbsz Hope this is the expectation. In case if we want this to be part of the next release v2.1.51 (which should ideally happen early next week), then please help me with the tests and review. Thanks! |
scripts/targetcli
Outdated
break | ||
else: | ||
call_daemon(shell, command.encode()) | ||
sys.exit(0) |
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.
Maybe here also could just break the loop like the above.
scripts/targetcli
Outdated
sys.exit(1) | ||
|
||
usage_version(command); | ||
command = '%'.join(inputs) # delimit multiple commands with '%' |
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.
We can move the Line#199 just before Line#204, no need to join it here every time.
9654476
to
f19e961
Compare
@lxbsz modified the conditioning for better readability. Thanks! |
f19e961
to
2315147
Compare
@lxbsz updated. Thanks! |
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.
This looks good to me.
Thanks.
@iammattcoleman @gonzoleeman can you guys please share your first impression on this? Thanks! |
This is definitely on the right track. Thanks for working on this! I found three bugs...
|
2315147
to
3cdd4ec
Compare
Thanks @iammattcoleman for testing this.
Yeah, I know this. This is because the cli will be a dummy in daemon mode, it will not have handle for root_node. One option always returns
Again, maybe I need to see the rtslib code more to understand how to not let the stdout chars not modifiable or unchanged. |
@pkalever I've been thinking about a significant rewrite to enforce separation of concerns a bit better by removing the UI handling code entirely from the daemon and making it just an RPC server. It could use JSON-RPC, Protocol Buffers, Thrift, etc. Thrift would make it very easy to switch between daemonized mode and direct execution by targetcli. However, it's got a pretty steep initial learning curve and a lot of people dislike generated code. (Although it does a pretty good job of making it so you can ignore the contents of the generated code and just use it.) JSON-RPC would probably be my preference, but I haven't actually worked with it in Python previously. I find that Protocol Buffers (without going to full gRPC, which doesn't make sense at all for this) tends to be just as verbose as Thrift but with a much steeper barrier to entry because you have to implement so much boilerplate yourself. Are there any other options would recommend? What do you think about the idea, overall? |
3cdd4ec
to
f9b3a9b
Compare
@iammattcoleman Frankly, I initially wanted to introduce the socket based communication with some sort of rpc, but I didn't actually found a need for it. And I also didn't want to make it complicated, just for string query and response kind of usecase. I will consider rethinking on this and share my thoughts later this week. @maurizio-lombardi @iammattcoleman fixed the issue 2 and 3 mentioned in the above comments by Matt. For issue 1: I was thinking just instead of printing May be lets just print > Thoughts? |
I think it makes sense |
f9b3a9b
to
fe69253
Compare
I will check it out today.
…--
Lee-Man Duncan
Sent from my iPhone, dude
On Apr 6, 2020, at 12:49 AM, Prasanna Kumar Kalever ***@***.***> wrote:
@iammattcoleman @gonzoleeman can you guys please share your first impression on this?
Thanks!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
fe69253
to
853bbc4
Compare
@maurizio-lombardi @gonzoleeman @iammattcoleman @lxbsz with the patch2, now the interactive mode can print the prompt path. Please take a look. Thanks! |
set interactive mode as default to make it appear similar to cli approach, $ targetcli targetcli shell version 2.1.51 Entering targetcli interactive mode for daemonized approach. Type 'exit' to quit. /> pwd / /> cd /iscsi /> pwd /iscsi /> exit Here we introduce a new global option daemon_use_batch_mode for switching between batch and interactive modes. $ targetcli set global daemon_use_batch_mode=true Parameter daemon_use_batch_mode is now 'true'. $ targetcli targetcli shell version 2.1.51 Entering targetcli batch mode for daemonized approach. Enter multiple commands separated by newline and type 'exit' to run them all in one go. /> pwd /> cd /iscsi /> pwd / /iscsi Fixes: open-iscsi#160 Signed-off-by: Prasanna Kumar Kalever <[email protected]>
$ targetcli targetcli shell version 2.1.51 Entering targetcli interactive mode for daemonized approach. Type 'exit' to quit. /> pwd / /> cd /iscsi /iscsi> ls o- iscsi .......................................... [Targets: 0] /iscsi> exit Signed-off-by: Prasanna Kumar Kalever <[email protected]>
853bbc4
to
d768df6
Compare
Your recent changes fixed the issues I had found. I found another example of why the daemon should not be trying to format the terminal output: it is unaware of the terminal's width:
I really don't think that should be fixed in the daemon: the code is getting increasingly complicated because of the lack of separation of concerns. To resolve this would require adding code that lets |
@iammattcoleman I agree. That we need to work on the UI positioning. But that's an another story for another PR! These changes won't be happening in daemon, because daemon will be running via systemd and it has no idea about the width of its client (targetcli). Thanks Matt for the retesting this sequence. |
I have tested the branch. Thank you for your changes! My take on this is that it is better than before. I just did a quick sanity test on my "standard" configuration, which is one backstore file being used by one LUN, and it looked good. But interactive mode is still different when he daemon is present: there is no "color" enhancement. Last time I mentioned this problem others seemed to think it was not a big deal, but the color enhancement is there for a reason: it helps. It seems like, the way things are working now, the reason for this is that the daemon should not have to care about enhancing its output with color hints, but I disagree with that, at least partly. I'll back up and explain what I thought we were getting and what I would prefer. I'd like to go to an architecture where we have the daemon running all the time, and there's a thin CLI client. The work should be divided IMHO in such a way that the daemon does the heavy lifting, like setup, event detection, sysfs interaction, etc, and the CLI handle the "display" and "input" parts. In such a world the "batch" API could be just another client or use the CLI in some special mode. I'm not sure where "coloring hints" (like good connections are green, bad connections are red) would fit in such an architecture, but I suspect it'd have to be shared between the backend and frontend, since the backend knows the status and state of things, and the front end knows how to display "things". Bottom line: given that we probably will not get color, for now, from the daemon, this seems better than forcing batch mode on systems where the daemon is running, to me. |
Typing somthing and then hitting backspace multiple-times would clear the prompt previously. This patch do not let backspace clear the prompt msg. Signed-off-by: Prasanna Kumar Kalever <[email protected]>
@gonzoleeman Thanks for testing this series. My understanding is that for adding coloring support we need to bring a part of configshell and rtslib code to targetclid. As I always mention, targetclid is young and its at the very beginning, we can do much more with it. I will keep the coloring feature request in mind, and try to come up with the optimal solution for achieving it in the near feature. Thanks! |
latest targetcli daemon approach set interactive mode as default to make it appear similar to cli approach, hence to use previous batch mode we need some global settings. Depends on: open-iscsi/targetcli-fb#167 Signed-off-by: Prasanna Kumar Kalever <[email protected]>
latest targetcli daemon approach set interactive mode as default to make it appear similar to cli approach, hence to use previous batch mode we need some global settings. Depends on: open-iscsi/targetcli-fb#167 Reviewed-by: Xiubo Li <[email protected]> Signed-off-by: Prasanna Kumar Kalever <[email protected]>
latest targetcli daemon approach set interactive mode as default to make it appear similar to cli approach, hence to use previous batch mode we need some global settings. Depends on: open-iscsi/targetcli-fb#167 Reviewed-by: Xiubo Li <[email protected]> Signed-off-by: Prasanna Kumar Kalever <[email protected]>
set interactive mode as default to make it appear similar to cli approach,
Here we introduce a new global varibale
daemon_use_batch_mode
for switching betwebatch and interactive modes.
Fixes: #160
Signed-off-by: Prasanna Kumar Kalever <[email protected]>