jupyter-xeus / cpp-terminal

C++ library for writing multiplatform terminal applications
https://jupyter-xeus.github.io/cpp-terminal/
Other
527 stars 55 forks source link

error on k8s #376

Open boyism80 opened 2 weeks ago

boyism80 commented 2 weeks ago

when use on k8s this error occurred

errno 25: Inappropriate ioctl for device [::ioctl(Private::in.fd(), FIONREAD, &nread)]

i guess Private::in.fd() returns invalid value in k8s.

flagarde commented 2 weeks ago

Hello @boyism80, Thank you for the report. It was happening to github action too. I don't know exactly why it's not working anymore. I have to do workaround for this

flagarde commented 2 weeks ago

@boyism80 I have made some change on the code. It seems to fix the problem on github action but I don't know how to test it on k8s

boyism80 commented 2 weeks ago

@boyism80 I have made some change on the code. It seems to fix the problem on github action but I don't know how to test it on k8s

really appreciate you. I'll apply it to my project and let you know the results.

boyism80 commented 2 weeks ago

I tested your update. No more errors occurs on k8s but text doesn't appear. In non k8s, text appears normally. Additionally, I tested it using std::cout instead of Term::cout and it was appeared successfully on k8s.

tested on 802d7be9af07de6b7ae0dfcd21737220937242a8

flagarde commented 2 weeks ago

@boyism80 Thx for the update. I think the two bugs are not related. cpp-terminal open the /dev/tty by itself to be sure Term::cout is always printing to a terminal (it can't be redirected) contrary to std::cout. It seems k8s is doing some tricks like this before us so the logic in cpp-terminal fail and so redirect Term::cout to /dev/null I not sure what kubernetes is doing and so don't know exatly how to circonvoluate that. Do you have some ideas?

boyism80 commented 2 weeks ago

I also don't know why k8s have different results. I thought std::cout and Term:::cout were exactly the same, but I guess that's not it. I'll look at your code a little more when I have time. Thank you.

boyism80 commented 2 weeks ago

I looked into how kubernetes handles logs. I'm not sure if I understand right, but kubernetes redirects stdout, stderr because even when the system shuts down, it has to keep records without removing them. I think it's not a cpp-terminal's bug. It happened because I didn't know how to log in kubernetes. I have to approach it in a different way to use logs on Kubernetes. Thanks for your hard work.

document : https://kubernetes.io/docs/concepts/cluster-administration/logging/

flagarde commented 2 weeks ago

@boyism80 Thanks for the informations. Maybe is not a bug per se but I wonder if in the case there is no /dev/tty available, Term::cout should not redirect to stdout. I will try to think about it