Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

ldshell logs show is broken in OSS build #62

Closed
MohamedBassem opened this issue Dec 31, 2018 · 5 comments
Closed

ldshell logs show is broken in OSS build #62

MohamedBassem opened this issue Dec 31, 2018 · 5 comments

Comments

@MohamedBassem
Copy link
Contributor

MohamedBassem commented Dec 31, 2018

Steps to reproduce:

  • Start a local cluster using ld-dev-cluster using the ubuntu docker image
  • ldhsell into this cluster
  • Run logs show
  • It crashes with:
root@/dev/shm/tmp/logdevice/IntegrationTestUtils.510e-92fc-9dcd-57c2/logdevice.conf> logs show
Error running command: 'ascii' codec can't encode character '\u25bc' in position 5: ordinal not in range(128)
------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/nubia/internal/cmdbase.py", line 363, in run_interactive
    ret = fn(**args_dict)
  File "/usr/local/lib/python3.6/dist-packages/ldshell/autoload/commands/logsconfig.py", line 514, in show
    node, max_depth=max_depth, log_groups=True, show_version=True
  File "/usr/local/lib/python3.6/dist-packages/ldshell/autoload/commands/logsconfig.py", line 334, in _print_directory
    return _print_directory_helper(0, directory, max_depth, log_groups, show_version)
  File "/usr/local/lib/python3.6/dist-packages/ldshell/autoload/commands/logsconfig.py", line 309, in _print_directory_helper
    cprint(space_shift + "\u25BC " + directory.fully_qualified_name, "green")
  File "/usr/local/lib/python3.6/dist-packages/termcolor.py", line 124, in cprint
    print((colored(text, color, on_color, attrs)), **kwargs)
UnicodeEncodeError: 'ascii' codec can't encode character '\u25bc' in position 5: ordinal not in range(128)
------------------------------------------------------------
@MohamedBassem
Copy link
Contributor Author

MohamedBassem commented Dec 31, 2018

Even easier, running this inside the container triggers the error.

python3 -c 'print("Hello\u25BC")'

I tried it on my personal laptop outside the container and it worked correctly. I use Python 3.7 on my laptop but the one installed in the container is Python 3.6.7. I'm not a python expert but I found this in the release notes of Python 3.7: Avoiding the use of ASCII as a default text encoding which seems relevant.

Maybe we should install Python 3.7 in the container then?

@motohedgehog
Copy link

@MohamedBassem, unfortunately, Nubia and hence LDShell are not Python 3.7 compatible at the moment (see facebookarchive/python-nubia#2). I hope @calebmarchent and/or myself will be able to address it soon(-ish).

@calebmarchent
Copy link

Logs Show is using hardcoded utf-8 charaters to render the tree; ▼ is "\u25BC". But by default the docker container shell is configured without UTF-8 support.
One can work-around the issue by setting the locale in the terminal:

root@af2893e7f15f:/# export LANG=C.UTF-8
root@af2893e7f15f:/# ldshell -c /dev/shm/tmp/logdevice/IntegrationTestUtils.5714-ed1a-5e36-c72b/logdevice.conf
Logging to /tmp/ldshell-pcjjglrc
Logging Level: WARNING
root@/dev/shm/tmp/logdevice/IntegrationTestUtils.5714-ed1a-5e36-c72b/logdevice.conf> logs show
▼ /
  Version: 1
  Attributes:
  - extra-copies: 0    (Overridden)
  - synced-copies: 0    (Overridden)
  - max-writes-in-flight: 1000    (Overridden)
  - single-writer: False    (Overridden)
  - sequencer-affinity: None    (Overridden)
  - nodeset-size: None    (Overridden)
  - backlog: None    (Overridden)
  - delivery-latency: None    (Overridden)
  - scd-enabled: False    (Overridden)
  - local-scd-enabled: False    (Overridden)
  - write-token: None    (Overridden)
  - sticky-copysets: False    (Overridden)

Docker containers are intended to provide lean controlled environments for individual services to run in so the majority of the terminal things we are used to as developers are not present (e.g. an editor).

In terms of a solution: we could update the Docker container shell to have UTF-8 enabled. Or we could remove the UTF-8 characters from the ldshell UI, replacing "▼" with "V" and "▶" with ">".

@calebmarchent
Copy link

Discussed further internally: the key features of ldshell include enhanced and hence intuitive presentation; use of UTF-8 will remain.
Next Action: Configure the Docker instance shells to include UTF-8.

@calebmarchent
Copy link

Fixed by: #63

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants