olx-global / rubiks

[DEPRECATED] Rubiks - a kubernetes YAML file generator and manager
Apache License 2.0
57 stars 6 forks source link

Generate better error messages from non-existent commands (or other command run errors) in run_command() #46

Closed katsharp closed 5 years ago

katsharp commented 6 years ago

Expected Behavior

Should be able to run rubiks after following the readme

Actual Behavior

Was unable to run rubiks because (I suspect) I do not have git-crypt installed.

Steps to Reproduce the Problem

  1. Clone the repo
  2. Try to run Rubiks

Specifications

katsharp commented 6 years ago

once installing git-crypt I also had to install htpasswd

mb-m commented 6 years ago

htpasswd is not a function of rubiks, but of the rubiks repository you're trying to run against.

What's the error message when you run rubiks without git-crypt installed

katsharp commented 6 years ago

Before installing git-crypt:

Traceback (most recent call last):
  File "../rubiks/rubiks", line 27, in <module>
    main()
  File "../rubiks/rubiks", line 24, in main
    sys.exit(command.Command.run_command())
  File "/home/ksharp/work/git/rubiks/lib/command.py", line 143, in run_command
    rc = cmd_obj.do_run(args.command)
  File "/home/ksharp/work/git/rubiks/lib/command.py", line 174, in do_run
    rc = self.run(nargs)
  File "/home/ksharp/work/git/rubiks/lib/commands/generate.py", line 46, in run
    files = collection.gen_output()
  File "/home/ksharp/work/git/rubiks/lib/load_python.py", line 206, in gen_output
    return self.outputs.write_output()
  File "/home/ksharp/work/git/rubiks/lib/output.py", line 101, in write_output
    return self._write_output_clustered()
  File "/home/ksharp/work/git/rubiks/lib/output.py", line 124, in _write_output_clustered
    uses_policybinding=uses_policybinding,
  File "/home/ksharp/work/git/rubiks/lib/output.py", line 191, in _write_namespace
    p = op.write_file(path)
  File "/home/ksharp/work/git/rubiks/lib/output.py", line 385, in write_file
    content = str(self.cached_yaml)
  File "/home/ksharp/work/git/rubiks/lib/var_types.py", line 119, in __str__
    return self._internal_render()
  File "/home/ksharp/work/git/rubiks/lib/var_types.py", line 112, in _internal_render
    ret += self.var[i].__str__()
  File "/home/ksharp/work/git/rubiks/lib/var_types.py", line 120, in __str__
    return self.renderer(self._internal_render())
  File "/home/ksharp/work/git/rubiks/lib/var_types.py", line 107, in _internal_render
    ret += self.to_string()
  File "/home/ksharp/work/git/rubiks/lib/kube_vartypes.py", line 27, in to_string
    s = str(self.value)
  File "/home/ksharp/work/git/rubiks/lib/var_types.py", line 119, in __str__
    return self._internal_render()
  File "/home/ksharp/work/git/rubiks/lib/var_types.py", line 107, in _internal_render
    ret += self.to_string()
  File "/home/ksharp/work/git/rubiks/lib/kube_vartypes.py", line 102, in to_string
    stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
katsharp commented 6 years ago

after installing git-crypt, BEFORE install htpasswd (or, more accurately, apache2-utils)

Traceback (most recent call last):
  File "../rubiks/rubiks", line 27, in <module>
    main()
  File "../rubiks/rubiks", line 24, in main
    sys.exit(command.Command.run_command())
  File "/home/ksharp/work/git/rubiks/lib/command.py", line 143, in run_command
    rc = cmd_obj.do_run(args.command)
  File "/home/ksharp/work/git/rubiks/lib/command.py", line 174, in do_run
    rc = self.run(nargs)
  File "/home/ksharp/work/git/rubiks/lib/commands/generate.py", line 46, in run
    files = collection.gen_output()
  File "/home/ksharp/work/git/rubiks/lib/load_python.py", line 206, in gen_output
    return self.outputs.write_output()
  File "/home/ksharp/work/git/rubiks/lib/output.py", line 101, in write_output
    return self._write_output_clustered()
  File "/home/ksharp/work/git/rubiks/lib/output.py", line 124, in _write_output_clustered
    uses_policybinding=uses_policybinding,
  File "/home/ksharp/work/git/rubiks/lib/output.py", line 191, in _write_namespace
    p = op.write_file(path)
  File "/home/ksharp/work/git/rubiks/lib/output.py", line 385, in write_file
    content = str(self.cached_yaml)
  File "/home/ksharp/work/git/rubiks/lib/var_types.py", line 119, in __str__
    return self._internal_render()
  File "/home/ksharp/work/git/rubiks/lib/var_types.py", line 112, in _internal_render
    ret += self.var[i].__str__()
  File "/home/ksharp/work/git/rubiks/lib/var_types.py", line 120, in __str__
    return self.renderer(self._internal_render())
  File "/home/ksharp/work/git/rubiks/lib/var_types.py", line 107, in _internal_render
    ret += self.to_string()
  File "/home/ksharp/work/git/rubiks/lib/kube_vartypes.py", line 27, in to_string
    s = str(self.value)
  File "/home/ksharp/work/git/rubiks/lib/var_types.py", line 119, in __str__
    return self._internal_render()
  File "/home/ksharp/work/git/rubiks/lib/var_types.py", line 107, in _internal_render
    ret += self.to_string()
  File "/home/ksharp/work/git/rubiks/lib/kube_vartypes.py", line 102, in to_string
    stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  File "/usr/lib/python2.7/subprocess.py", line 711, in __init__
    errread, errwrite)
  File "/usr/lib/python2.7/subprocess.py", line 1343, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory
mb-m commented 6 years ago

that's to do with the htpasswd (in this particular repository), and we should better trap that, and generate a proper error message - nothing to do with git-crypt that I can tell.

katsharp commented 6 years ago

btw it works now that i installed those 2 things