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

Crash loading cache if file is empty or corrupted #713

Closed
rizdaputra opened this Issue Jul 27, 2018 · 1 comment

Comments

2 participants
@rizdaputra

rizdaputra commented Jul 27, 2018

What were you trying to do?

run telepresence --run-shell

Automatically included information

Command line: ['/usr/local/bin/telepresence', '--run-shell']
Version: 0.86
Python version: 3.6.5 (default, Apr 1 2018, 05:46:30) [GCC 7.3.0]
kubectl version: Client Version: v1.8.6 // Server Version: v1.9.6-gke.1
oc version: (error: [Errno 2] No such file or directory: 'oc': 'oc')
OS: Linux putra-Lenovo-IdeaPad-Z410 4.15.0-22-generic #24-Ubuntu SMP Wed May 16 12:15:17 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Traceback:

Traceback (most recent call last):
  File "/usr/local/share/telepresence/libexec/lib/python3.6/site-packages/telepresence/cli.py", line 74, in call_f
    return f(*args, **kwargs)
  File "/usr/local/share/telepresence/libexec/lib/python3.6/site-packages/telepresence/main.py", line 433, in go
    runner = Runner.open(args.logfile, kubectl_or_oc(server), args.verbose)
  File "/usr/local/share/telepresence/libexec/lib/python3.6/site-packages/telepresence/runner.py", line 138, in open
    open(logfile_path, "a", buffering=1), kubectl_cmd, verbose
  File "/usr/local/share/telepresence/libexec/lib/python3.6/site-packages/telepresence/runner.py", line 114, in __init__
    self.cache = Cache.load(os.path.join(cache_dir, "cache.json"))
  File "/usr/local/share/telepresence/libexec/lib/python3.6/site-packages/telepresence/cache.py", line 29, in load
    cache = json.load(f)
  File "/usr/lib/python3.6/json/__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Logs:

   0.0 TEL | Telepresence 0.86 launched at Fri Jul 27 18:51:42 2018
   0.0 TEL |   /usr/local/bin/telepresence --run-shell
   0.0 TEL | [1] Launching: kubectl version --short
   0.0 TEL | [2] Launching: oc version
   0.0 TEL | [2] [Errno 2] No such file or directory: 'oc': 'oc'
   0.0 TEL | [3] Launching: uname -a
   0.0   3 | Linux putra-Lenovo-IdeaPad-Z410 4.15.0-22-generic #24-Ubuntu SMP Wed May 16 12:15:17 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
   0.0 TEL | Python 3.6.5 (default, Apr  1 2018, 05:46:30)
   0.0 TEL | [GCC 7.3.0]
   0.0 TEL | [3] exit 0
   0.9   1 | Client Version: v1.8.6
   0.9   1 | Server Version: v1.9.6-gke.1
   0.9 TEL | [1] exit 0

@ark3 ark3 added the bug label Jul 30, 2018

@ark3 ark3 self-assigned this Jul 30, 2018

@ark3 ark3 added this to To do in Tel Tracker via automation Jul 30, 2018

@ark3

This comment has been minimized.

Contributor

ark3 commented Jul 30, 2018

Sorry about the crash! As a workaround, please delete the Telepresence cache file in ~/.cache/telepresence if it's still there.

@ark3 ark3 changed the title from json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) to Crash loading cache if file is empty or corrupted Jul 30, 2018

@ark3 ark3 closed this in #716 Jul 30, 2018

Tel Tracker automation moved this from To do to Done Jul 30, 2018

ark3 added a commit that referenced this issue Jul 30, 2018

Merge pull request #716 from telepresenceio/cache-load-crash
Don't crash in the presence of an empty or corrupted cache file
Closes #713
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment