databricks / click

The "Command Line Interactive Controller for Kubernetes"
Apache License 2.0
1.49k stars 84 forks source link

Logs -f: cannot Ctrl-C out of followed logs #99

Open jrop opened 5 years ago

jrop commented 5 years ago

Thanks for writing this! This is an amazing utility for managing/monitoring K8s!

My use-case is, when I have a pod selected, I like to follow logs at times. Now, from within click, logs works flawlessly, as expected. However, when I issue the command logs -f, it starts following the logs for the currently selected pod, but I can never terminate the followed log (by Ctrl+C, for example). The only way I have found to kill click, is Ctrl+Z, then kill %1.

I am on MacOS with Click 0.3.2

jrop commented 5 years ago

I also tried updating to using the master branch (cargo install --force: 0.4.0), and I am still seeing the same issue

nicklan commented 5 years ago

hrmm, and you're doing this via just cargo install and then running click? there was an old bug in cargo that caused cargo run to have this exact behavior, but unless you're doing cargo run with an old version of cargo that's probably not it.

If you can, could you test the ctrlc crate on your system via the following:

$ git clone https://github.com/Detegr/rust-ctrlc.git
$ cd rust-ctrlc
$ cargo run --example readme_example

Which should output something like:

$ cargo run --example readme_example
[...]
Waiting for Ctrl-C...
^CGot it! Exiting...

If that works it's probably something inside Click and I can try and look further.

jrop commented 5 years ago

@nicklan Yes, to confirm, I installed the latest version of click by cloning the repo, and running cargo install --force (as I had a previous version installed). Then I run click at my terminal whenever I run click.

I tried running rust-ctrlc directly, and this is what I got:


(master ✓) rust-ctrlc cargo run --example readme_example
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/examples/readme_example`
Waiting for Ctrl-C...
^CGot it! Exiting...
(master ✓) rust-ctrlc
nicklan commented 5 years ago

odd, okay, I will try and investigate this further. thanks for the info!

slyoldfox commented 5 years ago

@nicklan seeing the same issue today, isn't the cause that:

                        while !env.ctrlcbool.load(Ordering::SeqCst) {
                            if let Ok(amt) = reader.read_line(&mut line) {

reader.read_line is a blocking call?

As far as I see it, the ^C displays on the screen when I press it, but will only terminate the stream after a line has been read from the server.

Shouldn't reading from the server be async or in a thread?